Torii Image Translator API

Bring Torii's image translation, OCR, inpainting, typesetting and colorization into your own apps, paid for with the same credits as the rest of Torii.

Get started in minutes

Start translating images with just a few lines of code.

  1. 1

    Sign up and get your key

    Create a free account, then create an API key at the bottom of this page.

  2. 2

    Top up your credits

    The API spends the same credits as the rest of Torii. Top up your account to start translating.

  3. 3

    Make your first request

    Call the endpoints to translate, run OCR, inpaint, typeset or colorize. Each has example code below.

Limits and rate throttling

Every API key is rate limited, and uploads have size limits, so requests stay fast for everyone.

Standard rate limit

Your API key has a default throttling limit configured to manage steady traffic:

Steady rate 1 request / second Standard processing rate per API key.
Burst capacity 100 requests Spikes are queued and processed sequentially.

Image and file limits

Uploaded images have to fit these limits, which keeps processing fast:

Max file size 50 MB Maximum allowed file payload size.
Max side length 100,000 px Height and width limit per image.
Total resolution 100 MP Maximum total resolution limit.

Handling limit errors

Past the rate limit, requests are rejected with 429 Too Many Requests or 503 Service Unavailable. Past a size limit, they get a validation error. Retry with exponential backoff, so your app handles these gracefully.

API reference

Pick an endpoint to see its parameters, responses and example code.

Translate endpoint

Translate images or raw text between dozens of languages. Image translation automatically handles text detection, inpainting and typesetting, with lots of other settings and features available.

POST https://api.toriitranslate.com/api/v2/upload

Credits cost

Each request to the translate endpoint costs at least 1 credit, but it may cost more depending on the chosen translation model, context and input/output character length.

Build your request

Authentication

Authenticate your requests by including your API key in the Authorization header as a Bearer token.

Parameters

form data

Send these as multipart/form-data fields, with the image under file. Booleans are the strings true and false; anything other than true counts as false.

file file required

The image to translate, up to 50 MB, 100,000 px on its longest side and 100 megapixels.

target_lang string required

The language to translate into, as a language code.

All language codes
translator string optional

The model that translates. An unknown value falls back to the default.

Default
gemini-3.1-flash-lite
All models
reasoning_effort string optional

How much the model thinks before it translates. More thinking can help with hard pages, but it uses more tokens, so it costs more credits. Some models always think a little, even with none. An unknown value falls back to the default.

Default
none
Values
nonelowmediumhigh
font string optional

The font for the translated text. Pick one that covers your target language. An unknown value falls back to the default.

Default
wildwords
All fonts
text_align string optional

How translated lines line up inside their bubble.

Default
auto, which follows the alignment of each original text
Values
autoleftcenterright
min_font_size integer optional

The smallest font size, in pixels, that Torii may shrink text to so it fits. A value outside the range falls back to the default.

Default
6
Range
6 to 100
stroke_disabled boolean optional

Turns off the outline drawn around text. Torii matches each text's outline and colours to the original, which can look wrong on documents.

Default
false
bubbles_only boolean optional

Translates only text inside speech bubbles, plus long text read with high confidence outside them. Sound effects and background text stay as they are.

Default
false
source_langs_whitelist string (JSON array) optional

Translates and erases only text detected in these languages, such as ["ja", "zh"]. Text in any other language stays as it is, and text whose language can't be detected is always kept. Use the same codes as target_lang.

Default
every language
custom_prompt string optional

Extra instructions for the model, such as a tone or how to translate certain names.

Limit
2,000 characters
context string optional

Background that helps the translation: names, characters, events, earlier dialogue. To chain pages, send None with the first one, then send back the context each response returns. Any other text is used as plain background.

Limit
10,000 characters; only the last 10,000 are kept
x-byok-<provider> string optional

Your own API key for an AI provider (BYOK). The translation then runs on your account with that provider, and Torii charges a flat 1 credit per image, or 0.1 per text request. Put the provider's name in place of <provider>.

Values
x-byok-openrouterOpenRouter
x-byok-openaiOpenAI
x-byok-googleGoogle Gemini
x-byok-anthropicAnthropic Claude
x-byok-deepseekDeepSeek
x-byok-xaixAI Grok
x-byok-localYour self-hosted model's key, if it needs one; see x-byok-local-url
x-byok-local-url string required for a self-hosted model

The base URL of your self-hosted, OpenAI-compatible endpoint, such as https://my-llm-server.com/v1. Set translator to the model name it serves. Local and private network addresses are refused, so expose it through a tunnel.

x-byok-fallback boolean optional

What happens when your own key fails, for example when the model blocks the content or times out. With true, Torii's own models translate the request instead and charge their usual credits, and metadata.fallback_model names the model that ran. With false, the request fails with your provider's error.

Default
false

Response headers

success boolean

Whether the request was successful. If true, the response contains the translated or cleaned image, else the response contains an error message.

credits number

The amount of credits remaining in the account.

Response body

The response content is a JSON object containing the translated image as a Data URL, the inpainted image as a Data URL, the detected text objects, remaining account balance, and request execution metadata. The context key will be empty if a context chain has not been started (see above for explanation).

