> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# O C R Agent • AI Agent SDK

> OCRAgent: A specialized agent for OCR (Optical Character Recognition).

# OCRAgent

> Defined in the [**Ocr Agent**](../modules/ocr_agent) module.

<Badge color="blue">AI Agent</Badge>

A specialized agent for OCR (Optical Character Recognition).

Extracts text from documents (PDFs) and images using AI models.

Supported Providers:

* Mistral: `mistral/mistral-ocr-latest`

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#8B0000', 'primaryTextColor': '#fff', 'primaryBorderColor': '#710101', 'lineColor': '#189AB4', 'secondaryColor': '#189AB4', 'tertiaryColor': '#fff' }}}%%

graph LR
    input["Input Data"] --> agent["Agent: OCRAgent"]
    agent --> output["Output Result"]
    style agent fill:#8B0000,color:#fff
    style input fill:#8B0000,color:#fff
    style output fill:#8B0000,color:#fff
```

## Constructor

<ParamField query="name" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="instructions" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="llm" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="model" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="base_url" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="api_key" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="ocr" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="verbose" type="Union" required={false} default="True">
  No description available.
</ParamField>

## Methods

<CardGroup cols={2}>
  <Card title="console()" icon="function" href="../functions/OCRAgent-console">
    Lazily initialize Rich Console.
  </Card>

  <Card title="litellm()" icon="function" href="../functions/OCRAgent-litellm">
    Lazy load litellm module when needed.
  </Card>

  <Card title="extract()" icon="function" href="../functions/OCRAgent-extract">
    Extract text from a document or image.
  </Card>

  <Card title="aextract()" icon="function" href="../functions/OCRAgent-aextract">
    Async version of extract().
  </Card>

  <Card title="read()" icon="function" href="../functions/OCRAgent-read">
    Quick OCR - extract and return markdown text.
  </Card>

  <Card title="aread()" icon="function" href="../functions/OCRAgent-aread">
    Async version of read().
  </Card>
</CardGroup>

## Usage

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import OCRAgent
    
    agent = OCRAgent(llm="mistral/mistral-ocr-latest")
    
    # Extract from PDF URL
    result = agent.extract("https://example.com/document.pdf")
    print(result.text)
    
    # Extract from image URL
    result = agent.extract("https://example.com/image.png")
    for page in result.pages:
        print(page.markdown)
```

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/agent/ocr_agent.py#L42">
  `praisonaiagents/agent/ocr_agent.py` at line 42
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Agents Concept" icon="robot" href="/docs/concepts/agents" />

  <Card title="Single Agent Guide" icon="book-open" href="/docs/guides/single-agent" />

  <Card title="Multi-Agent Guide" icon="users" href="/docs/guides/multi-agent" />

  <Card title="Agent Configuration" icon="gear" href="/docs/configuration/agent-config" />

  <Card title="Auto Agents" icon="wand-magic-sparkles" href="/docs/features/autoagents" />
</CardGroup>
