Developers
ENPT

Use Tolky with Claude

Paste a ready-made prompt into Claude Code so it reads your documents, images and audio through the Tolky media extraction API.

Give Claude a file address and say which fields you want. Claude calls the Tolky media extraction API, reads the file and shows you the result. You do not write any code: you paste one prompt and then ask in plain language.

Where it works

The prompt works where Claude can make HTTP calls, such as Claude Code or another coding agent with access to a terminal. In a chat without network access Claude cannot run the call.

Before you start

Get a token

Tolky issues the token. Ask your Tolky contact for the host token of your account. See Authentication. There is no self-service page for tokens yet.

Keep the token in an environment variable

Save it as TOLKY_TOKEN in the terminal where you start Claude. Never paste the token into the conversation: whatever you type in the chat stays in its history.

Host the file

The API reads files from a public URL. It does not accept uploads, and links that expire or ask for a login cannot be read.

In a Linux or macOS terminal, set the variable and start Claude Code from the same window:

export TOLKY_TOKEN="<your-token>"
claude

In PowerShell:

$env:TOLKY_TOKEN = "<your-token>"
claude

The prompt

Copy it and paste it as the first message of the session.

Prompt for Claude Code
You will use the Tolky media extraction API to read files and give me structured data.

General rules
- Base URL: https://api.tolky.to
- Authentication: header "Authorization: Bearer <token>". The token is in the environment variable TOLKY_TOKEN. Read it from the environment inside the command. Never print the token, write it to a file or put it in a log, and never ask me to paste it in this chat.
- Every call is a POST with "Content-Type: application/json".
- The file must be at a public URL. The API does not accept uploads. If I give you a file from my computer, tell me it must be hosted first.
- Send one URL per call. Prefer URLs that end in the file name, for example .pdf or .png.
- A call can take several seconds. Wait for the answer before sending another one.

Route 1: read images, documents, audio, video and web pages
POST /api/externalAPIs/public/tolkyOCRV4
Body:
- files (required): the URL of the file or page. Accepts images, PDF (including scanned, up to 10 pages read), DOCX, text, audio, video and web pages.
- schema (optional): what to extract, as {"name": "...", "description": "...", "parameters": {JSON Schema with type object and properties}}. Every property needs "type" and "description" (or "enum"); otherwise the API answers 400 INVALID_SCHEMA. Without a schema the response is {"description": "..."} with a detailed description.
- generalInstructions (optional): extra guidance, for example "amounts are in reais".

Route 2: speech in an audio file, in Portuguese
POST /api/externalAPIs/public/tolkyAudioExtractV4
Body:
- url (required): public URL of the audio.
- schema (required): same as route 1, with "parameters".
- mimeType (optional): audio/mpeg (default), audio/mp4, audio/webm, audio/ogg or audio/wav.
- generalInstructions (optional).

Success response (HTTP 200)
{"code": 200, "message": "OK", "data": { ...the schema fields... }}
The result is in data.

Errors
- 401: missing or invalid token. The body is {"error": "...", "message": "..."}, without "code" or "data". Stop, do not retry, and tell me to check TOLKY_TOKEN.
- 400: a required field is missing (route 2). Fix the body and call again.
- 422: the file could not be read (blocked or expired link, link behind a login, empty "files", or no speech in the audio). The message is in Portuguese. For route 1, data.error.details.inaccessible lists each URL with its HTTP status. Tell me which URL failed and do not retry the same URL.
- 500, 502, 503, 504 or timeout: try once more after a few seconds. If it repeats, tell me.

Example
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"}}}}}'
(Adapt the command to the shell you have. The token must still come from TOLKY_TOKEN.)

How to work
1. When I ask you to read a file, build the schema with only the fields I asked for, with a short description on each.
2. Call the right route (speech in audio: route 2; everything else: route 1).
3. Show the contents of data in a table and say which fields came back empty. Do not invent values.

Ask for what you need

After the prompt, write a request like this:

Read https://example.com/invoice-4821.pdf and give me the invoice number, the issue date and the total.

Claude builds the schema, calls the API and shows the fields in a table. Fields it could not find are reported as empty instead of guessed.

How Claude handles problems

ResultWhat Claude does
401Stops and asks you to check the TOLKY_TOKEN variable.
422Tells you which URL could not be read. Check that the link is public and has not expired.
400Fixes the request body and calls again.
500, 502, 503, 504 or timeoutTries once more, then tells you.

The limits that matter: one URL per call, a public URL, up to 10 pages read in a scanned PDF. The full list is in Media extraction.

What the prompt sendsTechnical details

Claude calls POST https://api.tolky.to/api/externalAPIs/public/tolkyOCRV4 with a schema it writes from your request. For the invoice example it sends:

{
  "files": ["https://example.com/invoice-4821.pdf"],
  "schema": {
    "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" }
      }
    }
  }
}

The answer carries the extracted fields in data. For speech in a recording, Claude uses POST /api/externalAPIs/public/tolkyAudioExtractV4 instead. Field tables, limits and error bodies are in Media extraction.

Previous

Quickstart

Next

Conventions