Skip to main content

Troubleshooting

Quick reference for the most common errors you’ll hit when integrating with PolarGrid.

HTTP Error Reference

Authentication Issues

”I’m sending my API key but getting 401”

Edge endpoints accept pg_* API keys directly — no token exchange needed:
The SDK also sends pg_* keys directly. If you’re still getting 401:
  • Check the key is active in Settings > API Keys (not revoked)
  • Check the endpoint — some non-edge endpoints (e.g., management APIs) may require a session JWT
  • Check the format — the key must start with pg_
For endpoints that require a session JWT, exchange your API key first:

“My key works in the playground but not in my code”

The playground uses the same auth flow as the SDK. Common causes:
  • Wrong base URL: Use regional edge URLs like api.yto-01.edge.polargrid.ai, not api.polargrid.ai
  • Missing Content-Type: POST requests need Content-Type: application/json
  • Key permissions: Check that your key has read-write permissions in the dashboard

Region and Routing Issues

”Which region should I use?”

Use the autorouter for automatic region selection:
Or pick a specific region:

”I’m getting high latency”

  1. Check you’re hitting the nearest region (use the autorouter)
  2. First requests may be slower due to model cold start
  3. Use GET /health to check if the edge node is healthy before sending inference requests

Browser / Frontend Issues

”ReferenceError: process is not defined”

The SDK references process.env for configuration fallbacks. In browser environments (Vite, esbuild, Parcel), process is not defined. Fix: Pass all configuration explicitly at init:

“CORS error when calling the API from my frontend”

Edge inference endpoints include Access-Control-Allow-Origin: * via CORS middleware, so browser-origin requests work directly. If you’re seeing CORS errors:
  1. Check the URL: Make sure you’re hitting a regional edge URL (api.yto-01.edge.polargrid.ai), not a misconfigured proxy
  2. Check the auth endpoint: If the CORS error is on auth.polargrid.ai, ensure your auth-service deployment includes CORS headers (added in POL-230)
  3. Check preflight: OPTIONS requests must return 2xx with CORS headers — if your proxy strips them, the browser blocks the real request

TTS Issues

”TTS returns 0 bytes or empty audio”

Common causes:
  • Empty input field
  • Invalid voice parameter (check available voices in the TTS docs)
  • Quoted text with special characters can sometimes cause issues

”TTS generation time is very slow”

TTS generation time scales linearly with input length for batch requests. For long text, consider:
  • Breaking text into shorter segments
  • Using streaming TTS (stream: true) for faster time-to-first-audio

Still Stuck?