The fastest migration path. Keep using the OpenAI SDK — just change the base URL and auth.
import OpenAI from 'openai';// Before: OpenAIconst openai = new OpenAI({ apiKey: 'sk-...' });// After: PolarGrid (using OpenAI SDK)const pg = new OpenAI({ apiKey: 'pg_your_api_key', // PolarGrid API key — sent directly to the edge baseURL: 'https://api.yto-01.edge.polargrid.ai/v1', // pin a region, or discover one via the autorouter (see /guides/regions)});// Same API — no other changes neededconst response = await pg.chat.completions.create({ model: 'qwen-3.5-27b', // PolarGrid model name messages: [{ role: 'user', content: 'Hello!' }],});
from openai import OpenAI# Before: OpenAIclient = OpenAI(api_key="sk-...")# After: PolarGrid (using OpenAI SDK)client = OpenAI( api_key="pg_your_api_key", # PolarGrid API key — sent directly to the edge base_url="https://api.yto-01.edge.polargrid.ai/v1", # pin a region, or discover one via the autorouter (see /guides/regions))# Same API — no other changes neededresponse = client.chat.completions.create( model="qwen-3.5-27b", # PolarGrid model name messages=[{"role": "user", "content": "Hello!"}],)
The edge accepts your pg_* API key directly — no token exchange step.
If you’re calling OpenAI via raw HTTP, swap the base URL:
# Before: OpenAIcurl https://api.openai.com/v1/chat/completions \ -H "Authorization: Bearer sk-..." \ -H "Content-Type: application/json" \ -d '{"model": "gpt-4o", "messages": [{"role": "user", "content": "Hello"}]}'# After: PolarGrid — API key direct to the edge# Step 1: Ask the autorouter which edge is best for the caller (returns# {region, name, endpoint, ttl}; endpoint is the actual base URL).EDGE=$(curl -s https://autorouter.polargrid.ai/v1/route | jq -r .endpoint)# Step 2: POST inference directly to that edge with your pg_* keycurl $EDGE/v1/chat/completions \ -H "Authorization: Bearer pg_your_api_key" \ -H "Content-Type: application/json" \ -d '{"model": "qwen-3.5-27b", "messages": [{"role": "user", "content": "Hello"}]}'
Same endpoints; transcriptions are async by default for raw HTTP callers — see below
The PolarGrid SDK eliminates most of these differences — it handles auth, region selection, and token refresh automatically. If you’re building a new integration, start with the SDK.
OpenAI’s transcription endpoint is strictly synchronous. PolarGrid’s /v1/audio/transcriptions defaults to an async job — 202 Accepted with { job_id, status, poll_url } — which is better for long files but surprises OpenAI migrators expecting a transcript in the response body.What you’ll get depends on how you call it:
Stock OpenAI SDK (Option 1 above): no change needed. OpenAI SDKs send model as a multipart form field, and the endpoint serves those requests synchronously — you get the transcript inline, exactly as you do against OpenAI.
Raw HTTP or query-parameter requests: add ?sync=true to block until completion and get the formatted result inline. Without it you’ll receive a JSON job object, not your transcript.