Skip to content

Commit 5ad8732

Browse files
committed
feat(genapis): add how to query audio models
1 parent 572e5df commit 5ad8732

File tree

1 file changed

+131
-86
lines changed

1 file changed

+131
-86
lines changed

pages/generative-apis/how-to/query-audio-models.mdx

Lines changed: 131 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: How to query audio models
33
description: Learn how to interact with powerful audio models using Scaleway's Generative APIs service.
44
tags: generative-apis ai-data audio-models voxtral
55
dates:
6-
validation: 2025-09-22
6+
validation: 2025-10-17
77
posted: 2025-09-22
88
---
99
import Requirements from '@macros/iam/requirements.mdx'
@@ -12,7 +12,7 @@ Scaleway's Generative APIs service allows users to interact with powerful audio
1212

1313
There are several ways to interact with audio models:
1414
- The Scaleway [console](https://console.scaleway.com) provides a complete [playground](/generative-apis/how-to/query-language-models/#accessing-the-playground), aiming to test models, adapt parameters, and observe how these changes affect the output in real-time.
15-
- Via the [Chat Completions API](https://www.scaleway.com/en/developers/api/generative-apis/#path-chat-completions-create-a-chat-completion)
15+
- Via the [Chat Completions API](https://www.scaleway.com/en/developers/api/generative-apis/#path-chat-completions-create-a-chat-completion) or the [Audio Transcriptions API](https://www.scaleway.com/en/developers/api/generative-apis/#path-TODO)
1616

1717
<Requirements />
1818

@@ -46,6 +46,20 @@ You can also use the upload button to send supported audio file formats, such as
4646
You can query the models programmatically using your favorite tools or languages.
4747
In the example that follows, we will use the OpenAI Python client.
4848

49+
### Chat Completions API or Audio Transcriptions API?
50+
51+
Both the [Chat Completions API](TODO) and the [Audio Transcriptions API](TODO) are OpenAI-compatible REST APIs that accept audio input.
52+
53+
The **Chat Completions API** is more suitable when transcribing audio input is part of a broader task, rather than pure transcription. Examples could include building a voice chat assistant which listens and responds in natural language, or sending multiple inputs (audio and text) to be interpreted and commented on. This API can be used with compatible multimodal models, such as `voxtral-small-24b`.
54+
55+
The **Audio Transcriptions API** is designed for pure speech-to-text (audio transcription) tasks, such as transcribing a voice note or meeting recording file. It can be used with compatible audio models, such as `whisper-large-v3`.
56+
57+
<Message type="note">
58+
Scaleway's support for the Audio Transcriptions API is currently at beta stage. TODO CHECK: incremental support of feature set?
59+
</Message>
60+
61+
For full details on the differences between these APIs, see the [official OpenAI documentation](https://platform.openai.com/docs/guides/audio#choosing-the-right-api).
62+
4963
### Installing the OpenAI SDK
5064

5165
Install the OpenAI SDK using pip:
@@ -70,98 +84,129 @@ client = OpenAI(
7084

7185
### Transcribing audio
7286

73-
You can now generate a text transcription of a given audio file using the Chat Completions API. This audio file can be remote or local.
87+
You can now generate a text transcription of a given audio file using a suitable API / model combination of your choice.
7488

75-
#### Transcribing a remote audio file
89+
<Tabs id="transcribing-audio">
7690

77-
In the example below, an audio file from a remote URL (`https://genapi-documentation-assets.s3.fr-par.scw.cloud/scaleway-ai-revolution.mp3`) is downloaded using the `requests` library, base64-encoded, and then sent to the model in a chat completion request alongside a transcription prompt. The resulting text transcription is printed to the screen.
91+
<TabsTab label="Audio Transcriptions API">
7892

79-
```python
80-
import base64
81-
import requests
82-
83-
MODEL = "voxtral-small-24b-2507"
84-
85-
url = "https://genapi-documentation-assets.s3.fr-par.scw.cloud/scaleway-ai-revolution.mp3"
86-
response = requests.get(url)
87-
audio_data = response.content
88-
encoded_string = base64.b64encode(audio_data).decode("utf-8")
89-
90-
content = [
91-
{
92-
"role": "user",
93-
"content": [
94-
{
95-
"type": "text",
96-
"text": "Transcribe this audio"
97-
},
98-
{
99-
"type": "input_audio",
100-
"input_audio": {
101-
"data": encoded_string,
102-
"format": "mp3"
103-
}
104-
}
105-
]
106-
}
107-
]
108-
109-
110-
response = client.chat.completions.create(
111-
model=MODEL,
112-
messages=content,
113-
temperature=0.2, # Adjusts creativity
114-
max_tokens=2048, # Limits the length of the output
115-
top_p=0.95 # Controls diversity through nucleus sampling. You usually only need to use temperature.
116-
)
93+
from openai import OpenAI
94+
import os
11795

118-
print(response.choices[0].message.content)
119-
```
96+
client = OpenAI(
97+
base_url="https://aa2cee79-0e20-4515-8ec0-0a8084dfbd9e.ifr.fr-par.scaleway.com/v1",
98+
api_key=os.getenv("SCW_SECRET_KEY") # Your unique API secret key from Scaleway
99+
)
120100

121-
Various parameters such as `temperature` and `max_tokens` control the output. See the [dedicated API documentation](https://www.scaleway.com/en/developers/api/generative-apis/#path-chat-completions-create-a-chat-completion) for a full list of all available parameters.
101+
MODEL = "openai/whisper-large-v3:fp16"
102+
AUDIO = 'interview-jbk-62s.mp3'
122103

123-
#### Transcribing a local audio file
104+
audio_file = open(AUDIO, "rb")
124105

125-
In the example below, a local audio file [scaleway-ai-revolution.mp3](https://genapi-documentation-assets.s3.fr-par.scw.cloud/scaleway-ai-revolution.mp3) is base-64 encoded and sent to the model, alongside a transcription prompt. The resulting text transcription is printed to the screen.
106+
response = client.audio.transcriptions.create(
107+
model=MODEL,
108+
file=audio_file,
109+
language='fr'
110+
)
126111

127-
```python
128-
import base64
129-
130-
MODEL = "voxtral-small-24b-2507"
131-
132-
with open('scaleway-ai-revolution.mp3', 'rb') as raw_file:
133-
audio_data = raw_file.read()
134-
encoded_string = base64.b64encode(audio_data).decode("utf-8")
135-
136-
content = [
137-
{
138-
"role": "user",
139-
"content": [
140-
{
141-
"type": "text",
142-
"text": "Transcribe this audio"
143-
},
144-
{
145-
"type": "input_audio",
146-
"input_audio": {
147-
"data": encoded_string,
148-
"format": "mp3"
112+
print(response.text)
113+
114+
</TabsTab>
115+
116+
<TabsTab label="Chat Completions API">
117+
118+
#### Transcribing a remote audio file
119+
120+
In the example below, an audio file from a remote URL (`https://genapi-documentation-assets.s3.fr-par.scw.cloud/scaleway-ai-revolution.mp3`) is downloaded using the `requests` library, base64-encoded, and then sent to the model in a chat completion request alongside a transcription prompt. The resulting text transcription is printed to the screen.
121+
122+
```python
123+
import base64
124+
import requests
125+
126+
MODEL = "voxtral-small-24b-2507"
127+
128+
url = "https://genapi-documentation-assets.s3.fr-par.scw.cloud/scaleway-ai-revolution.mp3"
129+
response = requests.get(url)
130+
audio_data = response.content
131+
encoded_string = base64.b64encode(audio_data).decode("utf-8")
132+
133+
content = [
134+
{
135+
"role": "user",
136+
"content": [
137+
{
138+
"type": "text",
139+
"text": "Transcribe this audio"
140+
},
141+
{
142+
"type": "input_audio",
143+
"input_audio": {
144+
"data": encoded_string,
145+
"format": "mp3"
146+
}
149147
}
150-
}
151-
]
152-
}
153-
]
154-
155-
156-
response = client.chat.completions.create(
157-
model=MODEL,
158-
messages=content,
159-
temperature=0.2, # Adjusts creativity
160-
max_tokens=2048, # Limits the length of the output
161-
top_p=0.95 # Controls diversity through nucleus sampling. You usually only need to use temperature.
162-
)
148+
]
149+
}
150+
]
151+
152+
153+
response = client.chat.completions.create(
154+
model=MODEL,
155+
messages=content,
156+
temperature=0.2, # Adjusts creativity
157+
max_tokens=2048, # Limits the length of the output
158+
top_p=0.95 # Controls diversity through nucleus sampling. You usually only need to use temperature.
159+
)
160+
161+
print(response.choices[0].message.content)
162+
```
163+
164+
Various parameters such as `temperature` and `max_tokens` control the output. See the [dedicated API documentation](https://www.scaleway.com/en/developers/api/generative-apis/#path-chat-completions-create-a-chat-completion) for a full list of all available parameters.
165+
166+
#### Transcribing a local audio file
167+
168+
In the example below, a local audio file [scaleway-ai-revolution.mp3](https://genapi-documentation-assets.s3.fr-par.scw.cloud/scaleway-ai-revolution.mp3) is base-64 encoded and sent to the model, alongside a transcription prompt. The resulting text transcription is printed to the screen.
169+
170+
```python
171+
import base64
172+
173+
MODEL = "voxtral-small-24b-2507"
174+
175+
with open('scaleway-ai-revolution.mp3', 'rb') as raw_file:
176+
audio_data = raw_file.read()
177+
encoded_string = base64.b64encode(audio_data).decode("utf-8")
178+
179+
content = [
180+
{
181+
"role": "user",
182+
"content": [
183+
{
184+
"type": "text",
185+
"text": "Transcribe this audio"
186+
},
187+
{
188+
"type": "input_audio",
189+
"input_audio": {
190+
"data": encoded_string,
191+
"format": "mp3"
192+
}
193+
}
194+
]
195+
}
196+
]
163197

164-
print(response.choices[0].message.content)
165-
```
166198

167-
Various parameters such as `temperature` and `max_tokens` control the output. See the [dedicated API documentation](https://www.scaleway.com/en/developers/api/generative-apis/#path-chat-completions-create-a-chat-completion) for a full list of all available parameters.
199+
response = client.chat.completions.create(
200+
model=MODEL,
201+
messages=content,
202+
temperature=0.2, # Adjusts creativity
203+
max_tokens=2048, # Limits the length of the output
204+
top_p=0.95 # Controls diversity through nucleus sampling. You usually only need to use temperature.
205+
)
206+
207+
print(response.choices[0].message.content)
208+
```
209+
210+
Various parameters such as `temperature` and `max_tokens` control the output. See the [dedicated API documentation](https://www.scaleway.com/en/developers/api/generative-apis/#path-chat-completions-create-a-chat-completion) for a full list of all available parameters.
211+
</TabsTab>
212+
</Tabs>

0 commit comments

Comments
 (0)