Lunar SDK
Lunar is a Python SDK that provides a simple, OpenAI-compatible interface to access multiple LLM providers through the PureAI API. It features intelligent fallback mechanisms, per-request cost tracking, and a built-in evaluation framework.Key Features
OpenAI-Compatible
Drop-in replacement for OpenAI SDK. Migrate existing code with minimal changes.
Intelligent Fallbacks
Automatic retry with fallback models when providers experience issues.
Cost Tracking
Real-time cost tracking for every request with token-level granularity.
Built-in Evals
Comprehensive evaluation framework with 15+ built-in scorers.
Architecture
API Endpoints
| Environment | Base URL |
|---|---|
| Production | https://api.pureai-api.com |
| Development | https://dev-api.pureai-api.com |
Clients
The SDK provides two client classes:| Client | Description |
|---|---|
Lunar | Synchronous client for standard applications |
AsyncLunar | Asynchronous client for high-performance applications |
Quick Example
Resources
The SDK exposes these resources:| Resource | Description |
|---|---|
client.chat.completions | Chat completion API (messages-based) |
client.completions | Text completion API (prompt-based) |
client.models | List available models |
client.providers | List available providers |
client.evals | Run evaluations |
client.datasets | Manage evaluation datasets |