Skip to main content
Inworld Router is fully compatible with the OpenAI SDK. By simply changing the base_url and api_key, you can add the capabilities of Inworld Router to your existing apps.

Endpoint

The OpenAI-compatible API endpoint is available at:
https://api.inworld.ai/v1
To use Inworld Router, change your API call URL or SDK base URL from https://api.openai.com/v1 to https://api.inworld.ai/v1.

OpenAI SDK

Below is an example request using OpenAI’s SDK
from openai import OpenAI

# Initialize the client with Inworld Router credentials
client = OpenAI(
    base_url="https://api.inworld.ai/v1",
    api_key="YOUR_INWORLD_API_KEY" # Your Inworld 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)