> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.meshapi.ai/llms.txt.
> For full documentation content, see https://developers.meshapi.ai/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.meshapi.ai/_mcp/server.

# Audio

> Send audio into chat completions and request audio output from supported models.

Mesh API supports audio through `POST /v1/chat/completions`.

Use this page for:

* audio input with `input_audio`
* audio output with `modalities` and `audio`

## Audio input

Send audio as a content part inside a chat message.

```bash
curl https://api.meshapi.ai/v1/chat/completions \
  -H "Authorization: Bearer <YOUR_RSK_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/gemini-3-flash-preview",
    "messages": [
      {
        "role": "user",
        "content": [
          { "type": "text", "text": "Transcribe this clip." },
          {
            "type": "input_audio",
            "input_audio": {
              "data": "<BASE64_AUDIO>",
              "format": "wav"
            }
          }
        ]
      }
    ]
  }'
```

```ts
const response = await client.chat.completions.create({
  model: "google/gemini-3-flash-preview",
  messages: [
    {
      role: "user",
      content: [
        { type: "text", text: "Transcribe this clip." },
        {
          type: "input_audio",
          input_audio: {
            data: "<BASE64_AUDIO>",
            format: "wav",
          },
        },
      ],
    },
  ],
});
```

```python
from meshapi import ChatCompletionParams, ChatMessage, ContentPartAudio, ContentPartText, InputAudio, MeshAPI

client = MeshAPI(base_url="https://api.meshapi.ai", token="rsk_...")

response = client.chat.completions.create(
    ChatCompletionParams(
        model="google/gemini-3-flash-preview",
        messages=[
            ChatMessage(
                role="user",
                content=[
                    ContentPartText(type="text", text="Transcribe this clip."),
                    ContentPartAudio(
                        type="input_audio",
                        input_audio=InputAudio(data="<BASE64_AUDIO>", format="wav"),
                    ),
                ],
            )
        ],
    )
)
```

```go
params := meshapi.ChatCompletionParams{
    Model: meshapi.String("google/gemini-3-flash-preview"),
    Messages: []meshapi.ChatMessage{
        {
            Role: "user",
            Content: []meshapi.ContentPart{
                {Type: "text", Text: meshapi.String("Transcribe this clip.")},
                {
                    Type: "input_audio",
                    InputAudio: &meshapi.InputAudio{
                        Data:   "<BASE64_AUDIO>",
                        Format: "wav",
                    },
                },
            },
        },
    },
}

_, err := client.Chat.Completions.Create(ctx, params)
```

```java
MeshAPI client = MeshAPI.builder()
    .baseUrl("https://api.meshapi.ai")
    .token("rsk_...")
    .build();

ChatCompletionRequest request = ChatCompletionRequest.builder()
    .model("google/gemini-3-flash-preview")
    .addMessage(
        ChatMessage.builder()
            .role("user")
            .content(java.util.List.of(
                java.util.Map.of("type", "text", "text", "Transcribe this clip."),
                java.util.Map.of(
                    "type", "input_audio",
                    "input_audio", java.util.Map.of("data", "<BASE64_AUDIO>", "format", "wav")
                )
            ))
            .build()
    )
    .build();

client.chat().completions().create(request);
```

## Audio output

Request text and audio together when the model supports audio output.

```bash
curl https://api.meshapi.ai/v1/chat/completions \
  -H "Authorization: Bearer <YOUR_RSK_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o-audio-preview",
    "messages": [
      { "role": "user", "content": "Read this back to me in a calm voice." }
    ],
    "modalities": ["text", "audio"],
    "audio": {
      "voice": "alloy",
      "format": "wav"
    }
  }'
```

The same request shape is available through all four SDKs by setting chat-completions fields for `modalities` and `audio`.

## SDK coverage

* Node: `client.chat.completions.create(...)`
* Python: `client.chat.completions.create(...)`
* Go: `client.Chat.Completions.Create(...)`
* Java: `client.chat().completions().create(...)`

## Notes

* Audio payloads are base64 encoded in the request body.
* Check `GET /v1/models` to find models that accept or produce audio.
* Keep payload sizes reasonable, especially for browser-based clients.