Документация / API
Речь и расшифровка
Синтез речи и расшифровка. Звук на выходе в чате — через modalities на странице чата.
Модели синтеза речи →Модели расшифровки →
Синтез речи отвечает аудио без usage: стоимость списывается, когда провайдер её сообщит, её видно в кабинете. Расшифровка принимает файл формой или base64 в input_audio; резерв считается по размеру звука.
/v1/audio/speechSynthesize speech
Returns audio bytes. The response carries no usage: the cost is charged after the provider reports it. provider and input_references are refused with 400: they change the price and cannot be bounded in advance.
Ключ: заголовок Authorization: Bearer <ключ>. Как получить ключ →
Тело запроса
application/json
inputstringобязательноеmodelstringобязательноеresponse_formatstringspeednumbervoicestring- Остальные поля формата OpenRouter передаются модели без изменений.
Пример запроса
{
"input": "Hello world.",
"model": "openai/gpt-4o-mini-tts",
"voice": "alloy"
}Ответ 200
Audio.
Ошибки
- 400The request is invalid or its cost cannot be bounded in advance. Nothing is charged.
- 401Missing or invalid API key.
- 402The balance does not cover the reserve of this request.
- 403The input was flagged by moderation; metadata.reasons lists why.
- 404The model provider rejected the request (its status is kept: 400, 404, 413 or 422); metadata.provider_message, when present, is the provider's explanation.
- 413The model provider rejected the request (its status is kept: 400, 404, 413 or 422); metadata.provider_message, when present, is the provider's explanation.
- 422The model provider rejected the request (its status is kept: 400, 404, 413 or 422); metadata.provider_message, when present, is the provider's explanation.
- 429Too many requests, or the model provider is busy. Retry-After, when present, says when to retry.
- 502The model provider failed or returned an error.
- 503Billing or the model provider is temporarily unavailable.
Формат тела ошибки и что делать — Лимиты и ошибки.
/v1/audio/transcriptionsTranscribe audio
The audio arrives either as a multipart file or as base64 in input_audio.data. The reserve is computed from the audio size.
Ключ: заголовок Authorization: Bearer <ключ>. Как получить ключ →
Тело запроса
application/json, multipart/form-data
input_audioobjectобязательноеdatastringобязательноеbase64 audio.
formatstring
languagestringmodelstringобязательноеresponse_formatstring- Остальные поля формата OpenRouter передаются модели без изменений.
Пример запроса
{
"input_audio": {
"data": "UklGRiQAAABXQVZF",
"format": "wav"
},
"model": "openai/whisper-1"
}Ответ 200
Transcript.
durationnumberlanguagestringtextstringобязательноеusageobjectcompletion_tokensintegercostnumber | nullAmount actually charged, in roubles with five decimals (thousandths of a kopeck). null while the provider cost is being fetched (pending) or the charge is under review.
cost_statusstringfinal — charged by the provider's actual cost; estimated — by our price table; pending — the cost is being fetched, the charge follows; review — an operator decides.
Значения:
final,estimated,pending,reviewprompt_tokensintegertotal_tokensinteger
- Остальные поля формата OpenRouter передаются модели без изменений.
Пример ответа
{
"text": "Hello world.",
"usage": {
"cost": 0.52,
"cost_status": "final"
}
}Ошибки
- 400The request is invalid or its cost cannot be bounded in advance. Nothing is charged.
- 401Missing or invalid API key.
- 402The balance does not cover the reserve of this request.
- 403The input was flagged by moderation; metadata.reasons lists why.
- 404The model provider rejected the request (its status is kept: 400, 404, 413 or 422); metadata.provider_message, when present, is the provider's explanation.
- 413The model provider rejected the request (its status is kept: 400, 404, 413 or 422); metadata.provider_message, when present, is the provider's explanation.
- 422The model provider rejected the request (its status is kept: 400, 404, 413 or 422); metadata.provider_message, when present, is the provider's explanation.
- 429Too many requests, or the model provider is busy. Retry-After, when present, says when to retry.
- 502The model provider failed or returned an error.
- 503Billing or the model provider is temporarily unavailable.
Формат тела ошибки и что делать — Лимиты и ошибки.