Request
Thetranslate() function converts text from one supported language to another. Pass text and target. The source language is optional: leave it out and Spitch detects the input language for you, or set it when you want to specify the input language explicitly.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
text | string | Yes | The text to translate. |
target | string | Yes | Language code of the desired output (e.g. "ha"). |
source | string | No | Language code of the input text (e.g. "en"). |
tone | string | No | One of neutral, warm, professional, or narration. |
formality | string | No | One of casual or formal. |
Context matters. Translations can vary depending on phrasing, tone, and domain, so test with representative samples from your use case.
Response
A successful request returns a JSON object with the translated text.| Field | Type | Description |
|---|---|---|
request_id | string | Request identifier for support and audit flows. |
text | string | The translated output. |
For error codes and retry guidance, see Troubleshooting.