Media extraction
Read images, documents, scanned PDFs, audio, video and web pages, and get back the data you need as JSON.
Send the address of a file and say what you want from it. Tolky reads the content, including text inside images and scanned documents, and returns the fields you asked for.
Typical uses:
- Read an invoice, a receipt or an ID document and get the number, date and amount.
- Describe a product photo sent by a customer.
- Turn a voice message into structured data, such as the customer's name and request.
| Endpoint | Reads |
|---|---|
| Media extraction | Images, documents (PDF, including scanned ones, DOCX and text), audio, video and web pages. This is the default choice. |
| Audio extraction | Speech in an audio file, in Portuguese. Use it when you need fields from what a person says in a recording, such as a voice message. |
Files must be reachable by a public URL. The API does not accept uploads: host the file first. Links that expire or sit behind a login cannot be read.
Use it with Claude
You can paste a ready-made prompt into Claude Code, or another assistant that can make HTTP calls, and ask it to read files for you. See Use Tolky with Claude.
ReferenceTechnical details
Both endpoints use a host token (Authorization: Bearer $TOLKY_TOKEN). The account is taken from the token. A request without a valid token is refused with 401 before it reaches the endpoint.
The schema
Both endpoints take a schema in the function format: a name, a description and parameters (a JSON Schema object). The response is an object with exactly those properties. Every property needs a type and a description (or enum); an object with properties may skip the description, but its own properties may not.
{
"name": "extract_invoice",
"description": "Invoice data",
"parameters": {
"type": "object",
"properties": {
"number": { "type": "string", "description": "Invoice number" },
"issueDate": { "type": "string", "description": "Issue date, YYYY-MM-DD" },
"total": { "type": "number", "description": "Total amount" }
},
"required": ["number", "total"]
}
}Media extraction
POST /api/externalAPIs/public/tolkyOCRV4
| Name | Type | Required | Description |
|---|---|---|---|
files | string or string[] | Yes | URL of a file or web page. Send one URL per call: when a list has several URLs, some of them are skipped without an error. |
schema | object | No | What to extract. Without it, the response is { "description": "..." }, a detailed description of the content. |
generalInstructions | string | No | Extra guidance, for example "amounts are in reais". |
curl -X POST "https://api.tolky.to/api/externalAPIs/public/tolkyOCRV4" \
-H "Authorization: Bearer $TOLKY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"files": ["https://example.com/invoice-4821.pdf"],
"schema": {
"name": "extract_invoice",
"description": "Invoice data",
"parameters": {
"type": "object",
"properties": {
"number": { "type": "string", "description": "Invoice number" },
"total": { "type": "number", "description": "Total amount" }
}
}
}
}'{
"code": 200,
"message": "OK",
"data": { "number": "4821", "total": 1290.5 }
}The call runs several AI steps, so it can take several seconds. See Conventions for timeouts and retries.
A URL that ends in a known file extension (.pdf, .docx, .png, .jpg and similar) is read with the reader for its type, including the limits below. A URL that does not end in the file name, for example a signed link with parameters after the name, follows a general reading path that does not apply those limits and can give different results. Prefer links that end in the file name.
Audio extraction
POST /api/externalAPIs/public/tolkyAudioExtractV4
| Name | Type | Required | Description |
|---|---|---|---|
url | string | Yes | Public URL of the audio file. |
schema | object | Yes | What to extract. schema.parameters is required. |
mimeType | string | No | audio/mpeg (default), audio/mp4, audio/webm, audio/ogg or audio/wav. Any other value is accepted and the file is handled as MP3. |
generalInstructions | string | No | Extra guidance for the extraction. |
curl -X POST "https://api.tolky.to/api/externalAPIs/public/tolkyAudioExtractV4" \
-H "Authorization: Bearer $TOLKY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/voice-note.ogg",
"mimeType": "audio/ogg",
"schema": {
"name": "extract_request",
"parameters": {
"type": "object",
"properties": {
"customerName": { "type": "string", "description": "Customer name" },
"request": { "type": "string", "description": "What the customer asked for" }
}
}
}
}'The response data is the object described by your schema. The speech is transcribed in Portuguese.
Audio and video sent to media extraction are described by an AI model, and the extraction works from that description. To pull fields from what a person says, use audio extraction, which works from the full transcript.
Limits
| Limit | Value |
|---|---|
| Pages read in a scanned PDF | 10 per PDF. The transcript ends with a note saying how many pages were read out of the total. |
| Text read from a document | 60,000 characters per document (PDF with a text layer, DOCX and text files). The rest is cut. |
| Document download | 60 seconds. |
| Audio download | 30 seconds. |
| URLs per call | One. See the files field. |
The endpoints do not set a limit on file size.
Errors
| Code | When |
|---|---|
400 | Audio extraction without url or without schema.parameters. |
401 | The token is missing or invalid. |
422 | Nothing could be read. In media extraction: the URL could not be downloaded or read (blocked or expired link), or files is missing or empty. In audio extraction: the file could not be downloaded or transcribed, or no speech was recognized. |
500 | Extraction failed. The response has no details. |
A 401 comes from the gateway and does not use the standard envelope. The body has no code or data:
{ "error": "Unauthorized", "message": "Token ausente ou inválido" }All other errors use the envelope from Conventions. The message text is in Portuguese, so branch on the HTTP status. A 422 from media extraction lists the URLs that could not be reached in data.error.details.inaccessible, each with the HTTP status (or null when there was no response):
{
"code": 422,
"message": "URL inacessível pelo backend e pelo provedor de visão (...): https://example.com/invoice-4821.pdf (status 403)",
"data": {
"error": {
"name": "TolkyError",
"message": "URL inacessível pelo backend e pelo provedor de visão (...)",
"code": 422,
"timestamp": "2026-12-03T14:00:00.000Z",
"details": {
"inaccessible": [{ "url": "https://example.com/invoice-4821.pdf", "status": 403 }]
}
}
}
}Other fields inside details are internal diagnostics. Do not depend on them.