簡介

歡迎使用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 錯誤請求 -- 您的請求無效。
401 未授權 -- 您的API密鑰無效。
402 需要付款 -- 您的帳戶餘額不足。
403 禁止 -- 您的API密鑰無效或團隊未找到。
404 未找到 -- 指定的資源無法找到。
500 內部服務器錯誤 -- 我們的服務器出現問題。請稍後再試。
503 服務不可用 -- 我們正在進行維護。請稍後再試。
---------- -------
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
}