> ## 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.

# SDKs Overview

> Official SDKs for JavaScript, Python, and CLI

# SDKs

PolarGrid provides official SDKs to make integration easy.

<CardGroup cols={3}>
  <Card title="JavaScript" icon="js" href="/sdks/javascript/quickstart">
    For Node.js and browser applications
  </Card>

  <Card title="Python" icon="python" href="/sdks/python/quickstart">
    Async and sync clients with full type hints
  </Card>

  <Card title="CLI" icon="terminal" href="/sdks/cli/quickstart">
    Command-line interface for scripting and CI/CD
  </Card>
</CardGroup>

## Installation

<CodeGroup>
  ```bash JavaScript theme={null}
  npm install @polargrid/polargrid-sdk
  ```

  ```bash Python theme={null}
  pip install polargrid-sdk
  ```

  ```bash CLI theme={null}
  npm install -g @polargrid/cli
  ```
</CodeGroup>

## Features

All SDKs include:

| Feature                        |  JS | Python | CLI |
| ------------------------------ | :-: | :----: | :-: |
| Chat completions               |  ✅  |    ✅   |  ✅  |
| Text completions               |  ✅  |    ✅   |  —  |
| Streaming                      |  ✅  |    ✅   |  —  |
| Text-to-Speech                 |  ✅  |    ✅   |  —  |
| Speech-to-Text                 |  ✅  |    ✅   |  —  |
| Model management               |  ✅  |    ✅   |  —  |
| GPU management                 |  ✅  |    ✅   |  —  |
| Auto-routing                   |  ✅  |    ✅   |  ✅  |
| Mock mode                      |  ✅  |    ✅   |  —  |
| Full TypeScript/Pydantic types |  ✅  |    ✅   |  —  |
| Async                          |  ✅  |    ✅   |  —  |
| Sync                           |  —  |    ✅   |  ✅  |

## Quick Example

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

  // Auto-select best region
  const client = await PolarGrid.create({
    apiKey: process.env.POLARGRID_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}
  import os
  from polargrid import PolarGrid

  # Auto-select best region
  client = await PolarGrid.create(api_key=os.environ["POLARGRID_API_KEY"])

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

  print(response.choices[0].message.content)
  ```

  ```bash CLI theme={null}
  export POLARGRID_API_KEY="pg_your_key"
  polargrid test inference --region toronto --prompt "Hello!"
  ```
</CodeGroup>

## Authentication

All SDKs support these authentication methods:

1. **Constructor parameter**: Pass `apiKey` / `api_key` directly
2. **Environment variable**: Set `POLARGRID_API_KEY`

```bash theme={null}
export POLARGRID_API_KEY="pg_your_api_key"
```

Get your API key from the <a href="https://app.polargrid.ai/dashboard/settings?tab=api-keys" target="_blank">Console</a>.
