Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.auriko.ai/llms.txt

Use this file to discover all available pages before exploring further.

Use Auriko as your LLM provider in the OpenAI Agents SDK. This integration is Python-only. For TypeScript, use the Vercel AI SDK integration.
Requires openai-agents >=0.13.

Prerequisites

Install

pip install "auriko[openai-compat]" openai-agents

Use AurikoAsyncOpenAI (experimental)

AurikoAsyncOpenAI (experimental) is an AsyncOpenAI subclass that captures routing metadata from every successful response. Pass it to OpenAIChatCompletionsModel via the openai_client= parameter:
import asyncio
from agents import Agent, Runner, set_tracing_disabled
from agents.models.openai_chatcompletions import OpenAIChatCompletionsModel
from auriko import AurikoAsyncOpenAI

set_tracing_disabled(True)

client = AurikoAsyncOpenAI()
model = OpenAIChatCompletionsModel(model="gpt-4o-mini", openai_client=client)
agent = Agent(name="assistant", instructions="Be brief.", model=model)

async def main():
    result = await Runner.run(agent, input="What is the capital of France?")
    print(result.final_output)
    print(client.last_routing_metadata.provider)

asyncio.run(main())
Runner.run_sync() works the same way.

Configure routing

Pass routing options through ModelSettings.extra_body, not through the client.chat.completions.create() call:
from agents import Agent
from agents.model_settings import ModelSettings
from auriko.route_types import RoutingOptions

model_settings = ModelSettings(
    extra_body=RoutingOptions(optimize="cost").to_extra_body(),
)
agent = Agent(name="assistant", instructions="Be brief.", model=model, model_settings=model_settings)
The Agents SDK forwards ModelSettings.extra_body to the API call. RoutingOptions.to_extra_body() returns a dict the Auriko API accepts.

Access routing metadata

Read client.last_routing_metadata after a run completes:
result = Runner.run_sync(agent, "Hello!")
print(client.last_routing_metadata.provider)
print(client.last_routing_metadata.routing_strategy)
The property uses last-write-wins semantics on a shared client. For per-request capture across concurrent runs, pass an on_response callback:
captured = []
client = AurikoAsyncOpenAI(on_response=lambda m: captured.append(m))
The callback must be synchronous. Passing an async callable raises TypeError.

Handle errors

AurikoAsyncOpenAI raises errors catchable as both Auriko and OpenAI error types:
import asyncio
import auriko
from agents import Agent, Runner, set_tracing_disabled
from agents.models.openai_chatcompletions import OpenAIChatCompletionsModel
from auriko import AurikoAsyncOpenAI

set_tracing_disabled(True)

async def main():
    client = AurikoAsyncOpenAI()
    model = OpenAIChatCompletionsModel(model="gpt-4o-mini", openai_client=client)
    agent = Agent(name="assistant", instructions="Be brief.", model=model)
    try:
        result = await Runner.run(agent, input="Hello!")
        print(result.final_output)
    except auriko.RateLimitError as e:  # also catchable as openai.RateLimitError
        print(f"Rate limited: {e.message}")

asyncio.run(main())
The same error is also catchable as openai.RateLimitError. Network-layer exceptions (openai.APITimeoutError, openai.APIConnectionError) propagate unchanged.
Mid-stream SSE errors (raised after the HTTP 200 during stream=True) remain unmapped openai.APIError. AurikoAsyncOpenAI maps HTTP-level status errors only.
For the full class reference, see AurikoAsyncOpenAI.

Configure manually

If you prefer to configure the SDK’s client directly, without the Auriko integration:
import asyncio
import os
from openai import AsyncOpenAI
from agents import Agent, Runner, set_default_openai_client, set_default_openai_api, set_tracing_disabled

set_default_openai_api("chat_completions")
set_tracing_disabled(True)

client = AsyncOpenAI(
    base_url="https://api.auriko.ai/v1",
    api_key=os.environ["AURIKO_API_KEY"],
)
set_default_openai_client(client, use_for_tracing=False)

agent = Agent(name="assistant", instructions="Be helpful.", model="gpt-5.4")

async def main():
    result = await Runner.run(agent, input="Hello!")
    print(result.final_output)

asyncio.run(main())
set_default_openai_api("chat_completions") is the default for the Agents SDK. Chat Completions streaming includes routing_metadata in the response. /v1/responses streaming does not include routing_metadata yet.