Skip to content
SDKs & Integrations

PydanticAI

Using PydanticAI

PydanticAI provides a high-level interface for working with various LLM providers, including SIRAYA Model Router.

Installation

pip install 'pydantic-ai-slim[openai]'

Configuration

You can use SIRAYA Model Router with PydanticAI through its OpenAI-compatible interface:

from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIChatModel
from pydantic_ai.providers.openai import OpenAIProvider

model = OpenAIChatModel(
    "claude-sonnet-4.5",  # or any other SIRAYA Model Router model
    provider=OpenAIProvider(
        base_url="https://llm.siraya.ai/v1",
        api_key="<API_KEY>",
    ),
)

agent = Agent(model)
result = agent.run_sync("What is the meaning of life?")
print(result.output)

For more details about using PydanticAI with SIRAYA Model Router, see the PydanticAI documentation.