Skip to main content

Language Services

:::warning Beta — quality may vary These endpoints are in beta and still being improved. The upstream model isn't always accurate: translations and especially speech transcription can miss or mistranslate, particularly for accents, mixed-language speech, and uncommon phrases. Treat output as a starting point — plan for human review or fallback, and don't rely on it for legally binding or safety-critical content. We're actively working on accuracy. :::

Translate between English and Ghana's major languages, and transcribe Ghanaian-language speech — powered by GhanaNLP Khaya. These endpoints make your product speak the user's language.

Languages: Twi, Ewe, Ga, Dagbani, Fante, Frafra.

Translate

POST /v2/language/translate — use ISO 639-3 codes (from and to must differ):

Request object:

ParameterTypeRequiredDefinition
textstringrequiredThe text to translate
fromstringrequiredSource ISO 639-3 code, e.g. eng
tostringrequiredTarget ISO 639-3 code, e.g. twi (must differ from from)
curl -X POST "https://api.afrihex.com/v2/language/translate" \
-H "X-API-Key: $AFRIHEX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "Turn right at the Melcom filling station",
"from": "eng",
"to": "twi"
}'
{
"success": true,
"data": {
"translated": "Dan kɔ baabi a wɔhyɛ Melcom ma no pɛɛ",
"from": "eng",
"to": "twi",
"cached": true
}
}

Supported codes: eng, twi, ewe, gaa, dag, fat, gur, yor, kik, luo. Translations are cached, so repeated strings (like route-instruction templates) cost one upstream call ever. Public but throttled — the upstream is metered.

Transcribe speech

POST /v2/language/transcribe converts Ghanaian-language audio to text:

curl -X POST "https://api.afrihex.com/v2/language/transcribe" \
-H "X-API-Key: $AFRIHEX_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "audio_base64": "…", "language": "tw" }'

Speech recognition can't be cached, so this endpoint is throttled more tightly than translation.

Availability

  • When the upstream is unconfigured on a deployment, both endpoints return 503 LANGUAGE_QUOTA.
  • Quota exhaustion surfaces as 503 LANGUAGE_QUOTA, distinct from transport failures — distinguish them so you can retry one and not the other.

Use cases

  • Localized navigation — translate route instructions into Twi for a driving app (see Routing).
  • Voice search — transcribe spoken place names, then resolve via place search.
  • Support & onboarding — translate your app's UI and messages.

API reference

See Language Services — API Reference for the endpoints in this group.