# Audio Inputs

Audio Processing enables applications to **understand, generate, and reason over audio content** using multimodal AI models. The audio processing works through the **Completion endpoint** and supports models that handle **multiple modalities**, including audio.

To get a full list of supported models, visit [**cortecs.ai**](https://cortecs.ai/serverlessModels) and filter by the **Audio** tag.

> **Note:** Audio format support depends on the provider. Check the model documentation for details.

{% tabs %}
{% tab title="Python" %}

```python
from openai import OpenAI
import base64

client = OpenAI(
  base_url="https://api.cortecs.ai/v1",
  api_key="<API_KEY>",
)

# Load and encode audio file
with open("path/to/audio_test.mp3", "rb") as f:
    audio_base64 = base64.b64encode(f.read()).decode('utf-8')

chat_response = client.chat.completions.create(
    model="gemini-2.5-pro",
    messages=[{
        "role": "user",
        "content": [
            {
                "type": "text",
                "text": "What is this file about?"
            },
            {
                "type": "input_audio",
                "input_audio": {
                    "data": audio_base64,
                    "format": "mp3"
                }
            },
        ]
    }]
)

print(chat_response)
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
import OpenAI from "openai";
import fs from "fs";

const client = new OpenAI({
  baseURL: "https://api.cortecs.ai/v1",
  apiKey: process.env.CORTECS_API_KEY,
});

// Load and encode audio file
const audioBuffer = fs.readFileSync("path/to/audio_test.mp3");
const audioBase64 = audioBuffer.toString("base64");

const chatResponse = await client.chat.completions.create({
  model: "gemini-2.5-pro",
  messages: [
    {
      role: "user",
      content: [
        {
          type: "text",
          text: "What is this file about?"
        },
        {
          type: "input_audio",
          input_audio: {
            data: audioBase64,
            format: "mp3"
          }
        }
      ]
    }
  ]
});

console.log(chatResponse);
```

{% endtab %}

{% tab title="Curl" %}

```bash
curl https://api.cortecs.ai/v1/chat/completions \
  -H "Authorization: Bearer <API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-2.5-pro",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "What is this file about?"
          },
          {
            "type": "input_audio",
            "input_audio": {
              "data": "<BASE64_AUDIO_DATA>",
              "format": "mp3"
            }
          }
        ]
      }
    ]
  }'
```

{% endtab %}
{% endtabs %}

> **Note:** For a dedicated speech-to-text endpoint, see the [**Audio Transcription**](https://docs.cortecs.ai/features/images) page.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cortecs.ai/usage/audio-inputs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
