Skip to content

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 OpenAIModel

model = OpenAIModel(
    "claude-sonnet-4.5",  # or any other Siraya Model Router model
    base_url="https://llm.siraya.ai/v1",
    api_key="API_KEY",
)

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

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