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.
Sign Up & Get Your Key
Create a free account and generate your unique API key from your dashboard.
Purchase Credits
Our API uses a simple credit-based system. Top up your account to start translating.
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
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
Authentication
Authenticate your requests by including your API key in the Authorization
header as a Bearer token.
OCR Endpoint
Credits Cost
Each request to the ocr endpoint costs 1 credit.
Request Body
The body of the request must contain the raw binary data of the image you want to perform OCR on, 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 OCR result, else the response contains an error message.
credits number
The amount of credits remaining in the account.
Response Body
The response content will be a JSON object containing the extracted text from the image.
{
"angle": 0,
"width": 930,
"height": 696,
"paragraphs": [
{
"boundingBox": [10, 320, 170, 320, 170, 370, 10, 370],
"text": "Thank you very much!",
"lines": [
{
"boundingBox": [11, 326, 165, 327, 165, 361, 11, 360],
"text": "Thank you",
"words": [
{
"boundingBox": [12, 327, 100, 327, 99, 361, 11, 360],
"text": "Thank",
"confidence": 0.998
},
{
"boundingBox": [107, 327, 160, 328, 160, 361, 107, 361],
"text": "you",
"confidence": 0.998
}
]
},
{
"boundingBox": [15, 365, 180, 366, 180, 395, 15, 394],
"text": "very much!",
"words": [
{
"boundingBox": [16, 366, 80, 366, 80, 394, 16, 394],
"text": "very",
"confidence": 0.996
},
{
"boundingBox": [85, 366, 160, 366, 160, 394, 85, 394],
"text": "much!",
"confidence": 0.995
}
]
}
],
"detectedLanguage": {
"language": "ENGLISH",
"code": "en",
"confidence": 0.9
}
}
]
}
Response Fields
angle number
The detected rotation angle of the input image in degrees.
width number
The width of the input image in pixels.
height number
The height of the input image in pixels.
paragraph array
An array of objects, where each object represents a detected paragraph of text.
paragraph[].boundingBox array
An array of 8 numbers representing the four (x, y) coordinates of the bounding box surrounding the paragraph.
paragraph[].text string
The recognized text content of the paragraph.
paragraph[].lines array
An array of line objects within the paragraph.
paragraph[].lines[].boundingBox array
An array of 8 numbers representing the four (x, y) coordinates of the bounding box surrounding the line.
paragraph[].lines[].text string
The recognized text content of the line.
paragraph[].lines[].words array
An array of word objects within the line.
paragraph[].lines[].words[].boundingBox array
An array of 8 numbers representing the four (x, y) coordinates of the bounding box surrounding the word.
paragraph[].lines[].words[].text string
The text of the individual word.
paragraph[].lines[].words[].confidence number
The confidence level (0 to 1) of the word recognition.
paragraph[].detectedLanguage object
An object containing information about the detected language of the line.
paragraph[].detectedLanguage.language string
The full name of the detected language.
paragraph[].detectedLanguage.code string
The language code (e.g., "en", "ja").
paragraph[].detectedLanguage.confidence number
The confidence level (0 to 1) of the language detection.
Example Code
Authentication
Authenticate your requests by including your API key in the Authorization
header as a Bearer token.
Inpaint Endpoint
Credits Cost
Each request to the inpaint endpoint costs 0.02 credits.
Request Body Files
The body must contain the following files as multipart/form-data:
image file * required
The original image file.
mask file * required
The mask image file (white areas will be inpainted).
Response Headers
success boolean
Whether the request was successful.
credits number
The amount of credits remaining.
Response Body
The response content is a JSON object.
{
"success": true,
"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=...",
"text_objects": []
}
Example Code
Manage Your API Key
Please sign in to generate and manage your API key.
Sign InYour unique API key:
Keep your API key secure. Do not share it publicly. You can only copy it once, but you can revoke it at any time and generate a new one.