> For the complete documentation index, see [llms.txt](https://docs.cortecs.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cortecs.ai/api/ocr.md).

# OCR \[BETA]

{% hint style="warning" %}
This endpoint is currently in beta. For any issues or feedback, please contact us via [Discord](https://discord.com/invite/bPFEFcWBhp) or <support@cortecs.ai>.
{% endhint %}

## Process a document with OCR

> This endpoint extracts text and structured content from a document or image using the specified OCR model.

```json
{"openapi":"3.0.0","info":{"title":"Cortecs OCR API","version":"1.0.0"},"servers":[{"url":"https://api.cortecs.ai/v1"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"OCRRequest":{"type":"object","description":"A request object for processing a document or image and controlling router behavior.","required":["model","document"],"properties":{"preference":{"type":"string","description":"The provider preference for handling the request.","enum":["speed","cost","balanced"]},"allowed_providers":{"type":"array","items":{"type":"string"},"description":"The providers that are allowed to process the request.","nullable":true},"eu_native":{"type":"boolean","description":"Whether to use only providers based and regulated within the EU.","nullable":true},"allow_quantization":{"type":"boolean","description":"Whether to allow quantized endpoints.","nullable":true},"allow_zero_data_retention":{"type":"boolean","description":"Whether to use only zero-data-retention providers.","nullable":true},"enable_model_fallback":{"type":"boolean","description":"Whether to allow model fallback when the requested model is unavailable.","nullable":true},"fallbacks":{"type":"array","items":{"type":"string"},"description":"Fallback model names to try when the requested model is unavailable.","nullable":true},"model":{"type":"string"},"document":{"oneOf":[{"type":"object","required":["type","document_url"],"properties":{"type":{"type":"string","enum":["document_url"]},"document_url":{"type":"string"}}},{"type":"object","required":["type","image_url"],"properties":{"type":{"type":"string","enum":["image_url"]},"image_url":{"type":"string"}}}]},"pages":{"oneOf":[{"type":"array","items":{"type":"integer"}},{"type":"string"}]},"include_image_base64":{"type":"boolean"},"image_limit":{"type":"integer","nullable":true},"image_min_size":{"type":"integer","nullable":true},"include_blocks":{"type":"boolean","default":true},"document_annotation_format":{"type":"object"},"bbox_annotation_format":{"type":"object"},"document_annotation_prompt":{"type":"string"},"extract_header":{"type":"boolean"},"extract_footer":{"type":"boolean"},"table_format":{"type":"string","enum":["markdown","html"]},"confidence_scores_granularity":{"type":"string","enum":["word","page","block"]}}},"OCRResponse":{"type":"object","required":["object","model","pages"],"properties":{"object":{"type":"string","enum":["ocr"]},"model":{"type":"string"},"pages":{"type":"array","items":{"type":"object","required":["index","markdown"],"properties":{"index":{"type":"integer"},"markdown":{"type":"string"},"images":{"type":"array","items":{"type":"object"}}}}},"document_annotation":{"oneOf":[{"type":"object"},{"type":"string"}],"nullable":true},"usage_info":{"type":"object","required":["pages_processed","credits"],"additionalProperties":false,"properties":{"pages_processed":{"type":"integer"},"credits":{"type":"number","description":"Cortecs credits charged for the request."}}}}}}},"paths":{"/ocr":{"post":{"summary":"Process a document with OCR","description":"This endpoint extracts text and structured content from a document or image using the specified OCR model.","operationId":"createOcr","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OCRRequest"}},"multipart/form-data":{"schema":{"type":"object","required":["model","file"],"properties":{"model":{"type":"string"},"file":{"type":"string","format":"binary"},"pages":{"type":"string"},"preference":{"type":"string","description":"The provider preference for handling the request.","enum":["speed","cost","balanced"]},"allowed_providers":{"type":"array","items":{"type":"string"},"description":"The providers that are allowed to process the request.","nullable":true},"eu_native":{"type":"boolean","description":"Whether to use only providers based and regulated within the EU.","nullable":true},"allow_quantization":{"type":"boolean","description":"Whether to allow quantized endpoints.","nullable":true},"allow_zero_data_retention":{"type":"boolean","description":"Whether to use only zero-data-retention providers.","nullable":true},"enable_model_fallback":{"type":"boolean","description":"Whether to allow model fallback when the requested model is unavailable.","nullable":true},"fallbacks":{"type":"array","items":{"type":"string"},"description":"Fallback model names to try when the requested model is unavailable.","nullable":true}}}}}},"responses":{"200":{"description":"OCR result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OCRResponse"}}}},"500":{"description":"Internal server error."}}}}}}
```
