Pydantic AI
Pydantic AI's OpenAI chat model takes a provider with a base URL and a key. That provider is all OpenCheap needs.
What you need
- Base URL
https://api.opencheap.si/v1 - API keyA
kl_live_…key from the console, kept inOPENCHEAP_API_KEY. - ModelAn id from Models, for example
claude-sonnet-5.
pip install "pydantic-ai-slim[openai]"An agent with a tool
import os
from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIChatModel
from pydantic_ai.providers.openai import OpenAIProvider
model = OpenAIChatModel(
"claude-sonnet-5",
provider=OpenAIProvider(base_url="https://api.opencheap.si/v1", api_key=os.environ["OPENCHEAP_API_KEY"]),
)
agent = Agent(model, instructions="Answer in one sentence.")
@agent.tool_plain
def get_weather(city: str) -> str:
"""Get the weather for a city."""
return f"Sunny in {city}"
print(agent.run_sync("What's the weather in Paris?").output)OpenAIChatModel uses /chat/completions, so any chat model from the Models page works; pick one that supports tool calls when the agent has tools.
What was checked
Run on October 28, 2026 with pydantic-ai-slim 2.31.1 on claude-sonnet-5: the agent called get_weather and answered from its result.