簡介

歡迎使用 i18n-agent 翻譯 API!這是一項具有文化適應性的 AI 驅動翻譯服務,期望能為您提供幫助。

本 API 文件提供了所有可用端點、身份驗證方式、請求/響應格式和錯誤代碼的詳細資訊,助您輕鬆上手。

基礎 URL

Environment URL
Development http://localhost:8000
Production https://api.i18nagent.ai

主要特點

  • 🌐 Multi-language Support 多語言支援 - 支援 10 多種語言的內容翻譯,並進行文化適應,讓您的內容更具全球化視野。
  • 🚀 Real-time Streaming 即時串流翻譯 - 透過伺服器發送事件提供進度更新,讓您隨時掌握翻譯狀態。
  • 📁 File Translation 檔案翻譯 - 支援 JSON、YAML、XML、CSV 等多種格式,滿足您的各種需求。
  • 🔐 Secure Authentication 安全身份驗證 - 基於 API 金鑰的身份驗證方式,確保您的資料安全。
  • 💳 Credit System 信用額度制 - 按使用量計費的定價模式,讓您靈活控制成本。
  • 🤖 AI-Powered AI 驅動 - 使用先進的 LLM 技術進行準確的翻譯,提升翻譯品質。

身份驗證

請使用以下代碼進行身份驗證:

# 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 金鑰來授權訪問。您可以從您的帳戶儀表板獲取 account dashboard API 金鑰。

API 金鑰必須包含在所有發送到伺服器的 API 請求中,並放在類似以下的標頭中:

Authorization: Bearer i18n_your_api_key_here

請將

替換為您的個人 API 金鑰。
You must replace i18n_your_api_key_here with your personal API key.

端點

服務資訊

獲取服務資訊

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

請求主體參數

Parameter Type Required Description

建立帶有即時進度更新的翻譯

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

請求主體參數

Parameter Type Required Description
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"
  }
}

請求主體參數

Parameter Type Required Description
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"
  }
}

請求主體參數

Parameter Type Required Description
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"
  }
}

查詢參數

Parameter Required Description
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"
  }
}

查詢參數

Parameter Required Description
id Yes Translation ID

下載已翻譯的內容

id="xvudc"/>

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

查詢參數

Parameter Required Description
id Yes Translation ID
language No Language code for specific language result

下載原始檔案

id="xvudc"/>

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

查詢參數

Parameter Required Description
id Yes Translation ID

從檢查點恢復翻譯

id="xvudc"/>

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

查詢參數

Parameter Required Description
id Yes Translation ID

請求主體參數

Parameter Type Required Description
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)

獲取進行中的翻譯任務

id="xvudc"/>

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 使用以下錯誤代碼:

Error Code Meaning
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
}