OpenrouterSdk.Api.Speech (OpenRouter SDK v0.1.0)

Copy Markdown View Source

POST /audio/speech — text-to-speech.

{:ok, mp3_binary} = OpenrouterSdk.Api.Speech.create(%{
  model: "openai/tts-1",
  input: "hello there",
  voice: "alloy",
  response_format: "mp3"
})

File.write!("hello.mp3", mp3_binary)

the response is the raw audio bytes — we do NOT decode json on this endpoint.

Summary

Functions

stream the audio response as a Stream of byte chunks. consumers who want pid / fun delivery pass :into exactly like the chat streaming api.

Functions

create(payload, opts \\ [])

@spec create(
  map(),
  keyword()
) :: {:ok, binary()} | {:error, OpenrouterSdk.Error.t()}

create_stream(payload, opts \\ [])

@spec create_stream(
  map(),
  keyword()
) ::
  {:ok, Enumerable.t() | reference() | term()}
  | {:error, OpenrouterSdk.Error.t()}

stream the audio response as a Stream of byte chunks. consumers who want pid / fun delivery pass :into exactly like the chat streaming api.