Skip to main content

Authentication

All PolarGrid API requests require authentication using an API key.

API Keys

API keys are created in the PolarGrid Console and start with pg_.

Creating a Key

  1. Open the API Keys page — either click Generate API Key (or Manage API Keys) on the Dashboard Overview, or go to Settings → API Keys in the sidebar
  2. Click Generate New Key
  3. Give it a descriptive name (e.g., “Production App”, “Development”)
  4. Select permissions: read-write (default), read-only, or admin
  5. Copy the key immediately — it won’t be shown again

Using Your Key

The SDKs handle authentication automatically — just pass your API key:

Raw HTTP (cURL)

Send your pg_* API key directly to the edge. Pick a region with the autorouter (one request) or pin one.
The autorouter (autorouter.polargrid.ai) is a discovery endpoint — it serves GET /v1/route only. It does not proxy /v1/chat/completions, /v1/models, or any other inference traffic; POST against it is rejected by CloudFront with 403.

Playground vs API

The Playground in the Console uses your real pg_* API key — the same key from Creating a Key above. There is no separate “playground token”.
1

Open the Playground

Click Playground in the Console sidebar.
2

Select your key

Pick a saved key from the Playground’s API key dropdown, or paste one manually.
Under the hood, the Playground sends your API key directly to the nearest edge — the same flow as a raw cURL call.

Environment Variables

We recommend storing your API key in an environment variable:
The SDKs automatically read from this variable:

Permission Levels

The inference endpoints (/v1/chat/completions, /v1/completions, /v1/models, /v1/audio/*) are not currently scope-gated — any active key can call them. Scope enforcement is presently scoped to /v1/tokens. Default to read-write unless you have a specific reason to narrow.

Troubleshooting Auth Errors

Advanced: Session Tokens (CLI / Management Plane)

For most users, the pg_* API key sent as Authorization: Bearer pg_* is all you need — edge endpoints accept it directly and no token exchange is required. The CLI and management-plane APIs (org management, key listing) use a separate session-token flow: the CLI exchanges a pg_* key via POST https://auth.polargrid.ai/v1/auth/session to obtain a short-lived JWT for those endpoints. This is handled automatically by polargrid login and is not needed for inference.
Edge inference endpoints (/v1/chat/completions, /v1/audio/*, /v1/models) do not require a JWT — send your pg_* API key directly as a bearer token. The session-token flow above applies only to CLI and management-plane operations.

Security Best Practices

Never commit API keys to source control or expose them in client-side code.
  • Use environment variables for API keys
  • Rotate keys periodically
  • Use separate keys for development and production
  • Revoke keys immediately if compromised

CLI Authentication

The CLI supports two authentication methods:

Browser Login (Interactive)

Opens your browser for OAuth authentication. Best for development.

API Key (CI/CD)

No login needed — just set the environment variable.