Agentic Translation
Important
Section titled “Important”Agentic Translation differs from /translation/translate and /translation/translate-batch endpoints by using an advanced translation pipeline.
Agentic Translation performs translation through multiple iterations, where each iteration fetches relevant context, estimates quality, provides feedback, and measures fluency. In most cases, this approach produces translations that sound more natural and “human-like”.
Comparison Table
Section titled “Comparison Table”| Feature | /translate |
/translate-batch |
/agentic-translate |
|---|---|---|---|
| Speed | Fast | Medium | Slower |
| Translation Size | Single text | Up to 20 at once | Single text |
| Price | Standard rate | Standard rate | 4x standard rate |
| Fluency | Good | Good | Excellent (human-like) |
| Glossary support | Yes | Yes | Yes |
Start Agentic Translation Task
Section titled “Start Agentic Translation Task”Start an asynchronous agentic translation task.
Endpoint: POST /translation/agentic-translate
Request Body
Section titled “Request Body”Sent as JSON.
| Field | Type | Required | Description |
|---|---|---|---|
sourceLanguage |
string | yes | Source language code (use auto for automatic detection) |
targetLanguage |
string | yes | Target language code |
textContent |
string | yes | Text to translate |
glossaryId |
string | no | Glossary ID to apply during translation |
prompt |
string | no | Custom prompt to guide translation |
ignoreCache |
boolean | no | Ignore previously cached translation results |
Headers
Section titled “Headers”| Header | Required | Description |
|---|---|---|
X-Webhook-Url |
no | URL to receive a POST notification with the translation result once the task completes |
Response
Section titled “Response”Success Response (200)
{ "status": "ok", "timestamp": "2025-01-12T22:31:48.856Z", "data": { "translation_id": "cmabc123translation", "status": "PENDING" }}Example Request
Section titled “Example Request”curl -X POST "https://platform.algebras.ai/api/v1/translation/agentic-translate" \ -H "X-Api-Key: your_api_key_here" \ -H "Content-Type: application/json" \ -d '{ "sourceLanguage": "en", "targetLanguage": "de", "textContent": "Hello, World!", "glossaryId": "glossary-123" }'import requests
url = "https://platform.algebras.ai/api/v1/translation/agentic-translate"headers = { "X-Api-Key": "your_api_key_here", "Content-Type": "application/json"}data = { "sourceLanguage": "en", "targetLanguage": "de", "textContent": "Hello, World!", "glossaryId": "glossary-123"}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200: result = response.json() translation_id = result["data"]["translation_id"] status = result["data"]["status"] print(f"Translation ID: {translation_id}, Status: {status}")else: print(f"Error: {response.status_code}") print(response.json())const url = "https://platform.algebras.ai/api/v1/translation/agentic-translate";
const response = await fetch(url, { method: "POST", headers: { "X-Api-Key": "your_api_key_here", "Content-Type": "application/json", }, body: JSON.stringify({ sourceLanguage: "en", targetLanguage: "de", textContent: "Hello, World!", glossaryId: "glossary-123", }),});
if (response.ok) { const result = await response.json(); console.log("Translation ID:", result.data.translation_id); console.log("Status:", result.data.status);} else { const error = await response.json(); console.error("Error:", response.status, error);}package main
import ( "bytes" "encoding/json" "fmt" "io" "net/http")
func main() { url := "https://platform.algebras.ai/api/v1/translation/agentic-translate"
payload := map[string]interface{}{ "sourceLanguage": "en", "targetLanguage": "de", "textContent": "Hello, World!", "glossaryId": "glossary-123", }
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) req.Header.Set("X-Api-Key", "your_api_key_here") req.Header.Set("Content-Type", "application/json")
client := &http.Client{} resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
if resp.StatusCode == 200 { var result map[string]interface{} json.Unmarshal(body, &result) data := result["data"].(map[string]interface{}) fmt.Printf("Translation ID: %v, Status: %v\n", data["translation_id"], data["status"]) } else { fmt.Printf("Error: %d\n", resp.StatusCode) fmt.Println(string(body)) }}Get Agentic Translation Task Status
Section titled “Get Agentic Translation Task Status”Get the status and result of an agentic translation task by ID.
Endpoint: GET /translation/agentic-translate/{id}
Path Parameters
Section titled “Path Parameters”id: Thetranslation_idreturned from the agentic-translate endpoint
Response
Section titled “Response”Success Response (200)
{ "status": "ok", "timestamp": "2025-01-12T22:31:48.856Z", "data": { "id": "cmabc123translation", "status": "READY", "createdAt": "2025-01-12T22:31:00.000Z", "completedAt": "2025-01-12T22:31:48.856Z", "result": "Hallo, Welt!", "sourceLanguage": "en", "targetLanguage": "de" }}status is one of PENDING, READY, or ERROR. result is present only when status is READY; error is present only when status is ERROR.
Example Request
Section titled “Example Request”curl -X GET "https://platform.algebras.ai/api/v1/translation/agentic-translate/cmabc123translation" \ -H "X-Api-Key: your_api_key_here"import requests
translation_id = "cmabc123translation"url = f"https://platform.algebras.ai/api/v1/translation/agentic-translate/{translation_id}"headers = { "X-Api-Key": "your_api_key_here"}
response = requests.get(url, headers=headers)
if response.status_code == 200: result = response.json() data = result["data"] print(f"Status: {data['status']}") if data.get("result"): print(f"Result: {data['result']}")else: print(f"Error: {response.status_code}") print(response.json())const translationId = "cmabc123translation";const url = `https://platform.algebras.ai/api/v1/translation/agentic-translate/${translationId}`;
const response = await fetch(url, { method: "GET", headers: { "X-Api-Key": "your_api_key_here", },});
if (response.ok) { const result = await response.json(); console.log("Status:", result.data.status); if (result.data.result) { console.log("Result:", result.data.result); }} else { const error = await response.json(); console.error("Error:", response.status, error);}package main
import ( "encoding/json" "fmt" "io" "net/http")
func main() { translationID := "cmabc123translation" url := fmt.Sprintf("https://platform.algebras.ai/api/v1/translation/agentic-translate/%s", translationID)
req, _ := http.NewRequest("GET", url, nil) req.Header.Set("X-Api-Key", "your_api_key_here")
client := &http.Client{} resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
if resp.StatusCode == 200 { var result map[string]interface{} json.Unmarshal(body, &result) data := result["data"].(map[string]interface{}) fmt.Printf("Status: %v\n", data["status"]) if result, ok := data["result"].(string); ok { fmt.Printf("Result: %s\n", result) } } else { fmt.Printf("Error: %d\n", resp.StatusCode) fmt.Println(string(body)) }}