Skip to documentation
TIMBRELAY FOR DEVELOPERS PREVIEW

API documentation

Turn short text into a complete, watermarked WAV. One Project Key connects your application to the available speech models.

Project API Key Watermark before delivery Complete WAV response
Project API

Complete, watermarked WAV responses from the enabled model catalog.Permanent audio asset storage is outside this release. Program generation uses credits; the signed-in Playground is free.

On this page

Your first watermarked clip

Create a Project in the Console, create a Project API Key, and prepare wallet credits and a sufficient Key budget. Keep the Key in your server environment.

  1. Set up accessCreate a Project Key and configure TIMBRELAY_API_KEY on your server.
  2. Choose a model & voiceRead the live catalogs, then set TIMBRELAY_MODEL and TIMBRELAY_VOICE to compatible IDs.
  3. Send a stable operation IDSave the request and its idempotency ID before sending. The same business action must reuse both on recovery.

For the Node.js example, download and install the SDK first. cURL and Python use the HTTP API directly.

import { writeFile } from "node:fs/promises";
import { Timbrelay } from "@timbrelay/sdk";

const client = new Timbrelay({
  apiKey: process.env.TIMBRELAY_API_KEY!,
  baseURL: "https://api.timbrelay.com",
});

const [models, voices] = await Promise.all([
  client.models.list(),
  client.speakers.list(),
]);
// Choose IDs from the live catalog, not an assumed default.
const model = models.data.find(
  (m) => m.available && m.id === process.env.TIMBRELAY_MODEL,
);
const voice = voices.data.find(
  (v) => v.id === process.env.TIMBRELAY_VOICE && v.models.includes(model?.id ?? ""),
);
if (!model || !voice) throw new Error("Choose a compatible model and voice.");

// Persist this action ID and exact input before sending.
const result = await client.audio.speech.create(
  { model: model.id, voice: voice.id, input: "Welcome to our application. Your announcement is ready." },
  { idempotencyKey: "announcement-123-action-456" },
);
await writeFile("speech.wav", result.audio);
// result.watermarkApplied is true for every resolved call.

Examples do not run in this page. A generation you send from your application may spend credits. Very short audio may not meet the configured watermark minimum.

Authentication & API origin

Program requests use a Project API Key as a bearer token. Your Key selects the Project; do not supply a Project ID in the speech request.

Authorization header
Authorization: Bearer <YOUR_PROJECT_API_KEY>
API environments
EnvironmentAPI originAccess
Productionhttps://api.timbrelay.comInvited accounts
Staginghttps://api.staging.timbrelay.comInvited testers
Localhttp://localhost:8000Your configured development API

Examples on this build use https://api.timbrelay.com. Append the endpoint path for HTTP calls; pass only the origin to the SDK.

Keep credentials on your server

Never place a Project Key in frontend bundles, URLs, browser storage or logs. Console Cognito tokens, TTS Gate keys and OfSpectrum credentials cannot replace a Project Key.

Node.js & TypeScript SDK

The preview package includes prebuilt ESM JavaScript, TypeScript declarations, examples and integration documentation. It requires Node.js 20+ and has zero runtime dependencies.

@timbrelay/sdk0.1.0-preview.1 · Preview · .tgz
Download package

Save the download in your application directory, then install it from the file. The package has not been published to npm.

Install the downloaded package
npm install ./timbrelay-sdk-0.1.0-preview.1.tgz

Verify the download with shasum -a 256 -c SHA256SUMS in the same directory as timbrelay-sdk-0.1.0-preview.1.tgz.

SDK methods
MethodPurpose
client.models.list()Read available models and current program prices.
client.speakers.list()Read preset voices and model compatibility.
client.audio.speech.create(input, options)Generate and return confirmed watermarked WAV.
client.watermark.decode(wavBytes)Explicitly detect a service-level watermark.

Every method sends one HTTP request. The SDK has no automatic retries, new operation IDs or fallback providers. Encoding is handled by Timbrelay; customers do not install the OfSpectrum SDK. CommonJS applications can use await import("@timbrelay/sdk") inside an async function.

