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 simple endpoint to send an image and receive the translation instantly.

API Reference

Endpoints

Build Your Request

Authentication

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

Translate Endpoint

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.

Request Parameters (Form Data)

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

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.

custom_prompt string * max 500 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.

Request Body

The body of the request must contain the raw binary data of the image you want to translate or clean, as multipart/form-data, with the key "file" containing the image bytes.

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"
        }
    ]
}

Example Code

Manage Your API Key

Please sign in to generate and manage your API key.

Sign In