Speech-to-Text API Reference
Upload an audio file through the Gate.AI speech-to-text endpoint and receive an OpenAI-compatible transcription result synchronously. When stream=true is set, the gateway relays upstream SSE as text/event-stream, with usage and model_extend on the final frame.
| Field | Value |
|---|---|
| Base URL | https://api.gate.ai/openai/v1 |
| Auth | Authorization: Bearer <API_KEY> |
| Format | OpenAI-compatible; uploads audio with multipart/form-data |
Audio endpoints live under /openai/v1. Speech-to-text and text-to-speech are synchronous capabilities: no job_id is returned and no polling is required. For default binary TTS responses, billing details are recorded in Console Generations.
Speech to Text
/audio/transcriptionsUpload an audio file for transcription and synchronously receive text, usage, and model_extend.cost. gpt-4o-transcribe and gpt-4o-mini-transcribe are token billed; whisper-1 is typically billed by audio duration.
Request Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| Authorization | header | string | Yes | Gate.AI API Key. Format: Bearer <API_KEY> |
| Content-Type | header | string | Yes | Request body format: multipart/form-data |
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Speech-to-text model ID, such as whisper-1, gpt-4o-transcribe, or gpt-4o-mini-transcribe. Availability depends on the platform catalog |
| file | file | Yes | Audio file to transcribe, such as mp3, wav, or m4a |
| language | string | No | Optional language hint, such as zh, to improve transcription accuracy |
| stream | boolean | No | Set true to return text/event-stream transcription events. The final transcript.text.done frame includes usage and model_extend |
Example
1model=gpt-4o-transcribe2language=zh3file=@./input.mp3Response Fields
| Name | Type | Description |
|---|---|---|
| text | string | Transcribed text |
| usage | object | Speech-to-text usage. Different models may return token usage or audio-duration usage |
| usage.input_token_details.audio_tokens | integer | Audio input token count for token-billed transcription models |
| model_extend.cost | string | Actual billed amount in USD. Billing is based on model_extend.cost |
| model_extend.provider | string | Actual upstream provider, such as openai |
| model_extend.line_items | array | Billing line items, such as input_audio, output, or duration-billed items |
Response Example
1{2 "text": "今天天气很好,我们一起去海边散步吧。",3 "usage": {4 "type": "tokens",5 "input_tokens": 14,6 "input_token_details": {7 "text_tokens": 0,8 "audio_tokens": 149 },10 "output_tokens": 18,11 "total_tokens": 3212 },13 "model_extend": {14 "cost": "0.000180",15 "provider": "openai",16 "total_tokens": "32",17 "line_items": [18 {19 "kind": "input_audio",20 "tokens": 14,21 "rate_usd_per_million": "6.0000000000",22 "amount_usd": "0.0000840000"23 },24 {25 "kind": "output",26 "tokens": 18,27 "rate_usd_per_million": "10.0000000000",28 "amount_usd": "0.0001800000"29 }30 ]31 }32}Response
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | Success. Returns transcription text, audio data, or SSE events synchronously. | AudioResponse |
| 400 | Bad Request | Invalid parameters, malformed body, or missing required fields such as model, file, or input. | OpenAIErrorResponse |
| 401 | Unauthorized | API key is invalid or missing. | OpenAIErrorResponse |
| 402 | Payment Required | Insufficient balance. | InsufficientBalanceResponse |
| 404 | Not Found | Model not found, or the audio endpoint is not enabled. | OpenAIErrorResponse |
| 413 | Payload Too Large | Uploaded file or request body is too large. | OpenAIErrorResponse |
| 429 | Too Many Requests | Too many requests. Please slow down. | OpenAIErrorResponse |
| 500 | Internal Server Error | Internal server error. | OpenAIErrorResponse |
| 502 | Bad Gateway | Upstream audio service failed. | OpenAIErrorResponse |