Translate
curl --request POST \
--url https://api.trynawa.com/v1/translateimport requests
url = "https://api.trynawa.com/v1/translate"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.trynawa.com/v1/translate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));Endpoints
Translate
Dialect-aware Arabic translation.
POST
/
v1
/
translate
Translate
curl --request POST \
--url https://api.trynawa.com/v1/translateimport requests
url = "https://api.trynawa.com/v1/translate"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.trynawa.com/v1/translate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));Translate text between English and Arabic with dialect awareness. Generates culturally appropriate translations in Gulf, Egyptian, Levantine, or MSA Arabic.
Cost: $0.005 per request (5 credits). Semantic cache hits are free (
X-NAWA-Cache: HIT).Request
Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer nawa_live_sk_xxx or Bearer nawa_test_sk_xxx |
Content-Type | Yes | application/json |
Body parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
text | string | Yes | The text to translate. Max 5,000 characters. |
source | string | No | Source language: ar, en, auto. Default: auto (detects automatically). |
target | string | Yes | Target language: ar, en. |
dialect | string | No | Target dialect for Arabic output: gulf, egyptian, levantine, msa. Default: msa. |
tone | string | No | Translation tone: formal, casual, social_media. Default: formal. |
platform | string | No | Source platform for social media tone context: youtube, instagram, twitter, facebook. |
metadata | object | No | Arbitrary key-value metadata to attach to the translation. |
Example request
curl -X POST https://api.trynawa.com/v1/translate \
-H "Authorization: Bearer nawa_test_sk_xxx" \
-H "Content-Type: application/json" \
-d '{
"text": "Hello, how are you?",
"source": "en",
"target": "ar",
"dialect": "gulf",
"tone": "casual"
}'
import { Nawa } from '@nawalabs/sdk'
const nawa = new Nawa({ apiKey: process.env.NAWA_API_KEY })
const { data, error } = await nawa.translate({
text: 'Hello, how are you?',
source: 'en',
target: 'ar',
dialect: 'gulf',
tone: 'casual'
})
from nawa import Nawa
nawa = Nawa(api_key="your_api_key")
result = nawa.translate(
text="Hello, how are you?",
source="en",
target="ar",
dialect="gulf",
tone="casual"
)
Response
Success response (200)
{
"success": true,
"result": {
"id": "trn_nw_pon1yom9bkfe",
"object": "translation",
"text": "Hello, how are you?",
"translated_text": "هلا، كيف حالك؟",
"source_language": "en",
"target_language": "ar",
"source_dialect": null,
"target_dialect": "gulf",
"tone": "casual",
"model": "nagl-v1",
"provider": "claude",
"fallback_used": false,
"cached": false,
"cost_usd": 0.005,
"credits_used": 5
},
"errors": [],
"request_id": "req_nw_4c11w71e44cb"
}
Result fields
| Field | Type | Description |
|---|---|---|
text | string | The original input text |
translated_text | string | The translated output |
source_language | string | Detected or specified source language |
target_language | string | Target language |
source_dialect | string or null | Detected dialect if source is Arabic |
target_dialect | string or null | Target dialect if target is Arabic |
tone | string | The tone used for translation |
model | string | Model version used |
provider | string | AI provider used. Currently always claude. |
fallback_used | boolean | Whether the fallback provider was used |
cached | boolean | Whether served from semantic cache |
cost_usd | number | Cost in USD |
credits_used | number | Credits deducted |
Dialect examples
English to Gulf Arabic (casual)
English to Gulf Arabic (casual)
Input: “The food was amazing, thank you so much”
Output: “الأكل كان وايد حلو، مشكور وايد”
curl -X POST https://api.trynawa.com/v1/translate \
-H "Authorization: Bearer nawa_test_sk_xxx" \
-H "Content-Type: application/json" \
-d '{"text": "The food was amazing, thank you so much", "source": "en", "target": "ar", "dialect": "gulf", "tone": "casual"}'
English to Egyptian Arabic (social media)
English to Egyptian Arabic (social media)
Input: “Subscribe to my channel for more content!”
Output: “اشتركوا في القناة عشان يوصلكم كل جديد!”
curl -X POST https://api.trynawa.com/v1/translate \
-H "Authorization: Bearer nawa_test_sk_xxx" \
-H "Content-Type: application/json" \
-d '{"text": "Subscribe to my channel for more content!", "source": "en", "target": "ar", "dialect": "egyptian", "tone": "social_media", "platform": "youtube"}'
Arabic to English (formal)
Arabic to English (formal)
Input: “وش رايكم بالمحتوى الجديد؟”
Output: “What do you think of the new content?”
curl -X POST https://api.trynawa.com/v1/translate \
-H "Authorization: Bearer nawa_test_sk_xxx" \
-H "Content-Type: application/json" \
-d '{"text": "وش رايكم بالمحتوى الجديد؟", "source": "ar", "target": "en", "tone": "formal"}'
MSA to Gulf Arabic dialect conversion
MSA to Gulf Arabic dialect conversion
Input: “كيف حالك اليوم؟” (MSA)
Output: “شلونك اليوم؟” (Gulf)
curl -X POST https://api.trynawa.com/v1/translate \
-H "Authorization: Bearer nawa_test_sk_xxx" \
-H "Content-Type: application/json" \
-d '{"text": "كيف حالك اليوم؟", "source": "ar", "target": "ar", "dialect": "gulf", "tone": "casual"}'
Error responses
| Status | Type | When |
|---|---|---|
| 400 | invalid_request_error | Missing text, source, or target. Invalid values. Text too long. |
| 401 | authentication_error | Invalid or missing API key |
| 402 | insufficient_credits | No credits remaining |
| 429 | rate_limit_error | Rate limit exceeded |
| 500 | api_error | Internal or provider error |
Was this page helpful?