Pydantic AI brings type-safe, structured outputs to agent development. Define response schemas with Pydantic models and get validated, typed results from your LLM calls.
agent.py
Copy
from pydantic_ai import Agentagent = Agent("openai:gpt-4o", system_prompt="You are a helpful assistant.")while True: try: user_input = input() except EOFError: break result = agent.run_sync(user_input) print(result.output)
requirements.txt
Copy
pydantic-ai
Copy
superserve deploy agent.pysuperserve secrets set my-agent OPENAI_API_KEY=sk-...superserve run my-agent
Pydantic AI’s result_type parameter lets you get structured, validated JSON instead of plain text - useful for agents that return data. See the Pydantic AI results docs.