Python SDK
The official Python SDK for PolarGrid with async and sync clients.Installation
Quick Start
Async Client (Recommended)
Sync Client
Configuration
Auto-Routing
Streaming
Response Metadata (latency)
PolarGrid attaches per-request metadata (region, latency breakdown) underresponse.pg_metadata. It is optional — fields may be None, and on the non-stream path latency_ms is commonly None. Always read it through the typed attribute and guard for None; never index a top-level latency_ms key (it does not exist and raises KeyError).
ChatCompletionChunk) do not carry pg_metadata — only the non-stream chat_completion response exposes it. If you need region/latency metadata on a streamed request, issue a non-stream call, or read the timing from your own client-side measurements.
Mock Mode
Type Hints
The SDK uses Pydantic models with full type hints:Environment Variables
Next Steps
Full Reference
Complete API reference
Voice Guide
Text-to-speech and speech-to-text
