> ## Documentation Index
> Fetch the complete documentation index at: https://polargrid.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Get your first API call working in 5 minutes

# Quickstart

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

## 1. Get an API Key

<Steps>
  <Step title="Sign up">
    Create an account at <a href="https://app.polargrid.ai" target="_blank">app.polargrid.ai</a>
  </Step>

  <Step title="Create API key">
    Go to <a href="https://app.polargrid.ai/dashboard/settings?tab=api-keys" target="_blank">Settings → API Keys</a> and click **Generate New Key**
  </Step>

  <Step title="Copy your key">
    Your key starts with `pg_`. Keep it secure — you won't see it again.
  </Step>
</Steps>

## 2. Make Your First Request

<CodeGroup>
  ```bash cURL theme={null}
  # 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
  ```

  ```javascript JavaScript theme={null}
  import { PolarGrid } from '@polargrid/polargrid-sdk';

  // Auto-select fastest region and handle auth automatically
  const client = await PolarGrid.create({
    apiKey: 'pg_your_api_key',
  });

  const response = await client.chatCompletion({
    model: 'qwen-3.5-27b',
    messages: [
      { role: 'user', content: 'Hello!' }
    ]
  });

  console.log(response.choices[0].message.content);
  ```

  ```python Python theme={null}
  from polargrid import PolarGrid

  # Auto-select fastest region and handle auth automatically
  client = await PolarGrid.create(api_key="pg_your_api_key")

  response = await client.chat_completion({
      "model": "qwen-3.5-27b",
      "messages": [
          {"role": "user", "content": "Hello!"}
      ]
  })

  print(response.choices[0].message.content)
  ```
</CodeGroup>

<Note>
  The edge accepts your `pg_*` API key directly. The SDKs additionally handle region selection automatically. See [Authentication](/authentication) for details.
</Note>

## 3. Choose Your Region

PolarGrid automatically routes to the fastest region when you use `PolarGrid.create()`. You can also specify one explicitly:

<CodeGroup>
  ```javascript JavaScript theme={null}
  // 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'
  });
  ```

  ```python Python theme={null}
  # Auto-select best region (recommended)
  client = await PolarGrid.create(api_key="pg_...")
  print(f"Connected to: {client.get_region_name()}")  # e.g., "Toronto"

  # Or specify a region explicitly
  client = PolarGrid(api_key="pg_...", region="toronto")
  ```
</CodeGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Streaming Responses" icon="bolt" href="/guides/streaming">
    Stream tokens as they're generated
  </Card>

  <Card title="Voice AI" icon="microphone" href="/guides/voice">
    Text-to-speech and speech-to-text
  </Card>

  <Card title="API Reference" icon="book" href="/api-reference/overview">
    Full endpoint documentation
  </Card>

  <Card title="Error Handling" icon="triangle-exclamation" href="/guides/error-handling">
    Handle errors gracefully
  </Card>
</CardGroup>
