Router
Ocr
Extracts text content while maintaining document structure and hierarchyfrom orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.router.ocr(model="mistral/mistral-ocr-4-0", document={
"type": "document_url",
"document_url": "https://example.com/invoice.pdf",
})
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.router.ocr({
model: "mistral/mistral-ocr-4-0",
document: {
type: "document_url",
documentUrl: "https://example.com/invoice.pdf",
},
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"model": str, # required
"document": { # required
# one of: Document1, Document2
"type": Union[Literal["document_url"], Literal["image_url"]], # required
"document_url": str, # required (variant-specific)
"document_name": Optional[str],
"image_url": { # required (variant-specific)
# one of: ImageURL2, str
"url": str, # required
"detail": Optional[str],
},
},
"pages": List[int], # optional
"ocr_settings": { # optional
"include_image_base64": Optional[bool],
"max_images_to_include": Optional[int],
"image_min_size": Optional[int],
},
}
{
model: string; // required
document: { // required
// one of: Document1, Document2
type: "document_url" | "image_url"; // required
documentUrl: string; // required (variant-specific)
documentName?: string;
imageUrl: { // required (variant-specific)
// one of: ImageUrl2, string
url: string; // required
detail?: string;
};
};
pages?: number[];
ocrSettings?: {
includeImageBase64?: boolean;
maxImagesToInclude?: number;
imageMinSize?: number;
};
}
Show Response
Show Response
{
"model": str,
"pages": [{
"index": float,
"markdown": str,
"images": [{
"id": str,
"image_base64": Optional[str],
}],
"dimensions": { # optional
"dpi": int,
"height": int,
"width": int,
},
}],
"usage": {
# one of: Usage1, Usage2
"type": Union[Literal["pages"], Literal["tokens"]],
"pages_processed": int,
"input_cost": Optional[float],
"output_cost": Optional[float],
"total_cost": Optional[float],
"tokens_processed": int,
},
}
{
model: string;
pages: {
index: number;
markdown: string;
images: {
id: string;
imageBase64?: string;
}[];
dimensions?: {
dpi: number;
height: number;
width: number;
};
}[];
usage: {
// one of: Usage1, Usage2
type: "pages" | "tokens";
pagesProcessed: number;
inputCost?: number;
outputCost?: number;
totalCost?: number;
tokensProcessed: number;
};
}