Audio provides three independent contracts: transcription, translation, and speech synthesis. Transcriptions and translations use multipart; Speech uses JSON and returns audio bytes or SSE based on the requested format.
https://api.tokensmarket.ai/v1POST /audio/transcriptionsThe endpoint remains fixed. Use the parameter documentation on this page to replace the model ID and request data.
${base_url}/audio/transcriptions${base_url}/audio/translations${base_url}/audio/speechTranscribe an audio file, requesting text, JSON, or SSE according to model capabilities.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
file | file | Yes | — | Audio file to transcribe. |
model | string | Yes | — | Model ID that supports transcription. |
language | string | No | — | Optional ISO-639-1 input language hint. |
prompt | string | No | — | Transcription prompt. |
temperature | number | No | — | Sampling temperature. |
response_format | string | No | — | Target text or JSON format. |
timestamp_granularities[] | string[] | No | — | Request segment or word timestamps when supported by the model. |
stream | boolean | No | — | Set to true to enable SSE when supported by the model. |
extra_body | JSON string | No | — | JSON string in the multipart form; it can contain provider. |
Translate an audio file; fields depend on the selected model's supported range.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
file | file | Yes | — | Audio file to translate. |
model | string | Yes | — | Model ID that supports translation. |
prompt | string | No | — | Translation prompt. |
temperature | number | No | — | Sampling temperature. |
response_format | string | No | — | Target text or JSON format. |
extra_body | JSON string | No | — | JSON string in the multipart form; it can contain provider. |
Speech submits text in JSON; it requests SSE only when stream=true and stream_format="sse".
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | Yes | — | Model ID that supports Speech. |
input | string | Yes | — | The text to be synthesized. |
voice | string | object | Yes | — | Voice or voice object supported by the model. |
response_format | string | No | — | Output audio format. |
speed | number | No | — | Speech speed when supported by the model. |
stream | boolean | No | — | Enables streaming audio. |
stream_format | string | No | — | Set to sse to request SSE output. |
extra_body.provider | object | No | — | Optional provider routing configuration. |
Put routing conditions in extra_body.provider. The processing order is ignore → ranges → only → sort → order; order boosts the providers named in the array last.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
extra_body.provider | object | No | — | Container for provider filters, ranges, sorting, and priority. Options / constraints: ignore, *_range, only, sort, order, allow_fallbacks. |
extra_body.provider.allow_fallbacks | boolean | No | — | Defaults to false when only is non-empty; otherwise defaults to true. Options / constraints: Returns HTTP 503 / no_available_provider when no channel is available. |
The following fields are HTTP response headers, not JSON, SSE event, or binary response body fields. They are not guaranteed when a network failure prevents the request from reaching the gateway.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
X-Client-Request-Id | string | No | — | Echoed when supplied by the caller; the gateway does not generate it automatically when omitted. |
X-Upstream-Request-Id | string | No | — | Usually used for gateway request tracing; it does not represent the provider's original request ID. |
The error body follows the selected protocol. HTTP 400 means invalid_request, HTTP 402 means insufficient available balance or quota, and HTTP 429 means rate limiting.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
error.code | string | No | — | Machine-readable error code defined by the protocol. |
error.message | string | No | — | Human-readable error description. |
A supported Audio SSE stream sends its protocol termination event and ends with data: [DONE] on normal completion; an interrupted stream is not guaranteed to deliver the termination event or data: [DONE]. Usage charges can still occur if the client disconnects after processing or output has started.
The examples use placeholders. Replace them with a currently available model ID from the model details page, and keep your API Key in a server-side environment variable.
curl https://api.tokensmarket.ai/v1/audio/transcriptions \
-H "Authorization: Bearer $TOKEN_MARKET_API_KEY" \
-F "file=@meeting.mp3" \
-F "model=<MODEL_ID>" \
-F "response_format=verbose_json" \
-F "stream=true" \
-F 'extra_body={"provider":{"sort":["latency"]}}'