llmocrapi.comGuide
OCR API Documentation: Endpoints, Modes and Limits
This page works as OCR API documentation for developers who want the full surface in one place: two endpoints, four request modes, the limits and the errors. The API cleans text that an OCR engine has already produced; it does not read images.
Updated

Key points
- Two methods exist: POST /v1/chat/completions and GET /v1/models, authenticated with a Bearer key.
- Streaming, JSON mode and tool calling follow the OpenAI chat format, with the model ID uncensored.
- Limits: 8 concurrent requests and 300 per minute on a full key, 2 and 60 on a trial key, 8 MB body.
- Errors on overload are HTTP 429 with a code that tells you whether to slow down or reduce parallelism.
Overview and authentication
The service is a hosted, OpenAI-compatible text API. Its purpose on this site is the second half of an OCR job: take the raw string an OCR engine produced and return clean prose, structured fields or flagged lines. Input is text only. There is no image, audio or video input or output, no embeddings and no fine-tuning.
Everything lives under one base URL, https://api.llmocrapi.com/v1. Authentication is a standard Bearer header: Authorization: Bearer YOUR_KEY. You create the key on the API key page after signing up with Google, or with email and password. The model behind the endpoint is a single open-weight model run by an independent provider. It is not the official API of any model vendor and it is not a router across vendors. Its ID is always uncensored.
For a hands-on walkthrough instead of a reference, the quickstart in the docs section covers the first request step by step.
Endpoints at a glance
| Method and path | Purpose |
|---|---|
GET /v1/models | Lists available models. Use it as a cheap key check. |
POST /v1/chat/completions | Runs the model on a list of messages. Supports streaming, JSON mode and tools. |
That is the whole surface. Because it matches the OpenAI wire format, any client library that lets you set a base URL and key will work. The quickest sanity check is:
curl https://api.llmocrapi.com/v1/models \
-H "Authorization: Bearer $LLMOCR_API_KEY"
A valid key returns a model list containing uncensored. A wrong key returns an authentication error instead, which tells you the problem is the key and not your request body.
Request parameters
A chat completion request needs model and messages. The optional fields below are passed through to the model.
temperatureandtop_p: sampling controls. For OCR repair usetemperature0 so identical input gives identical output.max_tokens: optional. If you leave it out, the completion can use whatever is left of the 100,000-token window after your prompt. Set it when you want a hard cap on cost per call.stop: strings that end generation. Handy when you ask for output between markers.seed: improves repeatability across runs.presence_penaltyandfrequency_penalty: passed through. Leave them at zero for cleanup, since penalties can push the model to alter repeated legitimate words such as table headers.stream,response_format,toolsandtool_choice: covered in the next three sections.
The context window counts prompt and completion together at 100,000 tokens, and the request body may be up to 8 MB. In practice the token limit arrives first.
Streaming responses
Set "stream": true and the API sends Server-Sent Events as the text is generated. Streaming helps interactive tools, such as an editor where a person watches a cleaned paragraph appear. Token usage is reported at the end of the stream, so you can still record the cost.
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.llmocrapi.com/v1", api_key=os.environ["LLMOCR_API_KEY"])
stream = client.chat.completions.create(
model="uncensored",
stream=True,
messages=[{"role": "user", "content": "Fix this OCR text: th1s is a sam-\nple."}],
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
if getattr(chunk, "usage", None):
print("\ntokens:", chunk.usage.prompt_tokens, chunk.usage.completion_tokens)
One detail affects throughput. A streamed request occupies its concurrency slot until the stream ends. If your code stops reading halfway and leaves the connection open, that slot stays busy. Close the stream explicitly, or consume it to the end.
JSON mode
JSON mode asks the model to reply with a JSON object rather than prose. Enable it with response_format and describe the keys in your instructions.
{
"model": "uncensored",
"temperature": 0,
"response_format": {"type": "json_object"},
"messages": [
{"role": "system", "content": "Return JSON with keys 'text' (cleaned string) and 'uncertain_lines' (array of integers)."},
{"role": "user", "content": "line one\nl1ne two\nline thr3e"}
]
}
Parse defensively. JSON mode shapes the output, but you should still validate the keys and types before they go into your database. If a response was cut off by max_tokens, the JSON may be incomplete, so raise the cap or send smaller pieces.
Tool calling
Tool calling lets the model ask your code to do something instead of writing prose. For OCR work, a common use is returning structured corrections: the model calls a function with the line number and replacement, and your code applies it. Define tools in the tools array, pick behavior with tool_choice, and return results as messages with role: "tool". When streaming, tool calls arrive incrementally as tool_calls deltas.
tools = [{
"type": "function",
"function": {
"name": "replace_line",
"description": "Replace one line of the OCR text with a corrected version.",
"parameters": {
"type": "object",
"properties": {
"line": {"type": "integer"},
"text": {"type": "string"},
},
"required": ["line", "text"],
},
},
}]
resp = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "1: The inven-\n2: tory was com1leted."}],
tools=tools,
tool_choice="auto",
)
for call in resp.choices[0].message.tool_calls or []:
print(call.function.name, call.function.arguments)
Arguments come back as a JSON string. Parse them, apply the change, and if you continue the conversation, append the assistant message and a role: "tool" message with the matching tool_call_id. This pattern keeps output tokens low, since the model returns only the lines it changes.
Settings that suit text cleanup
A reference is more useful with a recommended starting point, so here is how the parameters usually combine for OCR repair. These are suggestions from how the task behaves, not measured benchmarks.
- Deterministic repair:
temperature0, no penalties, a fixedseed. Use this for archives where you want a rerun to reproduce yesterday's output. - Field extraction:
temperature0,response_formatset tojson_object, and amax_tokenscap slightly above the largest object you expect. - Interactive review:
streamtrue and a short system prompt, so an editor sees corrected text appear and can stop it early. - Line-level fixes: tools with a
replace_linestyle function, so the model returns only what changed.
Message roles follow the usual convention: system for standing instructions, user for the OCR text, assistant for earlier replies in a multi-turn session, and tool for function results. Put the instructions in the system message and the raw text in the user message. If the OCR text itself contains something that looks like an instruction, such as a scanned sign saying to ignore previous text, the separation makes it easier to tell the model that the user message is data to repair and never a command to follow. Say so explicitly in the system prompt.
Keep a record of the X-Request-Id value for every call. It is the handle support needs if one page comes back wrong and you want it looked at.
Limits, headers and errors
| Limit | Full key | Trial key |
|---|---|---|
| Concurrent requests | 8 | 2 |
| Requests per minute | 300 | 60 |
| Max body size | 8 MB | 8 MB |
| Context window | 100,000 tokens | 100,000 tokens |
Responses include X-Request-Id (quote it to support), X-Balance-USD (your remaining credit), X-RateLimit-Limit-Requests and X-RateLimit-Limit-Concurrency.
When you pass a limit the API answers HTTP 429. The error code rate_limited means too many requests in a minute, so spread the load. The code concurrency means too many requests in flight, so lower the number of workers. A 429 carrying a Retry-After: 5 header signals temporary overload: wait five seconds and send again. Failed and refused requests are not charged, so a retry loop is safe.
Billing is per token: $0.15 per 1M input and $0.50 per 1M output, taken from prepaid credit that never expires. See the pricing page for top-up amounts and bonuses. Prompts are not used for training. The content rule is a single hard limit: no sexual content involving minors. Policy questions go to support.
More guides
Questions and answers
Which endpoints does the API offer?
Two: POST /v1/chat/completions for generation and GET /v1/models for the model list. Both use the same Bearer key.
Does it support streaming and function calling?
Yes. Set stream to true for SSE with usage at the end, and use tools and tool_choice for function calls, returning results as role tool messages.
What is the maximum input size?
The context window is 100,000 tokens for prompt plus completion, and the request body can be up to 8 MB.
Why did I get a 429 error?
You exceeded either requests per minute (rate_limited), parallel requests (concurrency), or hit temporary overload, which includes Retry-After: 5. Wait and retry.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.