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.

    FieldValue
    Base URLhttps://api.gate.ai/openai/v1
    AuthAuthorization: Bearer <API_KEY>
    FormatOpenAI-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

    POST/audio/transcriptions

    Upload 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

    NameInTypeRequiredDescription
    AuthorizationheaderstringYesGate.AI API Key. Format: Bearer <API_KEY>
    Content-TypeheaderstringYesRequest body format: multipart/form-data

    Request Body

    NameTypeRequiredDescription
    modelstringYesSpeech-to-text model ID, such as whisper-1, gpt-4o-transcribe, or gpt-4o-mini-transcribe. Availability depends on the platform catalog
    filefileYesAudio file to transcribe, such as mp3, wav, or m4a
    languagestringNoOptional language hint, such as zh, to improve transcription accuracy
    streambooleanNoSet true to return text/event-stream transcription events. The final transcript.text.done frame includes usage and model_extend

    Example

    text
    1model=gpt-4o-transcribe2language=zh3file=@./input.mp3

    Response Fields

    NameTypeDescription
    textstringTranscribed text
    usageobjectSpeech-to-text usage. Different models may return token usage or audio-duration usage
    usage.input_token_details.audio_tokensintegerAudio input token count for token-billed transcription models
    model_extend.coststringActual billed amount in USD. Billing is based on model_extend.cost
    model_extend.providerstringActual upstream provider, such as openai
    model_extend.line_itemsarrayBilling line items, such as input_audio, output, or duration-billed items

    Response Example

    json
    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

    StatusMeaningDescriptionSchema
    200OKSuccess. Returns transcription text, audio data, or SSE events synchronously.AudioResponse
    400Bad RequestInvalid parameters, malformed body, or missing required fields such as model, file, or input.OpenAIErrorResponse
    401UnauthorizedAPI key is invalid or missing.OpenAIErrorResponse
    402Payment RequiredInsufficient balance.InsufficientBalanceResponse
    404Not FoundModel not found, or the audio endpoint is not enabled.OpenAIErrorResponse
    413Payload Too LargeUploaded file or request body is too large.OpenAIErrorResponse
    429Too Many RequestsToo many requests. Please slow down.OpenAIErrorResponse
    500Internal Server ErrorInternal server error.OpenAIErrorResponse
    502Bad GatewayUpstream audio service failed.OpenAIErrorResponse