Overview
Pydantic AI is a type-safe, structured-output agent framework for Python. It works with any OpenAI-compatible endpoint throughOpenAIChatModel and OpenAIProvider, so you can point it at Eden AI’s V3 API and use models from OpenAI, Anthropic, Google, Cohere, Meta and more behind one key.
Installation
Pydantic AI requires Python 3.11 or later.Quick Start
Point Pydantic AI’s OpenAI model at Eden AI:Model naming
Models use theprovider/model format, for example openai/gpt-latest, anthropic/claude-sonnet-latest and vertex/gemini-flash-latest. Pass the id as the first argument of OpenAIChatModel. See List LLM Models for the full catalog.
Structured Output
Define a Pydanticoutput_type and the agent returns a validated object. By default Pydantic AI asks for the object through a tool call, so choose a model whose catalog entry has supports_function_calling (see List LLM Models):
Multi-Turn Conversations
Keep conversation history across runs withmessage_history:
Error Handling
Every 4xx or 5xx answer from Eden AI raisesModelHTTPError, with the status in e.status_code:
ModelAPIError is the parent class and also catches network failures, so keep it after ModelHTTPError.
Environment Variables
Next Steps
- Chat Completions - Core LLM endpoint
- List LLM Models - Browse available providers and models
- OpenAI SDK (Python) - Direct SDK usage