Realtime TTS-2 is live. Built for realtime conversation that feels human. Read the Realtime TTS-2 announcement

API formats

OpenAI compatibility

LLM Router serves OpenAI-compatible endpoints, so you can use the OpenAI SDK for chat completions, responses, and moderations. With the base URL and authentication settings below, you can add the capabilities of LLM Router to your existing apps.

Credential handling

Run these examples on your server. Set INWORLD_API_KEY to the complete Base64 credentials copied from Portal or the CLI, without encoding them again. The examples set an explicit Authorization: Basic ... header. The router also accepts the same credential as Authorization: Bearer ..., which is what the OpenAI SDK sends from api_key. Browser/mobile clients need a backend-minted token, never the server API key.

Endpoint

The OpenAI-compatible API endpoint is available at:

https://api.inworld.ai/v1

To use LLM Router, change your API call URL or SDK base URL from https://api.openai.com/v1 to https://api.inworld.ai/v1.

Supported endpoints

EndpointSDK methodGuide
POST /v1/chat/completionsclient.chat.completions.createText chat
POST /v1/responses and /v1/responses/{response_id} endpointsclient.responses.*Responses API
POST /v1/moderationsclient.moderations.createModeration

The router does not serve other OpenAI endpoints, including /v1/models (client.models.list() returns 404), /v1/batches, /v1/embeddings, and the file and image endpoints. To list available models, use the List Models API. For text-to-speech in OpenAI's /v1/audio/speech format, see TTS OpenAI compatibility.

OpenAI SDK

Below is an example request using OpenAI's SDK

Python
import os
from openai import OpenAI

api_key = os.environ["INWORLD_API_KEY"]

# Initialize the client with LLM Router credentials
client = OpenAI(
    base_url="https://api.inworld.ai/v1",
    api_key=api_key,
    default_headers={"Authorization": f"Basic {api_key}"},
)

# Call your router
response = client.chat.completions.create(
    model="inworld/<router-id>",
    messages=[
        {"role": "user", "content": "Who created you?"}
    ]
)

print(response.choices[0].message.content)

Responses API

The same client works with the Responses API:

python
response = client.responses.create(
    model="inworld/<router-id>",
    input="Who created you?",
)

print(response.output_text)

See the Responses API guide for streaming, tools, and stored responses.