Soniox
Docs

Quickstart

Learn how to use and integrate 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.

Note: API keys are bound to projects. Click on "API keys" under "My First Project" section to create one.

Configure environment

Store the API key in the SONIOX_API_KEY environment variable to prevent accidental exposure.

Terminal
export SONIOX_API_KEY=<YOUR_API_KEY>

Note: Alternative is to put the API key in .env file, if you already have it configured.

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