For Developers

Torii Image Translator API

Integrate the power of Torii's API into your own applications.

Get Started in Minutes

Start translating images with just a few lines of code.

1

Sign Up & Get Your Key

Create a free account and generate your unique API key from your dashboard.

2

Purchase Credits

Our API uses a simple credit-based system. Top up your account to start translating.

3

Make Your First Request

Use our endpoints to perform translation, OCR, inpainting, or typesetting.

Limits & Rate Throttling

To ensure service reliability and fair resource distribution, the Torii API implements rate limiting and file size constraints on all requests.

Standard Rate Limit

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

Steady State Rate

1 request / second

Standard processing rate per API key.

Burst Capacity

100 requests

Spikes are queued and processed sequentially.

Image & File Limits

The API enforces constraints on uploaded media to ensure fast processing times:

Max File Size

30 MB

Maximum allowed file payload size.

Max Side Length

50,000 px

Height & width limit per image.

Total Resolution

50 Megapixels

Maximum total resolution limit.

Handling Limit Errors

When limits are exceeded, subsequent requests will be rejected with an HTTP status code of 429 Too Many Requests or 503 Service Unavailable (for rate limits) or a client/validation error (for size limits). We recommend implementing a retry mechanism with exponential backoff in your application to handle these gracefully.

API Reference

Endpoints

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.

Request Parameters (Form Data)

These parameters should be sent as part of the multipart/form-data body, alongside the file.

file file * required

The image file to be translated.

target_lang string * required

The target language code for the translation.

translator string * required

The translation model to use.

font string * required

The font to be used for the translated text.

text_align string

The alignment of the translated text.

stroke_disabled boolean

Whether to disable the text stroke/outline (useful for some documents, since Torii tries to detect the stroke and color for every word).

min_font_size number

The minimum font size of the rendered translated text.

bubbles_only boolean

If true, only text inside detected speech bubbles will be translated and also text that is very long and high-confidence, even if not inside a bubble.

custom_prompt string * max 1000 chars

A custom prompt with instructions to guide the translation.

context string * max 10000 chars

Additional context to ground translation and provide extra information about the names, characters, events, dialogue, history, etc.

You can start a context chain with the string "None" as input for the first image's context. Then, for the next images, you can use the previous context to continue the chain. The previous context is returned in the response body under the key "context".

If you don't wish to start a context chain, you can omit this parameter, or use any other starting context string besides "None". This will simply provide regular context to the model without any special instructions.

x-byok-<provider> string

Optional. Your custom API key for a Bring-Your-Own-Key (BYOK) provider. If supplied, requests will use your own provider API key and account. Image translation will be reduced to 1 credit (OCR/server costs), no matter text length or model chosen, and Text translation will be 0.01.

The parameter name must be prefixed with x-byok- followed by one of the supported provider names:

  • x-byok-openrouter: OpenRouter API Key
  • x-byok-openai: OpenAI API Key
  • x-byok-google: Google Gemini API Key
  • x-byok-anthropic: Anthropic Claude API Key
  • x-byok-deepseek: DeepSeek API Key
  • x-byok-xai: xAI Grok API Key
  • x-byok-local: Self-hosted API Key (optional)

x-byok-local-url string

The Base URL of your self-hosted OpenAI-compatible LLM endpoint (e.g. https://my-llm-server.com/v1). Required if using self-hosted option.

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, and the detected text objects. 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"
        }
    ]
}

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.

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).

Example Code

Manage Your API Key

Please sign in to generate and manage your API key.

Sign In