DocTR is a document OCR model deployable via our Serverless Cloud API.
DocTR API
Run DocTR through the HTTP endpoint directly with curl, or with the inference-sdk wrapper.
Get your API Key
Create a Roboflow account, find your key on the Roboflow API settings page and make it available to your shell:
export ROBOFLOW_API_KEY="your-key-here"Run the model
Call the /doctr/ocr endpoint with curl:
curl --location 'https://serverless.roboflow.com/doctr/ocr' \
--header 'Content-Type: application/json' \
--data '{
"api_key": "'"$ROBOFLOW_API_KEY"'",
"image": {"type": "url", "value": "https://media.roboflow.com/inference/license_plate_1.jpg"}
}'Get your API Key
Create a Roboflow account, find your key on the Roboflow API settings page and make it available to your shell:
export ROBOFLOW_API_KEY="your-key-here"Install the dependencies
This package calls the model:
pip install -U inference-sdk supervisionRun the model
Run DocTR on an image containing text:
import os
import supervision as sv
from inference_sdk import InferenceHTTPClient
# Sample image containing text
image = sv.load_image_from_url("https://media.roboflow.com/inference/license_plate_1.jpg")
client = InferenceHTTPClient(
api_url="https://serverless.roboflow.com",
api_key=os.environ["ROBOFLOW_API_KEY"],
)
result = client.ocr_image(inference_input=image, model="doctr")
print(result["result"]) # Extracted textThe code above prints inference results to the terminal:
Mr
AUTPMATIC
280SE
34 T6511DocTR inference speed
Latency measured with Roboflow Inference on 1x NVIDIA L4, batch size 1, mean after warmup.
| Model | Latency (ms) |
|---|---|
doctr | 83.5 |
Measured on a full document image (text detection plus recognition).
Set api_url to match your deployment target:
https://serverless.roboflow.comfor the Serverless Cloud API.http://localhost:9001for a local Inference server.- Your Dedicated Deployment URL for a private endpoint.
Run DocTR with self-hosted Inference
DocTR is a core model in Roboflow Inference, so it also runs on a server you host yourself. Start a local server, then point the same ocr_image call at it:
pip install inference-cli
inference server start # serves http://localhost:9001import os
from inference_sdk import InferenceHTTPClient
client = InferenceHTTPClient(
api_url="http://localhost:9001",
api_key=os.environ["ROBOFLOW_API_KEY"],
)
result = client.ocr_image(inference_input="./container.jpg")
print(result)The response contains the recognized text and the inference time:
{'result': 'MSKU 0439215', 'time': 3.87}