Skip to main content

Quickstart

This guide will get you from zero to your first PolarGrid API call in under 5 minutes.

1. Get an API Key

1

Sign up

Create an account at app.polargrid.ai
2

Create API key

Go to Settings → API Keys and click Generate New Key
3

Copy your key

Your key starts with pg_. Keep it secure — you won’t see it again.

2. Make Your First Request

# Set your API key
export API_KEY="pg_your_api_key"

# Ask the autorouter which edge is fastest for the caller — it returns
# {region, name, endpoint, ttl}. The endpoint is the actual base URL for
# inference. Autorouter only serves /v1/route; it does NOT proxy inference.
EDGE=$(curl -s https://autorouter.polargrid.ai/v1/route | jq -r .endpoint)

# List available models on that edge — send the API key directly.
curl -s "$EDGE/v1/models" -H "Authorization: Bearer $API_KEY" | jq '.data[].id'

# Run a chat completion against the same edge
curl -s -X POST "$EDGE/v1/chat/completions" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-3.5-27b",
    "messages": [{"role": "user", "content": "Hello!"}]
  }' | jq
The edge accepts your pg_* API key directly. The SDKs additionally handle region selection automatically. See Authentication for details.

3. Choose Your Region

PolarGrid automatically routes to the fastest region when you use PolarGrid.create(). You can also specify one explicitly:
// Auto-select best region (recommended)
const client = await PolarGrid.create({ apiKey: 'pg_...' });
console.log(`Connected to: ${client.getRegionName()}`); // e.g., "Toronto"

// Or specify a region explicitly
const client = new PolarGrid({
  apiKey: 'pg_...',
  region: 'toronto'  // aliases: 'yto-01', 'yto'
});

Next Steps

Streaming Responses

Stream tokens as they’re generated

Voice AI

Text-to-speech and speech-to-text

API Reference

Full endpoint documentation

Error Handling

Handle errors gracefully