-
Notifications
You must be signed in to change notification settings - Fork 258
feat(gen apis): add info for audio models #5556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
682639d
feat(genapi): update supported models
fpagny 8a545d9
feat(genapi): update model catalog with voxtral
fpagny d3f274a
feat(genapi): update rate limits with voxstral
fpagny 086bdb9
feat(genapi): update faq for audio models
fpagny 037820a
feat(genapis): add audio model info
RoRoJ a08cc94
fix(genapis): fix dates
RoRoJ d37d261
Apply suggestions from code review
RoRoJ 97c5b62
fix(genapis): fix conflcit
RoRoJ 36f6aaf
Update pages/generative-apis/how-to/query-audio-models.mdx
RoRoJ ab9d0c6
fix(gen): switch order
RoRoJ File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,167 @@ | ||
| --- | ||
| title: How to query audio models | ||
| description: Learn how to interact with powerful audio models using Scaleway's Generative APIs service. | ||
| tags: generative-apis ai-data audio-models voxtral | ||
| dates: | ||
| validation: 2025-09-22 | ||
| posted: 2025-09-22 | ||
| --- | ||
| import Requirements from '@macros/iam/requirements.mdx' | ||
|
|
||
| Scaleway's Generative APIs service allows users to interact with powerful audio models hosted on the platform. | ||
|
|
||
| There are several ways to interact with audio models: | ||
| - 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. | ||
| - Via the [Chat Completions API](https://www.scaleway.com/en/developers/api/generative-apis/#path-chat-completions-create-a-chat-completion) | ||
|
|
||
| <Requirements /> | ||
|
|
||
| - A Scaleway account logged into the [console](https://console.scaleway.com) | ||
| - [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization | ||
| - A valid [API key](/iam/how-to/create-api-keys/) for API authentication | ||
| - Python 3.7+ installed on your system | ||
|
|
||
| ## Accessing the Playground | ||
|
|
||
| Scaleway provides a web playground for instruct-based models hosted on Generative APIs. | ||
|
|
||
| 1. Navigate to **Generative APIs** under the **AI** section of the [Scaleway console](https://console.scaleway.com/) side menu. The list of models you can query displays. | ||
| 2. Click the name of the chat model you want to try. Alternatively, click <Icon name="more" /> next to the chat model, and click **Try model** in the menu. | ||
|
|
||
| The web playground displays. | ||
|
|
||
| ## Using the playground | ||
|
|
||
| 1. Enter a prompt at the bottom of the page, or use one of the suggested prompts in the conversation area. | ||
| 2. Edit the hyperparameters listed on the right column, for example the default temperature for more or less randomness on the outputs. | ||
| 3. Switch models at the top of the page, to observe the capabilities of chat models offered via Generative APIs. | ||
| 4. Click **View code** to get code snippets configured according to your settings in the playground. | ||
|
|
||
| <Message type="tip"> | ||
| You can also use the upload button to send supported audio file formats, such as MP3, to audio models for transcription purposes. | ||
| </Message> | ||
|
|
||
| ## Querying audio models via API | ||
|
|
||
| You can query the models programmatically using your favorite tools or languages. | ||
| In the example that follows, we will use the OpenAI Python client. | ||
|
|
||
| ### Installing the OpenAI SDK | ||
|
|
||
| Install the OpenAI SDK using pip: | ||
|
|
||
| ```bash | ||
| pip install openai | ||
| ``` | ||
|
|
||
| ### Initializing the client | ||
|
|
||
| Initialize the OpenAI client with your base URL and API key: | ||
|
|
||
| ```python | ||
| from openai import OpenAI | ||
|
|
||
| # Initialize the client with your base URL and API key | ||
| client = OpenAI( | ||
| base_url="https://api.scaleway.ai/v1", # Scaleway's Generative APIs service URL | ||
| api_key="<SCW_SECRET_KEY>" # Your unique API secret key from Scaleway | ||
| ) | ||
| ``` | ||
|
|
||
| ### Transcribing audio | ||
|
|
||
| You can now generate a text transcription of a given audio file using the Chat Completions API. This audio file can be local or remote. | ||
|
|
||
| #### Transcribing a local audio file | ||
|
|
||
| In the example below, a local audio file called `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. | ||
|
|
||
| ```python | ||
| import base64 | ||
|
|
||
| MODEL = "voxtral-small-24b-2507" | ||
|
|
||
| with open('scaleway-ai-revolution.mp3', 'rb') as raw_file: | ||
| audio_data = raw_file.read() | ||
| encoded_string = base64.b64encode(audio_data).decode("utf-8") | ||
|
|
||
| content = [ | ||
| { | ||
| "role": "user", | ||
| "content": [ | ||
| { | ||
| "type": "text", | ||
| "text": "Transcribe this audio" | ||
| }, | ||
| { | ||
| "type": "input_audio", | ||
| "input_audio": { | ||
| "data": encoded_string, | ||
| "format": "mp3" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
|
|
||
|
|
||
| response = client.chat.completions.create( | ||
| model=MODEL, | ||
| messages=content, | ||
| temperature=0.2, # Adjusts creativity | ||
| max_tokens=2048, # Limits the length of the output | ||
| top_p=0.95 # Controls diversity through nucleus sampling. You usually only need to use temperature. | ||
| ) | ||
|
|
||
| print(response.choices[0].message.content) | ||
| ``` | ||
|
|
||
| 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. | ||
|
|
||
| #### Transcribing a remote audio file | ||
|
|
||
| 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. | ||
|
|
||
| ```python | ||
| import base64 | ||
| import requests | ||
|
|
||
| MODEL = "voxtral-small-24b-2507" | ||
|
|
||
| url = "https://genapi-documentation-assets.s3.fr-par.scw.cloud/scaleway-ai-revolution.mp3" | ||
| response = requests.get(url) | ||
| audio_data = response.content | ||
| encoded_string = base64.b64encode(audio_data).decode("utf-8") | ||
|
|
||
| content = [ | ||
| { | ||
| "role": "user", | ||
| "content": [ | ||
| { | ||
| "type": "text", | ||
| "text": "Transcribe this audio" | ||
| }, | ||
| { | ||
| "type": "input_audio", | ||
| "input_audio": { | ||
| "data": encoded_string, | ||
| "format": "mp3" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
|
|
||
|
|
||
| response = client.chat.completions.create( | ||
| model=MODEL, | ||
| messages=content, | ||
| temperature=0.2, # Adjusts creativity | ||
| max_tokens=2048, # Limits the length of the output | ||
| top_p=0.95 # Controls diversity through nucleus sampling. You usually only need to use temperature. | ||
| ) | ||
|
|
||
| print(response.choices[0].message.content) | ||
| ``` | ||
|
|
||
| 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. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.