Find models & compatible voices

GET/v1/models

Returns { "object": "list", "data": [...] }. Select a model with available: true. Model fields include id, name, sample_rate_hz, languages, capabilities, response_formats, price_per_generation_micros and price_version.

GET/v1/speakers

Returns the same list envelope. Each voice provides id, name, language and compatible model IDs in models. Both endpoints require a Project Key and do not generate audio.

Query the catalogs
curl --fail-with-body "https://api.timbrelay.com/v1/models" \
  -H "Authorization: Bearer $TIMBRELAY_API_KEY"

curl --fail-with-body "https://api.timbrelay.com/v1/speakers" \
  -H "Authorization: Bearer $TIMBRELAY_API_KEY"

Catalog metadata can change. Do not assume that an example model, voice, price or internal upstream format will always be available.

Generate speech

POST/v1/audio/speech

Send JSON with Content-Type: application/json and a required Idempotency-Key header. The server completes synthesis, watermark encoding and persistence before returning the deliverable audio.

Speech request body
FieldTypeRequirementDescription
modelstringRequiredAn enabled model ID from GET /v1/models. Check available=true.
voicestringRequiredA preset ID from GET /v1/speakers whose models include your model ID.
inputstringRequiredNonblank short text, at most 1,000 Unicode code points. No unsupported control characters.
speednumberDefault: 1A finite number from 0.25 to 4.
response_formatstringDefault: wavOnly wav is supported. The response is a complete audio file.

Unknown fields are rejected, including project_id or free. The idempotency header accepts 1–128 ASCII letters, digits, underscores or hyphens. Output is a complete WAV; streaming is not supported.

Watermark completion is required

Watermark failure does not deliver original audio or settle the failed generation. The SDK also rejects missing or unapplied watermark status. It never pads silence or falls back to raw audio.

Read the audio response & charge

A successful HTTP response is 200 with complete audio/wav bytes. It is not JSON, a stream, or an asset URL. Check status, watermark confirmation and WAV integrity before exposing direct HTTP results to users.

Successful speech response headers
HeaderMeaning
Content-Typeaudio/wav on a successful complete audio response.
X-Timbrelay-WatermarkOnly applied confirms persisted watermark completion. Reject a missing or not-applied value.
X-Timbrelay-Generation-IdGeneration UUID. This is not a permanent asset ID.
X-Timbrelay-Charged-MicrosOriginal generation charge in USD micros (1 USD = 1,000,000 micros), including on replay.
X-Timbrelay-Idempotent-Replaytrue when returning the saved result of the same request; no second settlement.
Cache-Controlno-store. Save the delivered WAV in your own application if you need to retain it.

The SDK exposes audio as a Uint8Array, plus generationId, watermarkApplied, chargedMicros, replayed, idempotencyKey, sampleRateHz and durationSeconds.

Model prices come from the current catalog. Check the selected model price and project spending limit before generating. On replay, the charge header reports the original settlement amount; it does not mean another charge. Successful replay audio expires after 24 hours, so save the WAV in your own application.

Detect a watermark

POST/v1/audio/watermark/decode

Timbrelay uses OfSpectrum Neo for watermark detection. Authenticate with your Project Key; no separate OfSpectrum Key is needed.

Upload raw WAV bytes with a Project Key and Content-Type: audio/wav. Use standard PCM16 WAV, mono or stereo, 8–48 kHz, up to 180 seconds and 6,356,992 bytes. This is a separate, explicit call.

Upload a WAV for detection
curl --fail-with-body "https://api.timbrelay.com/v1/audio/watermark/decode" \
  -H "Authorization: Bearer $TIMBRELAY_API_KEY" \
  -H "Content-Type: audio/wav" \
  --data-binary @speech.wav
Example detection response
{
  "watermarked": true,
  "matches_service_token": true,
  "attribution_scope": "service"
}
Detect with the Node.js SDK
import { readFile } from "node:fs/promises";

