简介
欢迎使用i18n-agent翻译API!基于AI的翻译服务,具有文化适应性
本API文档提供了关于所有可用端点、身份验证方法、请求/响应格式和错误代码的全面信息。
基本URL
环境 | URL |
---|---|
开发 | http://localhost:8000 |
生产 | https://api.i18nagent.ai |
主要功能
- 🌐 多语言支持 - 将内容翻译成10多种语言,并进行文化适应
- 🚀 实时流式传输 - 通过服务器发送事件获取进度更新
- 📁 文件翻译 - 支持JSON、YAML、XML、CSV等格式
- 🔐 安全身份验证 - 基于API密钥的身份验证
- 💳 积分系统 - 按使用付费的定价模式
- 🤖 基于AI - 使用先进的大型语言模型进行准确翻译
身份验证
要进行身份验证,请使用以下代码:
# With shell, you can just pass the correct header with each request
curl "api_endpoint_here" \
-H "Authorization: Bearer i18n_your_api_key_here"
const headers = {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
};
fetch('api_endpoint_here', { headers })
.then(response => response.json())
.then(data => console.log(data));
import requests
headers = {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
response = requests.get('api_endpoint_here', headers=headers)
print(response.json())
package main
import (
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "api_endpoint_here", nil)
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
请务必将
i18n_your_api_key_here
替换为您的API密钥。
i18n-agent API使用API密钥来允许访问API。您可以从您的账户仪表板获取您的API密钥。
API密钥必须包含在所有API请求的标头中,如下所示:
Authorization: Bearer i18n_your_api_key_here
端点
服务信息
获取服务信息
GET /
返回服务元数据和可用端点
curl -X GET "https://api.i18nagent.ai/" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json"
const response = await fetch('https://api.i18nagent.ai/', {
method: 'GET',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.get(
'https://api.i18nagent.ai/',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.i18nagent.ai/", )
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
上述命令返回的JSON结构如下:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2025-09-19T08:57:08.356Z"
}
}
监控
健康检查
GET /health
检查服务健康状态
curl -X GET "https://api.i18nagent.ai/health" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json"
const response = await fetch('https://api.i18nagent.ai/health', {
method: 'GET',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.get(
'https://api.i18nagent.ai/health',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.i18nagent.ai/health", )
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
上述命令返回的JSON结构如下:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2025-09-19T08:57:08.357Z"
}
}
积分
获取团队积分
GET /credits
获取经过身份验证的团队的当前积分余额
curl -X GET "https://api.i18nagent.ai/credits" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json"
const response = await fetch('https://api.i18nagent.ai/credits', {
method: 'GET',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.get(
'https://api.i18nagent.ai/credits',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.i18nagent.ai/credits", )
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
上述命令返回的JSON结构如下:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2025-09-19T08:57:08.357Z"
}
}
语言
列出支持的语言
GET /languages
获取所有支持的语言及其质量评级的列表
curl -X GET "https://api.i18nagent.ai/languages" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json"
const response = await fetch('https://api.i18nagent.ai/languages', {
method: 'GET',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.get(
'https://api.i18nagent.ai/languages',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.i18nagent.ai/languages", )
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
上述命令返回的JSON结构如下:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2025-09-19T08:57:08.357Z"
}
}
翻译
创建翻译(统一)
POST /translations
用于翻译文本和文件内容的统一端点
curl -X POST "https://api.i18nagent.ai/translations" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
}'
const response = await fetch('https://api.i18nagent.ai/translations', {
method: 'POST',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
})
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.post(
'https://api.i18nagent.ai/translations',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
},
json={
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
data := map[string]interface{}{
"texts": []string{"Hello, world!", "Welcome to our service"},
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", "https://api.i18nagent.ai/translations", bytes.NewBuffer(jsonData))
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
上述命令返回的JSON结构如下:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2025-09-19T08:57:08.357Z"
}
}
请求正文参数
参数 | 类型 | 必填 | 描述 |
---|
创建带有流式进度的翻译
POST /translations/stream
使用服务器发送事件(SSE)创建实时进度更新的翻译
curl -X POST "https://api.i18nagent.ai/translations/stream" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
}'
const response = await fetch('https://api.i18nagent.ai/translations/stream', {
method: 'POST',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
})
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.post(
'https://api.i18nagent.ai/translations/stream',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
},
json={
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
data := map[string]interface{}{
"texts": []string{"Hello, world!", "Welcome to our service"},
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", "https://api.i18nagent.ai/translations/stream", bytes.NewBuffer(jsonData))
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
上述命令返回的JSON结构如下:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2025-09-19T08:57:08.357Z"
}
}
请求正文参数
参数 | 类型 | 必填 | 描述 |
---|---|---|---|
texts | array | Yes | Array of texts to translate |
targetLanguage | string | Yes | Target language code (e.g., 'es', 'fr', 'ja') |
targetAudience | string | No | Target audience (e.g., 'general', 'technical', 'casual', 'formal') (default: general) |
industry | string | No | Industry context (e.g., 'technology', 'healthcare', 'finance') (default: technology) |
sourceLanguage | string | No | Source language code (auto-detected if not provided) |
region | string | No | Specific region for localization (e.g., 'Spain', 'Mexico', 'Brazil') |
context | string | No | Optional additional context or instructions for the translation (e.g., 'Keep technical terms in English', 'Use formal tone', 'Preserve brand names') |
获取翻译成本估算
POST /translations/estimate
计算字数和所需的翻译积分
curl -X POST "https://api.i18nagent.ai/translations/estimate" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
}'
const response = await fetch('https://api.i18nagent.ai/translations/estimate', {
method: 'POST',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
})
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.post(
'https://api.i18nagent.ai/translations/estimate',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
},
json={
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
data := map[string]interface{}{
"texts": []string{"Hello, world!", "Welcome to our service"},
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", "https://api.i18nagent.ai/translations/estimate", bytes.NewBuffer(jsonData))
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
上述命令返回的JSON结构如下:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2025-09-19T08:57:08.357Z"
}
}
请求正文参数
参数 | 类型 | 必填 | 描述 |
---|---|---|---|
content | string | Yes | Content to analyze |
fileType | string | No | File type for content analysis (default: txt) |
分析
分析内容以确定翻译就绪度
POST /analyze
分析内容以识别潜在问题并获得改进建议,在翻译之前。此端点以与翻译相同的速率消耗积分(每字0.001积分)。
curl -X POST "https://api.i18nagent.ai/analyze" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
}'
const response = await fetch('https://api.i18nagent.ai/analyze', {
method: 'POST',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
})
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.post(
'https://api.i18nagent.ai/analyze',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
},
json={
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
data := map[string]interface{}{
"texts": []string{"Hello, world!", "Welcome to our service"},
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", "https://api.i18nagent.ai/analyze", bytes.NewBuffer(jsonData))
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
上述命令返回的JSON结构如下:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2025-09-19T08:57:08.357Z"
}
}
请求正文参数
参数 | 类型 | 必填 | 描述 |
---|---|---|---|
targetLanguage | string | Yes | Target language code for translation |
targetAudience | string | No | Target audience (default: general) |
industry | string | No | Industry context (default: general) |
sourceLanguage | string | No | Source language code (auto-detected if not provided) |
region | string | No | Specific region for localization |
content | object | Yes | Content to analyze (text, array of texts, or structured object) |
fileType | string | No | Optional file type if content is from a file |
翻译工作
获取翻译详细信息
GET /translations/{id}
通过ID获取特定翻译的详细信息
curl -X GET "https://api.i18nagent.ai/translations/{id}" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json"
const response = await fetch('https://api.i18nagent.ai/translations/{id}', {
method: 'GET',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.get(
'https://api.i18nagent.ai/translations/{id}',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.i18nagent.ai/translations/{id}", )
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
上述命令返回的JSON结构如下:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2025-09-19T08:57:08.357Z"
}
}
查询参数
参数 | 必填 | 描述 |
---|---|---|
id | 是 | 翻译ID |
--------- | -------- | ----------- |
id | Yes | Translation ID |
获取翻译状态
GET /translations/{id}/status
获取翻译作业的当前状态
curl -X GET "https://api.i18nagent.ai/translations/{id}/status" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json"
const response = await fetch('https://api.i18nagent.ai/translations/{id}/status', {
method: 'GET',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.get(
'https://api.i18nagent.ai/translations/{id}/status',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.i18nagent.ai/translations/{id}/status", )
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
上述命令返回的JSON结构如下:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2025-09-19T08:57:08.357Z"
}
}
查询参数
参数 | 必填 | 描述 |
---|---|---|
id | 是 | 翻译ID |
--------- | -------- | ----------- |
id | Yes | Translation ID |
下载翻译结果
GET /translations/{id}/result
下载已翻译的内容
curl -X GET "https://api.i18nagent.ai/translations/{id}/result" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json"
const response = await fetch('https://api.i18nagent.ai/translations/{id}/result', {
method: 'GET',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.get(
'https://api.i18nagent.ai/translations/{id}/result',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.i18nagent.ai/translations/{id}/result", )
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
上述命令返回的JSON结构如下:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2025-09-19T08:57:08.357Z"
}
}
查询参数
参数 | 必填 | 描述 |
---|---|---|
id | 是 | 翻译ID |
language | 否 | 特定语言结果的语言代码 |
--------- | -------- | ----------- |
id | Yes | Translation ID |
language | No | Language code for specific language result |
下载原始文件
GET /translations/{id}/original
下载原始上传的文件
curl -X GET "https://api.i18nagent.ai/translations/{id}/original" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json"
const response = await fetch('https://api.i18nagent.ai/translations/{id}/original', {
method: 'GET',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.get(
'https://api.i18nagent.ai/translations/{id}/original',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.i18nagent.ai/translations/{id}/original", )
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
上述命令返回的JSON结构如下:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2025-09-19T08:57:08.357Z"
}
}
查询参数
参数 | 必填 | 描述 |
---|---|---|
id | 是 | 翻译ID |
--------- | -------- | ----------- |
id | Yes | Translation ID |
从检查点恢复翻译
POST /translations/{id}/resume
从特定检查点或自动从最后一个成功检查点恢复失败或中断的翻译
curl -X POST "https://api.i18nagent.ai/translations/{id}/resume" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
}'
const response = await fetch('https://api.i18nagent.ai/translations/{id}/resume', {
method: 'POST',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
})
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.post(
'https://api.i18nagent.ai/translations/{id}/resume',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
},
json={
"texts": [
"Hello, world!",
"Welcome to our service"
],
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
"sourceLanguage": "en",
"region": "Mexico",
"notes": "Keep technical terms in English, use formal tone"
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
data := map[string]interface{}{
"texts": []string{"Hello, world!", "Welcome to our service"},
"targetLanguage": "es",
"targetAudience": "general",
"industry": "technology",
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", "https://api.i18nagent.ai/translations/{id}/resume", bytes.NewBuffer(jsonData))
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
上述命令返回的JSON结构如下:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2025-09-19T08:57:08.357Z"
}
}
查询参数
参数 | 必填 | 描述 |
---|---|---|
id | 是 | 翻译ID |
--------- | -------- | ----------- |
id | Yes | Translation ID |
请求正文参数
参数 | 类型 | 必需 | 描述 |
---|---|---|---|
checkpointId | string | No | Opaque checkpoint ID to resume from (obtained from status endpoint). If not provided and autoDetect is true, will resume from last successful checkpoint. |
continueToEnd | boolean | No | Whether to continue processing all remaining content after resuming (default: true) |
autoDetect | boolean | No | Automatically detect and resume from the last successful checkpoint if checkpointId is not provided (default: true) |
获取当前正在进行的翻译任务
GET /translations/jobs/active
获取当前正在进行的翻译任务列表
curl -X GET "https://api.i18nagent.ai/translations/jobs/active" \
-H "Authorization: Bearer i18n_your_api_key_here" \
-H "Content-Type: application/json"
const response = await fetch('https://api.i18nagent.ai/translations/jobs/active', {
method: 'GET',
headers: {
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
import json
response = requests.get(
'https://api.i18nagent.ai/translations/jobs/active',
headers={
'Authorization': 'Bearer i18n_your_api_key_here',
'Content-Type': 'application/json'
}
)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.i18nagent.ai/translations/jobs/active", )
req.Header.Add("Authorization", "Bearer i18n_your_api_key_here")
req.Header.Add("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
}
以上命令返回的JSON结构如下:
{
"translations": [
{
"original": "Hello, world!",
"translated": "¡Hola, mundo!",
"confidence": 0.98
}
],
"metadata": {
"sourceLanguage": "en",
"targetLanguage": "es",
"wordCount": 2,
"creditsUsed": 0.002,
"timestamp": "2025-09-19T08:57:08.357Z"
}
}
错误
i18n-agent API使用以下错误代码:
错误代码 | 含义 |
---|---|
400 | Bad Request -- Your request is invalid. |
401 | Unauthorized -- Your API key is invalid. |
402 | Payment Required -- Insufficient credits in your account. |
403 | Forbidden -- Your API key is inactive or team not found. |
404 | Not Found -- The specified resource could not be found. |
500 | Internal Server Error -- We had a problem with our server. Try again later. |
503 | Service Unavailable -- We're temporarily offline for maintenance. Please try again later. |
错误响应格式
{
"error": "Detailed error message describing what went wrong",
"success": false
}