API reference
Every endpoint, field and error — generated from the committed OpenAPI contract.
Kalpa Speech API v0.1.0, generated from the committed contract (openapi.json). Base URL https://api.kalpalabs.ai; bodies are JSON; authenticated endpoints take Authorization: Bearer $KALPA_API_KEY. HTTP errors before streaming begins use the envelope described in Rate limits & errors. Each endpoint except the WebSocket runs from this page: fill the fields, hit send — the request and response stay in sync on the right, copyable as curl, Python or JavaScript.
Stored only in this browser and sent only to api.kalpalabs.ai. No key? Write to hello@kalpalabs.ai.
POST/v1/tts
Synthesize speech from text.
Render the given text as speech (24 kHz mono WAV) in the requested speaker's voice.
textrequiredText to speak.
modelPublic model id (see GET /v1/models). Omit/null for the default model.
›paramsobject · 4 optional fields
paramsacoustic_temperatureTemperature for the voice's fine acoustic detail; null = follow temperature.
audio_qualityPlayback fidelity: high = full quality (default); lower tiers reduce fidelity, not payload size.
max_new_tokensOptional generation cap; null uses the model's remaining context window.
temperaturespeakerSpeaker role to render the text as (one of the model's speakers; see GET /v1/models).
audioAudioPayloadaudio.audio_qualitystringFidelity tier this audio was rendered at (high = full quality).
audio.data_b64stringBase64-encoded 16-bit PCM WAV (mono).
audio.sample_rateintegerSample rate of the audio in Hz.
audio.formatstringContainer/encoding of data_b64 (16-bit PCM WAV).
modelstringResolved public model id that served the request.
request_idstringCorrelation id; identical to the X-Request-ID response header.
textstringThe text that was spoken (echoes the request).
usageUsageusage.input_audio_secondsnumberSeconds of input audio supplied (converse).
usage.input_charsintegerCharacters of input text billed for this request.
usage.output_audio_secondsnumberSeconds of audio generated.
metaobjectBackend-specific diagnostics (latency, frames, …).
POST/v1/tts/{voice_id}
Synthesize speech from text in a named voice.
Render the given text as speech (24 kHz mono WAV) in one of the named voices from GET /v1/voices.
voice_idrequiredA named voice id, as listed by GET /v1/voices.
textrequiredText to speak.
modelPublic model id (see GET /v1/models). Omit/null for the default model.
›paramsobject · 4 optional fields
paramsacoustic_temperatureTemperature for the voice's fine acoustic detail; null = follow temperature.
audio_qualityPlayback fidelity: high = full quality (default); lower tiers reduce fidelity, not payload size.
max_new_tokensOptional generation cap; null uses the model's remaining context window.
temperatureaudioAudioPayloadaudio.audio_qualitystringFidelity tier this audio was rendered at (high = full quality).
audio.data_b64stringBase64-encoded 16-bit PCM WAV (mono).
audio.sample_rateintegerSample rate of the audio in Hz.
audio.formatstringContainer/encoding of data_b64 (16-bit PCM WAV).
modelstringResolved public model id that served the request.
request_idstringCorrelation id; identical to the X-Request-ID response header.
textstringThe text that was spoken (echoes the request).
usageUsageusage.input_audio_secondsnumberSeconds of input audio supplied (converse).
usage.input_charsintegerCharacters of input text billed for this request.
usage.output_audio_secondsnumberSeconds of audio generated.
metaobjectBackend-specific diagnostics (latency, frames, …).
WSS/v1/tts/{voice_id}/stream
Stream speech in a named voice over WebSocket. Stream text and flush to hear each utterance in the named voice, independently per flush.
Use one connection for one named voice (voice_id as listed by GET /v1/voices). Start with initializeConnection, then stream text with sendText and set flush to true to hear it. Each flushed utterance is generated independently in the connection's voice — no state carries from one response to the next. One response generates at a time; a flush sent mid-generation is queued (one slot) and starts when the current response settles, and a bare cancelResponse abandons everything undelivered — the in-flight generation, the queued utterance, and buffered text.
›initializeConnection10 fieldsStarts and authenticates the session. Send this message first.
initializeConnection10 fieldstyperequired"initializeConnection"api_keyrequiredstringYour Kalpa API key.
modelstring | null · default nullModel id. Omit for the default model.
generation_configGenerationConfig | null · default nullEnable and tune server-side segmentation of streamed text. Omit to generate only on flush.
generation_config.chunk_length_scheduleinteger[] · 1 – 10 itemsBuffered-character thresholds before each successive segment of an utterance may start generating; the last value repeats. Lower values trade prosodic context for earlier first audio.
paramsGenParamsModelGeneration parameters for every response on this connection.
params.acoustic_temperaturenumber | null · 0 – 1.5 · default nullTemperature for the voice's fine acoustic detail; null = follow temperature.
params.audio_qualitystring · low | medium | high · default "high"Playback fidelity: high = full quality (default); lower tiers reduce fidelity, not payload size.
params.max_new_tokensinteger | null · 16 – 2048 · default nullOptional generation cap; null uses the model's remaining context window.
params.temperaturenumber · 0 – 1.5 · default 0.9›sendText3 fieldsAdds text to the pending utterance. Set flush to true to generate its audio. A flush that
arrives while a response is still generating is queued (one slot) and starts when that response
settles; only a flush arriving while another is already queued is rejected.
sendText3 fieldsflush to true to generate its audio. A flush that
arrives while a response is still generating is queued (one slot) and starts when that response
settles; only a flush arriving while another is already queued is rejected.typerequired"sendText"textstring · default ""Text to append to the utterance.
flushboolean · default falseEnds the utterance and starts generation when true.
›cancelResponse2 fieldsStops the current response. Without response_id it abandons everything undelivered — the
in-flight generation, the queued utterance, and buffered text (nothing from an abandoned turn
can leak into the next one; a discarded queued utterance produces no responseDone). With
response_id it cancels that specific response only, leaving buffer and queue intact.
cancelResponse2 fieldsresponse_id it abandons everything undelivered — the
in-flight generation, the queued utterance, and buffered text (nothing from an abandoned turn
can leak into the next one; a discarded queued utterance produces no responseDone). With
response_id it cancels that specific response only, leaving buffer and queue intact.typerequired"cancelResponse"response_idstring | null · default nullResponse to cancel. Omit to cancel the current response.
›sessionCreated8 fieldsConfirms that the session is ready.
sessionCreated8 fieldstype"sessionCreated"session_idstringId for this connection.
modelstringModel serving the session.
voice_idstringThe named voice every response speaks in.
output_format"pcm_s16le"Audio encoding for response chunks.
sample_rateintegerResponse audio sample rate in Hz.
channelsintegeraudio_qualitystring · low | medium | highFidelity tier responses are rendered at.
›responseCreated4 fieldsConfirms that response generation has started.
responseCreated4 fieldstype"responseCreated"response_idstringId for this response.
sample_rateintegeraudio_qualitystring · low | medium | high›responseAudio4 fieldsA chunk of generated audio.
responseAudio4 fieldspcm_b64stringBase64-encoded raw PCM audio.
response_idstringframeinteger | nullBackend frame counter; informational.
type"responseAudio"›responseDone9 fieldsConfirms that the response has completed or was cancelled.
responseDone9 fieldstype"responseDone"response_idstringstatusstring · completed | cancelledtextstringText for the response.
usageUsageusage.input_charsintegerCharacters of input text billed for this request.
usage.input_audio_secondsnumberSeconds of input audio supplied (converse).
usage.output_audio_secondsnumberSeconds of audio generated.
metaobjectPublic generation timing and runtime metadata.
›error7 fieldsReports a WebSocket error.
error7 fieldstype"error"fatalbooleanTrue when the connection is about to close.
errorWsErrorBodyerror.typestringerror.messagestringerror.request_idstring | nullId for the session or response.
response_idstring | nullPresent when the error belongs to a specific generation.
| Code | Meaning | Client action |
|---|---|---|
1011 | Internal server error. | Retry. |
4400 | Protocol violation. | Fix the message before reconnecting. |
4401 | Authentication failed. | Check the API key. |
4404 | Unknown voice id. | See `GET /v1/voices` for the available voices. |
4408 | Initialization or idle timeout. | Reconnect. |
4429 | Reserved for rate limiting; not currently emitted. | Retry with backoff. |
4503 | API-key verification is temporarily unavailable. | Retry with the same key. |
POST/v1/converse
Complete the open (final) turn of a conversation.
Given a conversation, complete its last ('open') turn. A speaker-only open turn is authored (text + audio); an open turn with text is rendered as that speaker, conditioned on the prior turns (contextual TTS).
conversationrequiredThe conversation, oldest turn first; the last turn is the open turn to complete.
audio_wav_b64speakertextaudio_wav_b64speakertextmodelPublic model id (see GET /v1/models). Omit/null for the default model.
›paramsobject · 4 optional fields
paramsacoustic_temperatureTemperature for the voice's fine acoustic detail; null = follow temperature.
audio_qualityPlayback fidelity: high = full quality (default); lower tiers reduce fidelity, not payload size.
max_new_tokensOptional generation cap; null uses the model's remaining context window.
temperaturemodelstringResolved public model id that served the request.
replyConverseReplyreply.speakerstringreply.textstringreply.audioAudioPayload | nullreply.audio.audio_qualitystringFidelity tier this audio was rendered at (high = full quality).
reply.audio.data_b64stringBase64-encoded 16-bit PCM WAV (mono).
reply.audio.sample_rateintegerSample rate of the audio in Hz.
reply.audio.formatstringContainer/encoding of data_b64 (16-bit PCM WAV).
request_idstringCorrelation id; identical to the X-Request-ID response header.
usageUsageusage.input_audio_secondsnumberSeconds of input audio supplied (converse).
usage.input_charsintegerCharacters of input text billed for this request.
usage.output_audio_secondsnumberSeconds of audio generated.
metaobjectPOST/v1/converse/stream
Complete the open turn, streaming audio as it is generated.
Same request as /v1/converse; the response is a text/event-stream: one meta event, audio chunk events as audio is generated (pcm_b64 = base64 raw 16-bit LE PCM at sample_rate), then exactly one end (reply text, audio_seconds, usage, meta) or error. First audio arrives after one ~80 ms frame instead of after the whole clip; closing the connection aborts generation.
conversationrequiredThe conversation, oldest turn first; the last turn is the open turn to complete.
audio_wav_b64speakertextaudio_wav_b64speakertextmodelPublic model id (see GET /v1/models). Omit/null for the default model.
›paramsobject · 4 optional fields
paramsacoustic_temperatureTemperature for the voice's fine acoustic detail; null = follow temperature.
audio_qualityPlayback fidelity: high = full quality (default); lower tiers reduce fidelity, not payload size.
max_new_tokensOptional generation cap; null uses the model's remaining context window.
temperaturetext/event-stream: one meta event, repeated audio events, then exactly one end or error.
WSS/v1/converse/stream
Stream a stateful conversation over WebSocket. Send JSON messages to build the conversation and receive audio as it is generated.
Use one connection for one conversation. Start with initializeConnection, then send text or add completed turns. The server keeps the conversation history until the socket closes and returns generated audio as responseAudio messages.
›initializeConnection9 fieldsStarts and authenticates the WebSocket session. Send this message first.
initializeConnection9 fieldstyperequired"initializeConnection"api_keyrequiredstringYour Kalpa API key.
modelstring | null · default nullModel id. Omit for the default model.
history_limitinteger | null · 1 – 64 · default nullOptional rolling number of completed turns retained for each response.
paramsGenParamsModelGeneration parameters for every response on this connection.
params.acoustic_temperaturenumber | null · 0 – 1.5 · default nullTemperature for the voice's fine acoustic detail; null = follow temperature.
params.audio_qualitystring · low | medium | high · default "high"Playback fidelity: high = full quality (default); lower tiers reduce fidelity, not payload size.
params.max_new_tokensinteger | null · 16 – 2048 · default nullOptional generation cap; null uses the model's remaining context window.
params.temperaturenumber · 0 – 1.5 · default 0.9›sendText4 fieldsAdds text to the current turn. Set flush to true to generate the response.
sendText4 fieldsflush to true to generate the response.typerequired"sendText"speaker_idinteger | null · ≥ 0 · default nullSpeaker for this turn. Required on the first sendText message.
textstring · default ""Text to append to the turn.
flushboolean · default falseEnds the turn and starts generation when true.
›addTurn4 fieldsAdds a completed text-and-audio turn to the conversation history.
addTurn4 fieldstyperequired"addTurn"speaker_idrequiredinteger · ≥ 0textrequiredstring · ≥ 1 charsTranscript for the audio.
audio_wav_b64requiredstring · ≥ 1 charsBase64-encoded WAV audio.
›cancelResponse2 fieldsStops the current response.
cancelResponse2 fieldstyperequired"cancelResponse"response_idstring | null · default nullResponse to cancel. Omit to cancel the current response.
›sessionCreated7 fieldsConfirms that the session is ready.
sessionCreated7 fieldstype"sessionCreated"session_idstringId for this conversation.
modelstringModel serving the session.
output_format"pcm_s16le"Audio encoding for response chunks.
sample_rateintegerResponse audio sample rate in Hz.
channelsintegeraudio_qualitystring · low | medium | highFidelity tier responses are rendered at.
›responseCreated5 fieldsConfirms that response generation has started.
responseCreated5 fieldstype"responseCreated"response_idstringId for this response.
speaker_idintegerSpeaker for this response.
sample_rateintegeraudio_qualitystring · low | medium | high›responseAudio4 fieldsA chunk of generated audio.
responseAudio4 fieldspcm_b64stringBase64-encoded raw PCM audio.
response_idstringframeinteger | nullBackend frame counter; informational.
type"responseAudio"›responseDone10 fieldsConfirms that the response has completed or was cancelled.
responseDone10 fieldstype"responseDone"response_idstringspeaker_idintegerstatusstring · completed | cancelledtextstringText for the response.
usageUsageusage.input_charsintegerCharacters of input text billed for this request.
usage.input_audio_secondsnumberSeconds of input audio supplied (converse).
usage.output_audio_secondsnumberSeconds of audio generated.
metaobjectPublic generation timing and runtime metadata.
›error7 fieldsReports a WebSocket error.
error7 fieldstype"error"fatalbooleanTrue when the connection is about to close.
errorWsErrorBodyerror.typestringerror.messagestringerror.request_idstring | nullId for the session or response.
response_idstring | nullPresent when the error belongs to a specific generation.
| Code | Meaning | Client action |
|---|---|---|
1011 | Internal server error. | Retry. |
4400 | Protocol violation. | Fix the message before reconnecting. |
4401 | Authentication failed. | Check the API key. |
4408 | Initialization or idle timeout. | Reconnect. |
4429 | Reserved for rate limiting; not currently emitted. | Retry with backoff. |
4503 | API-key verification is temporarily unavailable. | Retry with the same key. |
GET/v1/models
List available public models.
dataModelCard[]The available public models.
data[].display_namestringHuman-readable model name.
data[].idstringStable public model id used in the model request field.
data[].modesstring[]Supported modes: subset of ["converse", "tts"].
data[].speakersstring[]Valid role labels for a turn's speaker, in turn order (e.g. ["0", "1"]).
data[].defaultbooleanTrue for the model used when model is omitted.
data[].descriptionstringWhat this model is for.
data[].languagesstring[]Languages the model speaks, as ISO 639-1 codes (e.g. ["en", "hi"]).
GET/v1/voices
List available named voices.
dataVoiceCard[]The available named voices.
data[].genderstringPerceived voice gender.
data[].idstringStable public voice id, used as the /v1/tts/{voice_id} path segment.
data[].namestringHuman-readable voice name.
GET/v1/info
Backend info, default params, and limits.
backendInfoBackendActive gateway/backend description.
backend.detailstringbackend.kindstringbackend.namestringbackend.readybooleanbackend.sample_rateintegerdefaultsGenParamsModelDefault generation parameters.
defaults.acoustic_temperaturenumber | nullTemperature for the voice's fine acoustic detail; null = follow temperature.
defaults.audio_qualitystringPlayback fidelity: high = full quality (default); lower tiers reduce fidelity, not payload size.
defaults.max_new_tokensinteger | nullOptional generation cap; null uses the model's remaining context window.
defaults.temperaturenumberlimitsInfoLimitsEffective request caps and rate limits for this key.
limits.max_audio_bytesintegerlimits.max_conversation_turnsintegerlimits.max_text_charsintegerlimits.rate_limit_burstintegerlimits.rate_limit_rpmintegerparam_schemaParamSchemaEntry[]UI metadata for the generation parameters.
param_schema[].helpstringparam_schema[].keystringparam_schema[].labelstringparam_schema[].typestringparam_schema[].deprecatedbooleanparam_schema[].maxnumberparam_schema[].minnumberparam_schema[].nullablebooleanparam_schema[].offLabelstringparam_schema[].optionsinteger | string[]param_schema[].stepnumberGET/v1/usage
Your metered usage.
Durable usage totals (requests, input characters, audio seconds) for the calling API key. Without parameters, lifetime totals. With start_time/end_time (ISO 8601), totals for that window at hourly granularity: the effective window snaps outward to hour boundaries and is echoed back in the response.
input_audio_secondsnumberinput_charsintegerkey_idstringNon-secret identifier of the API key whose usage is summarized.
output_audio_secondsnumberrequestsintegerend_timestring | nullEffective (hour-snapped) window end, exclusive; windowed queries only.
first_request_tsnumber | nullUnix time of the first metered request (lifetime queries).
last_request_tsnumber | nullUnix time of the latest metered request (lifetime queries).
start_timestring | nullEffective (hour-snapped) window start; windowed queries only.
GET/health
Liveness probe. No authentication.
backendstringreadybooleanstatusstring