Skip to main content
Pydantic AI has no Eden AI provider, so you connect it through its OpenAI-compatible classes. This page shows the setup, structured output, message history and error handling.

Overview

Pydantic AI is a type-safe, structured-output agent framework for Python. It works with any OpenAI-compatible endpoint through OpenAIChatModel 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 the provider/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 Pydantic output_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 with message_history:

Error Handling

Every 4xx or 5xx answer from Eden AI raises ModelHTTPError, 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