Soniox
Docs

Get started

Learn how to use and integrate Omnio API.

Learn how to use Omnio API

Omnio API provides an interface to advanced AI models designed for audio and text reasoning. This guide will walk you through the process of generating a response from a specified audio file and text prompt with instructions.

Get API key

Create a free Soniox Account and login into Soniox Console to create an API key.

API keys are tied to individual projects. To create one, click API Keys under the My First Project section in the Console.

Configure environment

Store your API key in the SONIOX_API_KEY environment variable so your code can authenticate automatically.

Terminal
export SONIOX_API_KEY=<YOUR_API_KEY>

First API Request

You can interact with Omnio API directly using any HTTP client or leverage a client that supports OpenAI’s Chat Completion API.

Install the OpenAI SDK for Python using pip:

Terminal
pip install openai

Now, create a file called example.py with the following code:

example.py
import base64
import os
from openai import OpenAI
 
client = OpenAI(
    api_key=os.environ["SONIOX_API_KEY"],
    base_url="https://api.llm.soniox.com/v1",
)
 
with open("podcast.mp3", "rb") as audio_file:
    audio_data_b64 = base64.b64encode(audio_file.read()).decode("utf-8")
 
completion = client.chat.completions.create(
    model="omnio-chat-audio-preview",
    messages=[
        {
            "role": "user",
            "content": [
                {"audio_data_b64": audio_data_b64},
                {"text": "Write me a short summary of this audio file."},
            ],
        }
    ],
)
 
print(completion.choices[0].message.content)

Download the audio file podcast.mp3 and update the path in the code example to point to your downloaded file.

Run the example with python example.py — Omnio API will return a summary of the audio file.

On this page