APIs & SDKs
OpenAI Compatibility
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/v1To 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)import OpenAI from 'openai';
const openai = new OpenAI({
baseURL: 'https://api.inworld.ai/v1',
apiKey: 'YOUR_INWORLD_API_KEY',
});
async function main() {
const completion = await openai.chat.completions.create({
messages: [{ role: 'user', content: 'Who created you?' }],
model: 'inworld/demo-router'
});
console.log(completion.choices[0].message.content);
}
main();