Agentic Tranlation
Important
Section titled “Important”Agentic Translation differs from /translation/translate and /translation/batch-translate 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 | /batch-translate | /agentic-translate |
|---|---|---|---|
| Speed | Fast | Medium | Slower |
| Translation Size | Single text | Up to 20 at once | Single text |
| Price | Standard rate | Standard rate | Standard rate (while experimental) |
| Fluency | Good | Good | Excellent (human-like) |
| Dictionary 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”{ "sourceLanguage": "en", "targetLanguage": "de", "text": "Hello, World!", "options": { "uiSafe": false, "glossaryId": "glossary-123" }}Parameters:
sourceLanguage: Source language codetargetLanguage: Target language codetext: Text to translateoptions: Optional configuration objectuiSafe: Whether to ensure UI-safe translations (optional)glossaryId: Glossary ID to use for translation (optional)
Response
Section titled “Response”Success Response (200)
{ "status": "ok", "timestamp": "2025-01-12T22:31:48.856Z", "data": { "id": "task-123456", "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", "text": "Hello, World!", "options": { "uiSafe": false, "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", "text": "Hello, World!", "options": { "uiSafe": False, "glossaryId": "glossary-123" }}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200: result = response.json() task_id = result["data"]["id"] task_status = result["data"]["status"] print(f"Task ID: {task_id}, Status: {task_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", text: "Hello, World!", options: { uiSafe: false, glossaryId: "glossary-123", }, }),});
if (response.ok) { const result = await response.json(); console.log("Task ID:", result.data.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", "text": "Hello, World!", "options": map[string]interface{}{ "uiSafe": false, "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("Task ID: %v, Status: %v\n", data["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 of an agentic translation task by ID.
Endpoint: GET /translation/agentic-translate/{id}
Path Parameters
Section titled “Path Parameters”id: Task ID returned from the agentic-translate endpoint
Response
Section titled “Response”Success Response (200)
{ "status": "ok", "timestamp": "2025-01-12T22:31:48.856Z", "data": { "id": "task-123456", "status": "completed", "result": "Hallo, Welt!", "progress": 100 }}Example Request
Section titled “Example Request”curl -X GET "https://platform.algebras.ai/api/v1/translation/agentic-translate/task-123456" \ -H "X-Api-Key: your_api_key_here"import requests
task_id = "task-123456"url = f"https://platform.algebras.ai/api/v1/translation/agentic-translate/{task_id}"headers = { "X-Api-Key": "your_api_key_here"}
response = requests.get(url, headers=headers)
if response.status_code == 200: result = response.json() task_data = result["data"] print(f"Task ID: {task_data['id']}") print(f"Status: {task_data['status']}") if task_data.get("result"): print(f"Result: {task_data['result']}")else: print(f"Error: {response.status_code}") print(response.json())const taskId = "task-123456";const url = `https://platform.algebras.ai/api/v1/translation/agentic-translate/${taskId}`;
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("Task ID:", result.data.id); 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() { taskID := "task-123456" url := fmt.Sprintf("https://platform.algebras.ai/api/v1/translation/agentic-translate/%s", taskID)
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("Task ID: %v\n", data["id"]) 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)) }}