Skip to main content
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
from pydantic_ai import Agent

agent = 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
pydantic-ai
superserve deploy agent.py
superserve 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.

See the full Python example. Integrate deployed agents into your apps using the Superserve SDK.