Quickstart#

Omnio API offers a user-friendly 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.

Create Soniox Account#

Create a free Soniox Account. A Soniox Account is free of charge and does not require credit card information. You will receive $5.00 in free credits for Omnio API usage.

API key#

Go to the Soniox Console, to obtain an API key, which will enable you to access Soniox APIs. After generating the API key, export it as an environment variable in your terminal for use.

export SONIOX_API_KEY="your_soniox_api_key_here"

First API Request#

Once your Soniox API key is set as an environment variable, you can start making API requests. You can either interact with the API directly using any HTTP client or leverage a client that supports OpenAI’s Chat Completion API.

To use the official OpenAI SDK for Python, get started by installing the SDK using pip:

pip install openai

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

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.

Lastly, run the code with python example.py, and in a few moments, the API should return a summary of the provided audio file.