Skip to content

fix(speech-to-text): send keyterms as repeated multipart form fields - #824

Closed
fern-api[bot] wants to merge 1 commit into
mainfrom
fern/keyterms-multipart-repeated-fields
Closed

fern-api[bot] wants to merge 1 commit into
mainfrom
fern/keyterms-multipart-repeated-fields

Conversation

@fern-api

@fern-api fern-api Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Stopgap fix so speech_to_text.convert(keyterms=[...]) works without upgrading the Python SDK generator (this repo is on generator 4.64.1).

keyterms (an Optional[List[str]] multipart body property) was serialized as a single JSON-encoded form field:

"keyterms": json.dumps(jsonable_encoder(keyterms)),   # -> keyterms=["hello","world"]  (one field)

The API validates each keyterm individually, so the whole JSON-array string is treated as one keyword and rejected (400 invalid_keyword / invalid_keyword_length; [ ] " are also unsupported characters). This is the elevenlabs-python#819 regression.

Change

Pass the list straight through jsonable_encoder so httpx emits repeated form fields (keyterms=hello, keyterms=world), matching pre-2.59.0 behavior and what the API expects:

"keyterms": jsonable_encoder(keyterms) if keyterms is not OMIT else OMIT,

This is byte-for-byte what Fern's Python generator >=5.22.2 now emits (upstream fix: fern-api/fern#17226), so the manual edit and the eventual generator upgrade converge.

Files changed (2)

  • src/elevenlabs/speech_to_text/raw_client.py — sync + async convert (2 lines).
  • .fernignore — add raw_client.py so SDK regeneration won't overwrite this patch while staying on generator 4.64.1.

Notes

  • Scope is limited to keyterms; other fields (entity_detection, additional_formats, etc.) are unchanged.
  • Once this repo bumps its Python generator to >=5.22.2, this patch becomes redundant and the .fernignore entry can be removed.

Note

Low Risk
Narrow request-encoding fix for an optional STT parameter; no auth, billing, or broader API surface changes.

Overview
Fixes speech_to_text.convert(keyterms=[...]) failing with API 400s (invalid_keyword / invalid_keyword_length) because keyterms was sent as one JSON-encoded multipart field instead of repeated keyterms= fields per term.

In src/elevenlabs/speech_to_text/raw_client.py, sync and async convert now pass jsonable_encoder(keyterms) (or omit when unset) instead of json.dumps(jsonable_encoder(keyterms)), so httpx emits the repeated form fields the API validates individually. Other multipart fields are unchanged.

.fernignore now includes raw_client.py so Fern regeneration on generator 4.64.1 does not revert this stopgap until the SDK bumps to generator ≥5.22.2.

Reviewed by Cursor Bugbot for commit 4220b3c. Bugbot is set up for automated code reviews on this repo. Configure here.

@kraenhansen

kraenhansen commented Jul 30, 2026 •

Copy link
Copy Markdown
Member

Superseded by #825 (since the regression is not contained to the speech_to_text endpoint)

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