Skip to main content

Choose the endpoint

The Chat DTO and content parser represent type: input_audio, with plain Base64 in input_audio.data and the actual format in format. This is not a path, URL, or data:audio/...;base64, string. The example uses WAV; confirm other formats with the target model and channel instead of importing OpenRouter’s format catalog.

Support and response boundaries

Confirm audio input and Chat text output support first. Visibility in /v1/models does not establish either. Native OpenAI-compatible forwarding can carry this structure; conversions can apply different media rules and do not guarantee arbitrary formats. If an endpoint expects multipart, use the transcription API rather than upload fields inside Chat JSON. The request DTO also declares modalities / audio, but audio output has a different contract from this text-only example. Some native upstreams return message.audio or streaming delta.audio; forced formatting and conversion may lose extensions. The current message DTO also lacks the assistant audio.id replay field, so audio-ID continuation is not promised. Prefer the documented speech endpoint for generated files; a text SSE parser is insufficient for audio Chat streams. The script reads one regular WAV file up to 5 MiB and checks RIFF/WAVE markers. It does not fully decode audio or validate sample rate, duration, or upstream size limits. Renaming extensions does not transcode files. Base64 increases request size. Use recordings approved for transmission; answers may also contain sensitive recording content. One request, no automatic retries. The script requires one normally completed text answer without refusals or tool calls and does not print Base64 or private reasoning. Local checks verify encoding and protocol, not transcription, speaker separation, or recognition quality. Source: relaykit/dto/openai_request.go and relay/channel/openai/adaptor.go. See Chat API and OpenAI content-block reference.

Runnable example

Run from the documentation directory. See the REST runtime; keep http-client.mjs beside the script when copying.
阅读中文