Embeddings & Audio
Vector embeddings, speech-to-text, text-to-speech and the ephemeral tokens the realtime WebSocket requires.
Embeddings and audio follow the OpenAI shapes. POST /v1/tokens mints the short-lived token a browser must pass as ?key= when opening wss://ai.codai.ro/v1/realtime — a raw codai_ key in the query string is refused (close code 4401). See the embeddings & audio guide for worked examples.
bearerAuthAuthorizationBearer <codai_…>A codai API key (codai_ prefix). Ephemeral tokens from POST /v1/tokens are accepted only by the media surfaces matching their scope (/v1/realtime, /v1/audio/*, /v1/embeddings).
x-request-id?stringClient correlation id; echoed back as x-codai-trace-id and persisted on the usage row.
length <= 128x-codai-session-id?stringGroups requests of one conversation for receipts, stickiness and prompt caching.
length <= 128application/json- body
OpenAI-compatible embeddings body. Unknown fields are accepted and ignored.
model?stringAlias or concrete embedding model id. Defaults to codai-embed (platform default voyage-code-3).
"codai-embed"input*|array<string>One string or a non-empty array of strings. Token-id arrays are not supported.
dimensions?integerOptional output dimensionality cap. Honoured by OpenAI-style upstreams, ignored by others.
1 <= valueuser?stringOpenAI tracking field; logged, never forwarded upstream.
encoding_format?"float"Only float is supported; base64 is rejected with 400.
"float"[key: string]?anyEmbedding vectors in OpenAI list shape.
application/json- response
object*"list""list"data*array<>model*stringUpstream model that produced the vectors (matches x-codai-routed-to).
usage*curl -X POST 'https://ai.codai.ro/v1/embeddings' \ -H 'Content-Type: application/json' \ -d '{ "input": "function add(a, b) { return a + b }"}'{ "object": "list", "data": [ { "object": "embedding", "index": 0, "embedding": [ 0 ] } ], "model": "voyage-code-3", "usage": { "prompt_tokens": 0, "total_tokens": 0 }}bearerAuthAuthorizationBearer <codai_…>A codai API key (codai_ prefix). Ephemeral tokens from POST /v1/tokens are accepted only by the media surfaces matching their scope (/v1/realtime, /v1/audio/*, /v1/embeddings).
x-request-id?stringClient correlation id; echoed back as x-codai-trace-id and persisted on the usage row.
length <= 128x-codai-session-id?stringGroups requests of one conversation for receipts, stickiness and prompt caching.
length <= 128multipart/form-data- body
Multipart form fields. Only the listed fields are forwarded; anything else is dropped.
file*fileAudio file, max 25 MB. The original filename is forwarded (audio.webm when absent).
binarymodel?stringcodai-transcribe, whisper-1 and whisper map to the Whisper deployment; gpt-4o-mini-transcribe to its own.
"codai-transcribe""codai-transcribe""whisper-1""whisper""gpt-4o-mini-transcribe"language?stringISO-639-1 language hint, forwarded verbatim.
prompt?stringOptional text to guide style or spelling, forwarded verbatim.
response_format?stringForwarded verbatim. Use a JSON format (json, verbose_json); text/srt/vtt break the gateway's JSON parse.
"json"temperature?stringSampling temperature as a string form field (0–1), forwarded verbatim.
The transcription as returned by the upstream deployment.
application/json- response
The upstream JSON is returned unchanged. With verbose_json extra fields (language, duration, segments, …) appear alongside text.
text?stringThe transcript.
[key: string]?anycurl -X POST 'https://ai.codai.ro/v1/audio/transcriptions' \ -F 'file=string'{ "text": "Bună, vreau să programez o întâlnire mâine la zece."}bearerAuthAuthorizationBearer <codai_…>A codai API key (codai_ prefix). Ephemeral tokens from POST /v1/tokens are accepted only by the media surfaces matching their scope (/v1/realtime, /v1/audio/*, /v1/embeddings).
x-request-id?stringClient correlation id; echoed back as x-codai-trace-id and persisted on the usage row.
length <= 128x-codai-session-id?stringGroups requests of one conversation for receipts, stickiness and prompt caching.
length <= 128application/json- body
model?stringcodai-tts/tts-1/tts = neutral voice; codai-tts-expressive/gpt-4o-mini-tts = expressive family that honours instructions; codai-speech = Chirp 3 HD (native Romanian, fast); codai-speech-expressive = Gemini 2.5 Flash TTS (native Romanian, honours instructions).
"codai-tts""codai-tts""tts-1""tts""codai-tts-expressive""gpt-4o-mini-tts""codai-speech""codai-speech-expressive"input*stringText to synthesize. Longer than 4096 characters is rejected with 400.
1 <= length <= 4096voice?stringVoice name, not validated. Defaults to alloy (neutral), marin (expressive), Aoede (codai-speech) or Kore (codai-speech-expressive). The expressive family also accepts ash, ballad, coral, echo, fable, onyx, nova, sage, shimmer, verse, cedar. The codai-speech models accept the 30 Chirp 3 HD short names (Achernar … Zubenelgenubi) or a full Google voice name.
response_format?stringAudio container, forwarded without validation.
"mp3"speed?numberPlayback speed multiplier, forwarded when truthy (so 0 is dropped).
instructions?stringDelivery-style hint (e.g. "calm, warm, slow"). Honoured only by codai-tts-expressive/gpt-4o-mini-tts and codai-speech-expressive; truncated to 1000 characters.
length <= 1000language?stringBCP-47 language of the text. Selects the voice locale for the codai-speech models and hints the word-timing transcription.
"ro-RO"timestamps?booleanReturn per-word timings in words. Switches the response to SpeechJson.
falsestore?booleanStore the audio as a studio asset (kind speech, with words in its metadata when timestamps is set) and return it as asset instead of b64_json. Switches the response to SpeechJson.
falseBinary audio in the requested format (the media type is whatever the upstream returned, audio/mpeg when it sent none), or SpeechJson when timestamps or store is true.
- response
Returned by POST /v1/audio/speech when timestamps or store is true.
object*"audio.speech""audio.speech"model*stringThe public model id that served the request.
voice*stringlanguage*stringmime_type*stringduration_seconds*numberLength of the audio in seconds.
b64_json?stringBase64 audio. Present when store is not true.
asset?A codai Studio asset. Returned by /v1/assets and, with response_format: "url", in the data of the image, music and video endpoints.
words?array<>|Per-word timings; present only when timestamps was true, null when the timing pass failed.
cost_micro_usd*stringUpstream cost of the request in micro-USD, as a decimal string.
curl -X POST 'https://ai.codai.ro/v1/audio/speech' \ -H 'Content-Type: application/json' \ -d '{ "input": "Bună ziua! Cu ce te pot ajuta astăzi?"}'{ "object": "audio.speech", "model": "codai-speech", "voice": "Aoede", "language": "ro-RO", "mime_type": "audio/mpeg", "duration_seconds": 0, "b64_json": "string", "asset": { "asset_id": "b4695157-0d1d-4da0-8f9e-5c53149389e4", "kind": "music", "status": "pending", "model": "lyria-002", "url": "http://example.com", "mime_type": "audio/wav", "bytes": 0, "duration_seconds": 0, "width": 0, "height": 0, "created_at": "2019-08-24T14:15:22Z", "expires_at": "2019-08-24T14:15:22Z" }, "words": [ { "word": "Bună", "start": 0, "end": 0 } ], "cost_micro_usd": "480"}bearerAuthAuthorizationBearer <codai_…>A codai API key (codai_ prefix). Ephemeral tokens from POST /v1/tokens are accepted only by the media surfaces matching their scope (/v1/realtime, /v1/audio/*, /v1/embeddings).
x-request-id?stringClient correlation id; echoed back as x-codai-trace-id and persisted on the usage row.
length <= 128application/json- body
scope*stringSurface the token may reach. Only realtime, audio, embeddings and live (realtime + audio) are accepted; anything else is 400.
1 <= length <= 32ttl_seconds?integerLifetime in seconds. Values outside 60–3600 fail validation.
60 <= value <= 3600600The minted token, its expiry and the scope it was bound to.
application/json- response
token*stringBearer credential of the form codai_eph_v1.<payload>.<signature>. Pass it as Authorization: Bearer or as ?key= on /v1/realtime.
expires_at*stringExpiry as an ISO-8601 timestamp.
date-timescope*string"realtime""audio""embeddings""live"curl -X POST 'https://ai.codai.ro/v1/tokens' \ -H 'Content-Type: application/json' \ -d '{ "scope": "realtime"}'{ "token": "codai_eph_v1.eyJraWQiOiIuLi4ifQ.c2lnbmF0dXJl", "expires_at": "2026-09-23T10:15:00.000Z", "scope": "realtime"}Last updated: