POST
/
v1
/
ai
/
translate
import { JigsawStack } from "jigsawstack";

const jigsaw = JigsawStack({ apiKey: "your-api-key" });

const response = await jigsaw.translate.text({
  "text": [
        "Hello",
        "How are you?",
        "Thank you"
  ],
  "target_language": "zh"
})
{
  "success": true,
  "translated_text": [
        "你好",
        "你好吗?",
        "谢谢你"
  ],
  "_usage": {
        "input_tokens": 18,
        "output_tokens": 18,
        "inference_time_tokens": 33,
        "total_tokens": 69
  }
}

Request Parameters

Body

current_language
string
The language code of the source text. If not provided, the API will attempt to auto-detect the language. All supported language codes can be found here.
target_language
string
required
The language code of the target language to translate to. All supported language codes can be found here.
text
string[]
required
The text to translate. Supports two formats:
  • Single string: {"text": "Hello, how are you doing"}
  • Array of strings: {"text": ["Hello", "How are you doing"]}
Maximum text length is 5000 characters per string.
x-api-key
string
required
Your JigsawStack API key

Response Structure

success
boolean
Indicates whether the call was successful.
translated_text
string | string[]
The translated text. The format matches your input: - If you sent a single string, you’ll receive a single translated string - If you sent an array of strings, you’ll receive an array of translated strings
import { JigsawStack } from "jigsawstack";

const jigsaw = JigsawStack({ apiKey: "your-api-key" });

const response = await jigsaw.translate.text({
  "text": [
        "Hello",
        "How are you?",
        "Thank you"
  ],
  "target_language": "zh"
})
{
  "success": true,
  "translated_text": [
        "你好",
        "你好吗?",
        "谢谢你"
  ],
  "_usage": {
        "input_tokens": 18,
        "output_tokens": 18,
        "inference_time_tokens": 33,
        "total_tokens": 69
  }
}