Skip to content

feat(stt): add JSON input_audio request format#181

Open
8x22b wants to merge 1 commit into
grinev:mainfrom
8x22b:feat/stt-json-request-format
Open

feat(stt): add JSON input_audio request format#181
8x22b wants to merge 1 commit into
grinev:mainfrom
8x22b:feat/stt-json-request-format

Conversation

@8x22b

@8x22b 8x22b commented Jul 7, 2026

Copy link
Copy Markdown

What

Adds STT_REQUEST_FORMAT (multipart default | json). The json format sends base64-encoded audio in an input_audio: { data, format } JSON body instead of multipart/form-data, for STT providers whose /audio/transcriptions endpoint does not accept multipart uploads.

Why

Some providers (e.g. OpenRouter) expect audio inline as base64 JSON rather than a multipart file upload. Today this only works with a local source patch; this makes it a supported, documented option.

Changes

  • config.stt.requestFormat parsed from STT_REQUEST_FORMAT (validated; falls back to multipart).
  • transcribeAudio() selects the body shape based on the format. The fetch / timeout / error / response-parsing path is shared; only the request body and Content-Type differ between the two formats.
  • For json, the audio format is derived from the filename extension (oga/ogg/mp3/wav/m4a/flac/aac/webm, default ogg).
  • multipart behavior is unchanged.

Config

Var Default Notes
STT_REQUEST_FORMAT multipart json sends base64 audio in an input_audio JSON body

Tests

Two new cases in tests/app/services/stt-service.test.ts for the json path (body shape and Content-Type, format detection from filename, optional language). The default multipart tests are unchanged.

npm run lint, npm run build, npm test pass.

Add STT_REQUEST_FORMAT env var (multipart default | json). The json format sends base64 audio in an input_audio JSON body instead of multipart form-data, required by providers like OpenRouter. Ports a local STT protocol patch onto the current source.
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