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.
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 |
Next Steps
Quickstart
Get started in 5 minutes
Installation
Full installation guide
Chat Completions
Learn the Chat API
Evaluations
Test your LLM outputs