AI Gateway
Overview
DSPy is a framework for programmatically optimizing LLM prompts and weights through composable modules and signatures. Connecting DSPy to Orq.ai’s AI Gateway provides access to 300+ models for prompt optimization pipelines with a single configuration change.Key Benefits
Orq.ai’s AI Gateway enhances DSPy applications with:Complete Observability
Track every signature execution, module call, and optimization step
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 DSPy with Orq.ai, ensure the following are in place:- An Orq.ai account and API Key
- Python 3.8 or higher
To set up an API key, see API keys & Endpoints.
Installation
Configuration
Configure DSPy to use Orq.ai’s AI Gateway withdspy.LM:
Python
api_base: https://api.orq.ai/v3/router
Basic Example
Python
Chain of Thought
UseChainOfThought for step-by-step reasoning:
Python
Model Selection
With Orq.ai, any supported model from 20+ providers can be used:Python