---
title: "OCR - Extract text from image"
method: POST
path: "/image/to-text"
tags: ["Image"]
---

# OCR - Extract text from image

`POST /image/to-text`

## Request

- Base URL: `https://api.filegraph.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.filegraph.ai/image/to-text`
- Auth: API key in header `X-API-Key`

Extract text from an image using Optical Character Recognition (OCR).

## Supported Formats
- PNG, JPEG, TIFF, BMP, GIF, WebP

## Language Support
Use ISO 639-3 language codes. Multiple languages can be combined with '+'.

Examples:
- `eng` - English
- `deu` - German
- `fra` - French
- `eng+fra` - English and French

## Example Usage

```python
import httpx

with open("scan.png", "rb") as f:
    response = httpx.post(
        "https://api.filegraph.ai/image/to-text",
        headers={"X-API-Key": "your-api-key"},
        files={"file": f},
        data={"language": "eng"}
    )
print(response.json()["text"])
```

## Query parameters

- `language` string

## Response `200`

Text successfully extracted

- TextExtractionResponse: Response for text extraction endpoints.
  - `text` string, required: Extracted text content
  - `format_detected` string, required: Detected input format (e.g., 'pdf', 'docx', 'image')
  - `word_count` integer, required: Number of words extracted
  - `char_count` integer, required: Number of characters extracted
  - `used_ocr` boolean, required: Whether OCR was used for extraction
  - `metadata` object: Additional format-specific metadata

## Other responses

- `400`: Invalid image format
- `422`: OCR processing failed

---

[API](https://skmtc.dev/filegraph/apis/docconvert-api.md) · [All operations](https://skmtc.dev/filegraph/apis/docconvert-api/llms.txt) · [OpenAPI document](https://skmtc.dev/filegraph/apis/docconvert-api/revisions/436255c85bd4?raw)
