AI Gateway
Overview
Pydantic AI is a Python agent framework designed to make it easier to build production-grade applications with Generative AI. Connecting Pydantic AI to Orq.ai’s AI Gateway transforms experimental agents into production-ready systems with enterprise-grade capabilities.Key Benefits
Orq.ai’s AI Gateway enhances Pydantic AI agents with:Complete Observability
Track every agent step, tool use, and interaction with detailed traces and analytics
Built-in Reliability
Automatic fallbacks, retries, and load balancing for production resilience
Cost Optimization
Real-time cost tracking and spend management across all AI operations
Multi-Provider Access
Access 300+ LLMs and 20+ providers through a single, unified integration
Prerequisites
Before integrating Pydantic AI with Orq.ai, ensure the following are in place:- An Orq.ai account and API Key
- Python 3.9 or higher
- Pydantic AI SDK installed
To set up an API key, see API keys & Endpoints.
Installation
Install Pydantic AI and the OpenAI SDK:Configuration
Configure Pydantic AI to use Orq.ai’s AI Gateway by passing a custom OpenAI client:Python
base_url: https://api.orq.ai/v3/router
Basic Agent Example
Here’s a complete example of creating and running a Pydantic AI agent through Orq.ai:Python
Agent with Tools
Pydantic AI agents can use tools while routing through Orq.ai:Python
Structured Outputs
Pydantic AI excels at structured outputs with type-safe validation:Python
Model Selection
With Orq.ai, any supported model from 20+ providers can be used:Python