Skip to content

0.1.1: align with the current API (token retries, 402 code, realtime limits, types) - #1

Merged
iyashjayesh merged 5 commits into
mainfrom
fix/api-protocol-0.1.1
Oct 15, 2026
Merged

iyashjayesh merged 5 commits into
mainfrom
fix/api-protocol-0.1.1

Conversation

@iyashjayesh

Copy link
Copy Markdown
Collaborator

What

Version 0.1.1 aligns the SDK with the current public API (flam-voice-svc production, ff9a6ef), following a protocol audit.

  • Token auth and retries: short-lived fin_tok_ tokens are spent before the handler runs. A client using a token now retries only 429s and connections that never opened. A 5xx raises the real error instead of a misleading 401 token_invalid from the retry.
  • 402 code: an out-of-credits error during synthesis reports code == "insufficient_credits" instead of payment_required. The documented list of error codes now covers everything the API returns.
  • Realtime 1 MiB frame cap: text that would make a frame larger than 1 MiB is split across task_continue frames. Before, an oversized frame closed the whole socket with 1009.
  • Types: removed metadata, deleted_at and the job's result, which the public API no longer returns. Added created_via_key_prefix.
  • Docs:
    • num_step is 1–32 and sample_rate is 8000–48000.
    • Clips must be at least 10 s, and ref_text is at most 4,000 characters.
    • Media URLs may be short-lived.
  • Deprecated ?api_key= on the WebSocket: a one-time warning is logged, unless logLevel is "off". Deno 2.5 and later now sends the X-API-Key header instead of the URL parameter.

Checks

  • pnpm test: 156 passed (live tests skipped).
  • typecheck, lint and build pass.

The service spends a short-lived token just before the handler runs, so a
5xx or a dropped connection after that point left it used and the retry
came back as 401 token_invalid, hiding the real error. Token clients now
retry only 429 and connections that never opened.
The 402 from inside synthesis carries the generic payment_required code
next to the insufficient_credits message; prefer the specific one. List
every error code the API returns.
Text that would make a task_start or task_continue frame larger than
1 MiB is sent across several task_continue frames, never splitting a
character, instead of the service closing the socket with 1009. Deno 2.5+
sends the API key as a header; where it still goes in the deprecated URL
parameter, a warning is logged once.
Voice drops metadata and deleted_at and gains created_via_key_prefix;
CloneJob drops result. Document num_step 1-32, sample_rate 8000-48000,
clone clips of at least 10 s, ref_text up to 4000 characters, and
short-lived media URLs.
The deprecation warning for a key in the WebSocket URL now follows logLevel like every other log line, so a client with logging off stays silent.
@iyashjayesh
iyashjayesh merged commit c290783 into main Oct 15, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant