Pydantic AI
SDKs & frameworksType-safe Python agents with structured, validated outputs.
Fill the guide with your values
Stays in this browser tab — never sent or stored by us. Sign in to create one
Setup
- 1Use OpenAIChatModel with an OpenAIProvider pointed at
https://api.ultragpt.pro/v1.
# pip install pydantic-ai
import os
from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIChatModel
from pydantic_ai.providers.openai import OpenAIProvider
model = OpenAIChatModel(
"grok-4.7",
provider=OpenAIProvider(base_url="https://api.ultragpt.pro/v1", api_key=os.environ["ULTRAGPT_API_KEY"]),
)
agent = Agent(model, instructions="Be concise.")
print(agent.run_sync("Where were the 2012 Olympics held?").output)Tips
- Any model id from Models works; suffixes like :online (web search) and :nitro work too.
- Give each tool its own key with a spend limit, so usage shows separately in Activity.
- Something off? Error codes · Support