POST /v1/speech: create a speech job
POST /v1/speech is the endpoint to create a speech job. Speaks text (up to 600 characters) in a saved voice ("@handle") or a cloned voice from a 5 to 30 second sample (with voice_consent: true). Answers 202 with a queued job; the result is a WAV file.
At a glance
- Endpoint
POST /v1/speech- Base URL
https://bobabanana.com/api/v1- Auth
Authorization: Bearer bb_...- Success
202(or200withdry_run: true)- Safe to retry
- yes, with an
Idempotency-Keyheader - Guide
- Speech
Request#
Headers#
| Header | Required | Description |
|---|---|---|
Authorization |
yes | Bearer bb_...: your API key (or send X-API-Key: bb_...) |
Content-Type |
yes | application/json |
idempotency-key |
no | Any unique string up to 255 characters (a UUID is ideal). A retry with the same key and the same body within 24 hours returns the first job instead of making a second one; the same key with a different body is 422 idempotency_key_reused. |
Body (JSON)#
| Field | Type | Required | Default | Limits | Description |
|---|---|---|---|---|---|
webhook_url |
string | no | 0 to 500 characters | https:// URL that receives a signed POST when the job finishes | |
metadata |
object of string | no | at most 16 keys | Up to 16 keys (40 characters each) with string values (500 characters each), echoed back on the job and its webhook | |
name |
string | no | 0 to 80 characters | Label shown in the BobaBanana studio | |
max_credits |
integer | no | at least 0 | Refuse the job (400 cost_above_max, nothing held) if it would cost more than this | |
dry_run |
boolean | no | false |
true: answer 200 with what the job would cost (credits_estimate) and make nothing: nothing is queued, held or stored, and no Idempotency-Key is used | |
text |
string | yes | 1 to 600 characters | ||
voice |
string or VoiceSample | yes | |||
voice_consent |
boolean | no | false |
Example request#
A saved voice:
curl https://bobabanana.com/api/v1/speech \
-H "Authorization: Bearer $BOBABANANA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"text": "Thanks for watching. See you next week!",
"voice": "@storyteller"
}'
import os
import uuid
import requests
r = requests.post(
"https://bobabanana.com/api/v1/speech",
headers={"Authorization": f"Bearer {os.environ['BOBABANANA_API_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
json={
"text": "Thanks for watching. See you next week!",
"voice": "@storyteller",
},
timeout=60,
)
r.raise_for_status()
print(r.json())
const res = await fetch("https://bobabanana.com/api/v1/speech", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.BOBABANANA_API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": crypto.randomUUID(),
},
body: JSON.stringify({
"text": "Thanks for watching. See you next week!",
"voice": "@storyteller"
}),
});
if (!res.ok) throw new Error(JSON.stringify(await res.json()));
console.log(await res.json());
More request bodies#
Clone a voice from a sample (cloned_voice):
{
"text": "Welcome to the show.",
"voice": {
"file_id": "file_7a2c9e4b1d08",
"transcript": "Hi, this is a short sample of my voice for cloning."
},
"voice_consent": true
}
Response#
200 (DryRunEstimate): dry_run: true: the price of this request. Nothing is queued, held or stored.
{
"object": "estimate",
"dry_run": true,
"type": "speech",
"credits_estimate": 3,
"credits_available": 950,
"enough_credits": true,
"billing_mode": "credits"
}
202 (Job): Successful Response
{
"id": "x_2f6a9c1e8d47",
"object": "job",
"type": "speech",
"status": "queued",
"created": 1764950400,
"input": {
"text": "Thanks for watching. See you next week!",
"voice": "@storyteller"
},
"output": {},
"eta_seconds": 20,
"poll_after_seconds": 5,
"cost": {
"credits_estimate": 3,
"credits_charged": 0,
"credits_released": 0,
"status": "held"
}
}
Errors#
Errors use the error object. The codes this endpoint can return (what to do about each is in Error codes):
| Status | Code | Meaning |
|---|---|---|
| 400 | bad_request |
The Content-Length header is not a number. |
| 400 | cost_above_max |
The job would cost more than max_credits. credits_estimate gives the price. |
| 400 | fetch_failed |
Downloading a URL input failed or returned an HTTP error. |
| 400 | fetch_timeout |
Downloading a URL input took too long. |
| 400 | file_too_large |
A file or inline data is over its size limit. |
| 400 | invalid_audio |
The audio could not be read. |
| 400 | invalid_base64 |
data is not valid base64. |
| 400 | invalid_image |
The image could not be opened, or it has too many pixels. |
| 400 | invalid_metadata |
metadata has more than 16 keys, a key over 40 characters or a value over 500. |
| 400 | invalid_request |
A field is missing, has the wrong type or breaks a rule. param names the field. Type and range problems found while reading the body are 422 with the same code. |
| 400 | invalid_url |
The URL is not https://, its host cannot be found, or it points to a private address. |
| 400 | invalid_voice_sample |
The voice sample is too short or too long. |
| 400 | unsupported_file |
The file is not a supported image, audio or video format. |
| 400 | voice_consent_required |
A voice sample was sent without voice_consent: true. |
| 400 | wrong_asset_kind |
The asset is the wrong kind for this field (for example a voice used as a picture). |
| 400 | wrong_file_type |
An image was given where audio is needed, or the other way round. |
| 401 | invalid_api_key |
The key is wrong, revoked or belongs to no workspace. |
| 401 | missing_api_key |
No API key was sent. |
| 402 | insufficient_credits |
The workspace's available credits are less than the job's estimate. required and available give both numbers. |
| 403 | workspace_suspended |
The workspace that owns the key is suspended. |
| 404 | asset_not_found |
No approved library asset with this @handle or id. |
| 404 | file_not_found |
No live upload with this id in the workspace (expired or deleted). |
| 409 | asset_not_ready |
The asset has no approved version yet. |
| 409 | idempotency_in_progress |
A request with this Idempotency-Key is still being processed. Retry-After: 5 s. |
| 413 | too_large |
The request body is over the limit for this endpoint (JSON bodies 100 MB, uploads 64 MB). |
| 422 | idempotency_key_reused |
This Idempotency-Key was already used with a different request. |
| 422 | invalid_json |
The body is not valid JSON. |
| 429 | daily_limit_reached |
This key has used its jobs for the last 24 hours. Retry-After: 3600 s. |
| 429 | network_busy |
Every download slot is busy. Retry-After: 5 s. |
| 429 | queue_full |
The workspace has too many steps waiting. |
| 429 | too_many_active_jobs |
This key already has its maximum of unfinished jobs. Retry-After: 30 s. |
| 429 | too_many_attempts |
Too many requests with wrong keys came from your address. Retry-After is set. |
| 429 | too_many_downloads |
Two URL inputs are already being downloaded for this workspace. Retry-After: 10 s. |
| 500 | internal_error |
Something went wrong on our side. |
| 503 | engine_unavailable |
This kind of generation is not available right now. Retry-After: 300 s. |
| 503 | maintenance |
BobaBanana is being updated; changes are paused for a few minutes. Reads still work. Retry-After is set. |
| 507 | storage_quota_exceeded |
The workspace has used its storage. |
Related#
- Guide: Speech
- All endpoints
- Objects
- Error codes