Detect Language & Dialect
Endpoints
Detect Language & Dialect
Lightweight language and dialect detection. Returns in under 100ms — no AI model call required.
POST
Detect Language & Dialect
Detect language, dialect, script, and text direction from any text input. Uses local NAGL modules only — no external AI call, so responses return in under 100ms.Documentation Index
Fetch the complete documentation index at: https://developers.trynawa.com/llms.txt
Use this file to discover all available pages before exploring further.
Cost: $0.002 per request (2 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 detect. Max 5,000 characters. |
Example request
Response
Success response (200)
Result fields
| Field | Type | Description |
|---|---|---|
text | string | The original input text |
language | string | Detected language: ar, en, or mixed |
dialect | string or null | Detected Arabic dialect: gulf, egyptian, levantine, msa. Null if not Arabic. |
dialect_confidence | number or null | Confidence score 0—1 for dialect detection. Null if not Arabic. |
script | string | Script type: arabic, latin, or mixed |
text_direction | string | Text direction: rtl or ltr |
word_count | number | Number of words in the input text |
fallback_used | boolean | Always false for this endpoint (local detection only) |
cached | boolean | Whether served from semantic cache |
cost_usd | number | Cost in USD |
credits_used | number | Credits deducted |
Detection examples
Gulf Arabic
Gulf Arabic
Input: “وش رايكم بالمحتوى الجديد؟”
Result: language:
ar, dialect: gulf, confidence: 0.95, script: arabic, direction: rtlEgyptian Arabic
Egyptian Arabic
Input: “الفيديو ده جامد أوي”
Result: language:
ar, dialect: egyptian, script: arabic, direction: rtlEnglish
English
Input: “This is a great video”
Result: language:
en, dialect: null, script: latin, direction: ltrMixed script
Mixed script
Input: “awesome محتوى”
Result: language:
mixed, dialect detected, script: mixed, direction: rtlError responses
| Status | Type | When |
|---|---|---|
| 400 | invalid_request_error | Missing text. 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 error |