curl --request POST \
--url https://api.sunbird.ai/tasks/translate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"target_language": "<string>",
"text": "<string>",
"source_language": "<string>"
}
'import requests
url = "https://api.sunbird.ai/tasks/translate"
payload = {
"target_language": "<string>",
"text": "<string>",
"source_language": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({target_language: '<string>', text: '<string>', source_language: '<string>'})
};
fetch('https://api.sunbird.ai/tasks/translate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sunbird.ai/tasks/translate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'target_language' => '<string>',
'text' => '<string>',
'source_language' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sunbird.ai/tasks/translate"
payload := strings.NewReader("{\n \"target_language\": \"<string>\",\n \"text\": \"<string>\",\n \"source_language\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sunbird.ai/tasks/translate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"target_language\": \"<string>\",\n \"text\": \"<string>\",\n \"source_language\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sunbird.ai/tasks/translate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"target_language\": \"<string>\",\n \"text\": \"<string>\",\n \"source_language\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"delayTime": 123,
"executionTime": 123,
"id": "<string>",
"output": {
"text": "<string>",
"translated_text": "<string>",
"source_language": "<string>",
"target_language": "<string>",
"Error": "<string>"
},
"status": "<string>",
"workerId": "<string>",
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Translate
Translate text between supported languages using the Sunflower model.
Languages are accepted as ISO 639-3 codes (e.g. lug) or full names
(e.g. Luganda), case-insensitively. source_language is optional —
when omitted, Sunflower infers the source language from the text.
Translation works between any pair of supported languages.
Supported languages: Acholi (ach), Alur (alz), Aringa (luc), Ateso (teo), Bari (bfa), English (eng), Jopadhola (adh), Kakwa (keo), Karamojong (kdj), Kinyarwanda (kin), Kumam (kdi), Kupsabiny (kpz), Kwamba (rwm), Lango (laj), Lubwisi (tlj), Luganda (lug), Lugbara (lgg), Lugungu (rub), Lugwere (gwr), Lumasaba (myx), Lunyole (nuj), Lusoga (xog), Ma’di (mhi), Pokot (pok), Rukiga (cgg), Rukonjo (koo), Runyankole (nyn), Runyoro (nyo), Ruruuli (ruc), Rutooro (ttj), Samia (lsm), Swahili (swa).
Example
Request body
{
"source_language": "eng",
"target_language": "lug",
"text": "Hello, how are you?"
}
Response
{
"id": "trans-1a2b3c...",
"status": "COMPLETED",
"output": {
"translated_text": "Oli otya?",
"source_language": "eng",
"target_language": "lug"
}
}
curl --request POST \
--url https://api.sunbird.ai/tasks/translate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"target_language": "<string>",
"text": "<string>",
"source_language": "<string>"
}
'import requests
url = "https://api.sunbird.ai/tasks/translate"
payload = {
"target_language": "<string>",
"text": "<string>",
"source_language": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({target_language: '<string>', text: '<string>', source_language: '<string>'})
};
fetch('https://api.sunbird.ai/tasks/translate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sunbird.ai/tasks/translate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'target_language' => '<string>',
'text' => '<string>',
'source_language' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sunbird.ai/tasks/translate"
payload := strings.NewReader("{\n \"target_language\": \"<string>\",\n \"text\": \"<string>\",\n \"source_language\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sunbird.ai/tasks/translate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"target_language\": \"<string>\",\n \"text\": \"<string>\",\n \"source_language\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sunbird.ai/tasks/translate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"target_language\": \"<string>\",\n \"text\": \"<string>\",\n \"source_language\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"delayTime": 123,
"executionTime": 123,
"id": "<string>",
"output": {
"text": "<string>",
"translated_text": "<string>",
"source_language": "<string>",
"target_language": "<string>",
"Error": "<string>"
},
"status": "<string>",
"workerId": "<string>",
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authorizations
The access token received from the authorization server in the OAuth 2.0 flow.
Body
Request model for Sunflower-backed text translation.
Languages may be given as ISO 639-3 codes (e.g. lug) or full names
(e.g. Luganda). This schema stores the raw value as-is; the router
normalizes case and validates membership in the supported language set
via resolve_language (returning a 400 with the supported list for
anything unsupported).
Fields
source_language— Optional source language; auto-detected when omitted.target_language— The target language (code or full name).text— The text to translate (min 1 character, whitespace stripped).
Response
Successful Response
Response model for translation worker API calls.
This model wraps the translation worker output with metadata about the job execution.
Fields
delayTime— Time spent waiting in queue (ms).executionTime— Time spent executing the job (ms).id— Unique job identifier.output— The translation output data.status— Job status (e.g., "COMPLETED", "FAILED").workerId— Identifier of the worker that processed the job.usage— Token usage for the Sunflower translation call, when available.
Time spent waiting in queue (ms)
Time spent executing the job (ms)
Unique job identifier
The translation output data
Show child attributes
Show child attributes
Job status (e.g., COMPLETED, FAILED)
Identifier of the worker that processed the job
Token usage for the Sunflower translation call
Show child attributes
Show child attributes