{
    "image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII...",
    "inpainted": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII...",
    "context": "...",
    "text": [
        {
            "x": 623.0, 
            "y": 326.5, 
            "width": 50.0, 
            "height": 141.0, 
            "text": "Tanjiro", 
            "originalText": "炭治郎", 
            "textAlign": "center", 
            "strokeColor": "#f9f7f9", 
            "lineWidth": 10, 
            "fillColor": "#0e0c0f", 
            "font": "36px WildWords", 
            "addFontBackground": false, 
            "addFontBorder": false, 
            "addBackgroundColor": "#ffffff",
            "rotation": 0.0,
            "angle": 0.0,
            "layout": "h",
            "textDir": "ltr"
        }
    ],
    "metadata": {
        "credits_used": 1.25,
        "ocr_time": 0.452,
        "inpaint_time": 0.381,
        "translation_time": 1.124,
        "render_time": 0.089,
        "total_texts_count": 14,
        "filtered_texts_count": 0,
        "prompt_tokens": 420,
        "completion_tokens": 150,
        "reasoning_tokens": 0,
        "total_tokens": 570,
        "attempts": [
            {
                "model": "google/gemini-3.1-flash-lite",
                "duration": 1.124,
                "status": "success",
                "stage": "translation"
            }
        ]
    }
}

Response fields

image string

The base64-encoded Data URL of the final translated image. Only present for image translation requests (DataType: IMAGE).

inpainted string

The base64-encoded Data URL of the inpainted image (image with source text removed). Only present for image translation requests (DataType: IMAGE).

original string

Optional. The base64-encoded Data URL of the original source image. Only present for image translation requests (DataType: IMAGE) when a remote image URL is supplied and the user is authenticated.

context string

Optional. The updated translation context string. Only present if a context chain is active or has been updated.

detected_lang string

The detected ISO language code of the input text (e.g. "ja", "ko", "zh"). Only present for text translation requests (DataType: TEXT).

text array

An array of translated contents. Always present. For image responses, this is an array of objects detailing bounding box coordinates and styling rules. For text responses, this is an array of raw translated strings.

text[].x / y number

The X and Y pixel coordinates of the center point of the text bounding box.

text[].width / height number

The dimensions (width and height) of the text box in pixels.

text[].text string

The final translated text content rendered inside the box.

text[].originalText string

The original detected source text.

text[].textAlign string

Text alignment style ("left", "center", "right").

text[].fillColor / strokeColor string

The text fill and outline/stroke colors in hexadecimal format (e.g. #ffffff).

text[].lineWidth number

The width of the text stroke/outline border in pixels.

text[].font string

CSS font property value specifying size and family (e.g. "36px WildWords").

text[].addFontBackground / addFontBorder boolean

Options indicating whether extra background fills or custom border outlines are applied behind/around the font.

text[].addBackgroundColor string

Hexadecimal background color for the text background if enabled.

text[].rotation / angle number

The text block's rotation in radians and degrees, respectively.

text[].layout string

The orientation layout direction of the text block ("h" for horizontal, "v" for vertical).

text[].textDir string

The layout reading direction of the text flow ("ltr" for left-to-right, "rtl" for right-to-left).

metadata object

Execution metrics, stage timings, token consumption, reasoning thoughts, and fallback attempt waterfall.

metadata.credits_used number

The exact amount of credits deducted for the request.

metadata.ocr_time number

Duration of the OCR text detection stage in seconds.

metadata.inpaint_time number

Duration of the text removal/inpainting stage in seconds.

metadata.translation_time number

Total duration of translation attempts in seconds.

metadata.summarization_time number

Optional. Total duration of context summarization attempts in seconds (when context summarization runs).

metadata.render_time number

Duration of text rendering and font typesetting in seconds.

metadata.total_texts_count number

Total number of detected text paragraphs/bubbles.

metadata.filtered_texts_count number

Number of text paragraphs filtered out by the source languages whitelist.

metadata.prompt_tokens number

Input prompt tokens consumed across all successful LLM calls.

metadata.completion_tokens number

Output completion tokens generated across all successful LLM calls.

metadata.reasoning_tokens number

Thinking/reasoning tokens generated by reasoning models.

metadata.total_tokens number

Total tokens consumed across all successful LLM calls.

metadata.reasoning string

Optional. The internal thinking/reasoning process returned by the translation model.

metadata.fallback_model string

Optional. The fallback model that completed the translation if the primary model failed.

metadata.fallback_reason string

Optional. The reason the primary model failed and triggered a fallback (e.g. "content_filter", "timeout", "schema_validation_failed").

metadata.attempts array

An array of objects representing each model attempt and fallback in the execution waterfall.

metadata.attempts[].model string

Model identifier used for this attempt.

metadata.attempts[].duration number

Duration of this attempt in seconds.

metadata.attempts[].status string

Status of the attempt ("success" or "failed").

metadata.attempts[].stage string

Pipeline stage ("translation" or "summarization").

metadata.attempts[].reason string

Optional. The reason the attempt failed if status is "failed".

Example code

Manage your API keys

Give each app its own key. You'll see what each one uses, and you can revoke one without touching the others.

Sign in to create and manage your API keys.

Sign in