const result = await client.watermark.decode(await readFile("speech.wav"));
// { watermarked, matchesServiceToken, attributionScope: "service" }
// Explicit detection; generation never calls decode automatically.

A match identifies only the current service token, not a Project, user, generation or ownership. A negative result does not prove the absence of all watermarks. Detection failures are errors, never fabricated negative results. Uploaded audio is not persisted by Timbrelay.

Independent detection calls

Generation does not run decode automatically. Detection does not create a speech generation or debit the Timbrelay wallet. Speech idempotency IDs and audio replay do not apply to this endpoint: each call is independent, and the SDK does not retry it automatically.

Detection errors
HTTP status & codeMeaningNext step
502 · decode_invalid_result / decode_failedDetection failed or the service returned an invalid result.Treat the outcome as unknown, never as a negative detection.
503 · decode_busy / decode_unavailableDetection capacity or the detection service is unavailable.Wait before a deliberate retry. Persistent failures need service support.
504 · decode_timeoutDetection timed out without a confirmed result.Do not infer a negative result. Any repeat is a new detection request.

Idempotency & safe recovery

One business action gets one stable ID. Persist it with the exact request before sending, then reuse the same Project Key, ID and input on uncertain-result retries—even after your application restarts.

01

Save the operation

Store the ID and original parameters in your business records.

02

Repeat the same request

After uncertainty, recover with the original input and Key.

03

Reuse the saved result

A completed replay returns the stored WAV without another settlement.

The hosted edge waits up to 120 seconds without response bytes; the backend task lease is 300 seconds. The SDK defaults to a 130-second request timeout. A timeout, connection loss or client cancellation can leave the backend running or already settled.

Do not automatically create a new ID after a timeout. An in-progress operation returns 409 generation_in_progress; wait before recovering. A terminal failed request remains failed under its ID without charge; a deliberate new attempt needs a new ID. Changing the Project Key changes the idempotency scope.

A response rejected by the SDK may already have been settled by the server. Investigate repeated invalid responses and recover under the original ID; SDK rejection alone does not establish billing failure.

Errors & current limits

Example API error
{
  "detail": {
    "code": "generation_in_progress",
    "message": "This request is still running; retry the same request ID later"
  }
}
// Other failures may use a string detail or a validation-error array.
// A gateway can return HTML. Check HTTP status before parsing audio.
Common HTTP errors and recovery
Status / codeMeaningNext step
401 / 403Invalid Key or unavailable Project permissions/billing.Check the Project Key, expiration, revocation and Project status.
402Insufficient credits or Project Key budget.Resolve the wallet or Key limit before retrying.
409 · generation_in_progressThe original operation is still running.Wait, then repeat identical input with the same Key and idempotency ID.
409 · idempotency_conflictThe ID was already used with different input.Restore the original input, or deliberately start a new business action.
410 · result_expiredThe successful replay WAV expired after 24 hours.Use your saved audio. The old ID is not charged again.
413 / 415 / 422Upload, format or input validation failed.Check size, PCM16 WAV, text length, voice/model and speed. Very short clips may be insufficient for the watermark token.
429Capacity or active generation limit reached.Use bounded backoff. Preserve the original ID when recovering an existing action.
502 / 503 / 504Service failure, unavailability or timeout.For speech, recover with the original ID before deciding on a new attempt. For detection, follow the decode error guidance above.

SDK failures extend TimbrelayError. APIError includes HTTP status and a safe error code; TimeoutError, ConnectionError and RequestAbortedError describe uncertain outcomes. WatermarkError and InvalidResponseError expose no audio.

First-release scope

Short text and complete WAV responses only. Streaming, MP3, SSML, long/batch tasks, voice cloning, third-party BYOK and permanent S3 audio assets are not available. Python is supported through HTTP examples; a Python SDK has not been released.

Ready to test your integration?

Inspect authentication and catalog responses before sending a generation.

Open API test