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
Use a model name or~ alias from GET /v3/models, such as ~claude-sonnet-latest; a provider/model id pins one provider. Pass it as the first argument of OpenAIChatModel.
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