---
title: "Extract Text from Images with OCR"
method: POST
path: "/chat/completions"
tags: ["OCR"]
---

# Extract Text from Images with OCR

`POST /chat/completions`

## Request

- Base URL: `https://platform.qubrid.com/v1`
- URL: `https://platform.qubrid.com/v1/chat/completions`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/qubrid/apis/qubrid-ocr-api/docs/chat/completions/post.ts> (a function with typed inputs; its response is checked against the schema)

Use specialized OCR vision models to extract and recognize text from images via the OpenAI-compatible chat completions API.

## Request body

- OCRRequest
  - `model` string, required: The OCR-specialized vision model to use for text extraction.
  - `messages` object[], required: Chat-style input containing text instructions and image content for OCR processing.
    - `role` string
    - `content` object[]
      - `type` string
      - `text` string
      - `image_url` object
        - `url` string: Publicly accessible image URL containing text to extract.
  - `max_tokens` integer: Maximum number of tokens to generate in the OCR response.
  - `temperature` number: Sampling temperature for text extraction (lower = more deterministic).
  - `top_p` number: Nucleus sampling parameter for OCR output.
  - `stream` boolean: Whether to stream OCR output incrementally.

## Response `200`

OCR text extraction completed successfully

- OCRResponse: Standard OpenAI-compatible chat completion response with extracted text.
  - `id` string
  - `object` string
  - `created` integer
  - `model` string
  - `choices` object[]
    - `index` integer
    - `message` object
      - `role` string
      - `content` string
    - `finish_reason` string

## Other responses

- `400`: Bad request - missing required fields, invalid values, or malformed JSON
- `401`: Unauthorized - missing or invalid API key
- `402`: Insufficient credits to process the request
- `403`: Forbidden - authenticated but not allowed to access this model or resource
- `404`: Model not found - the specified OCR model does not exist or is not available
- `413`: Payload too large - input exceeds the model context window
- `429`: Rate limit exceeded
- `500`: Internal server error
- `502`: Bad gateway - upstream OCR provider is unavailable or returned an error
- `504`: Gateway timeout - upstream OCR provider took too long to respond

## Changes

- **2026-04-13** `cc5d51dc7845`: 6 breaking, 6 warning, 42 info
  - the `error` response's property type changed from `string` to `object` for status `400`
  - the `error` response's property type changed from `string` to `object` for status `401`
  - the `error` response's property type changed from `string` to `object` for status `403`
  - the `error` response's property type changed from `string` to `object` for status `404`
  - …50 more
- **2026-03-30** `af53edd6e945`: 5 info
  - api operation id `createVisionCompletion` removed and replaced with `createOCRCompletion`
  - api tag `OCR` added
  - api tag `Vision` removed
  - the `max_tokens` request property default value changed from `16384` to `8192`
  - …1 more

[Operation history](https://skmtc.dev/qubrid/apis/qubrid-ocr-api/changes/chat/completions/post.md)

---

[API](https://skmtc.dev/qubrid/apis/qubrid-ocr-api.md) - [All operations](https://skmtc.dev/qubrid/apis/qubrid-ocr-api/llms.txt) - [OpenAPI document](https://skmtc.dev/qubrid/apis/qubrid-ocr-api/revisions/cc5d51dc7845?raw)
