Skip to main content

SDKs

PolarGrid provides official SDKs to make integration easy.

Installation

npm install @polargrid/sdk

Features

All SDKs include:
FeatureJSPythonCLI
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

import { PolarGrid } from '@polargrid/sdk';

// Auto-select best region
const client = await PolarGrid.create({
  apiKey: process.env.POLARGRID_API_KEY,
});

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

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

Authentication

All SDKs support these authentication methods:
  1. Constructor parameter: Pass apiKey / api_key directly
  2. Environment variable: Set POLARGRID_API_KEY
export POLARGRID_API_KEY="pg_your_api_key"
Get your API key from the Console.