Skip to main content
Polaris supports two AI providers for code suggestions, quick edits, and conversations.

Supported providers

Anthropic Claude

Recommended - Claude 3.7 Sonnet for best results

Google Gemini

Free tier - Gemini 2.0 Flash for development

Anthropic Claude

Claude Sonnet 4 provides the best code completion quality for Polaris.
1

Create an Anthropic account

  1. Visit console.anthropic.com
  2. Sign up for an account
  3. Add billing information (pay-as-you-go)
2

Generate an API key

  1. Go to API Keys in the console
  2. Click Create Key
  3. Copy your API key (starts with sk-ant-)
3

Add to environment variables

ANTHROPIC_API_KEY=sk-ant-api03-...
4

Verify installation

The required package is already in package.json:
{
  "dependencies": {
    "@ai-sdk/anthropic": "^3.0.1"
  }
}

Models used

Polaris uses different Claude models for different features:
FeatureModelWhy
SuggestionsClaude 3.7 SonnetFast, high-quality completions
Quick EditClaude 3.7 SonnetAccurate code transformations
ConversationsClaude Opus 4Complex reasoning and planning

Configuration

The AI provider is configured in API routes:
import { anthropic } from '@ai-sdk/anthropic';
import { generateText } from 'ai';

const model = anthropic('claude-3-7-sonnet-20250219');

const { text } = await generateText({
  model,
  messages: [...],
  temperature: 0.3,
});

Google Gemini

Gemini 2.0 Flash is a free alternative for development and testing.
1

Create a Google Cloud account

Visit aistudio.google.com and sign in with your Google account.
2

Generate an API key

  1. Click Get API key in AI Studio
  2. Create a new API key
  3. Copy the key
3

Add to environment variables

GOOGLE_GENERATIVE_AI_API_KEY=AIza...
4

Verify installation

The required package is already in package.json:
{
  "dependencies": {
    "@ai-sdk/google": "^3.0.1"
  }
}

Model configuration

Gemini uses a single model for all features:
import { google } from '@ai-sdk/google';
import { generateText } from 'ai';

const model = google('gemini-2.0-flash-exp');

const { text } = await generateText({
  model,
  messages: [...],
  temperature: 0.3,
});

Choosing a provider

Switching providers

You can switch between providers without code changes:
  1. Remove the current provider’s API key from .env.local
  2. Add the new provider’s API key
  3. Restart your development server
Polaris automatically detects which provider is configured.

Cost optimization

Reduce costs by adjusting debounce timing for suggestions:Edit src/features/editor/extensions/suggestion/index.ts and increase the debounce delay from 300ms to 1000ms.
Never commit API keys to version control. Always use environment variables and add .env.local to .gitignore.

Rate limits

Claude

  • Tier 1: 50 RPM, 40,000 TPM
  • Tier 2: 1,000 RPM, 80,000 TPM
  • Tier 3: 2,000 RPM, 160,000 TPM

Gemini

  • Free tier: 15 RPM, 1,500 requests/day
  • Paid tier: 1,000 RPM, 4M tokens/min

Troubleshooting

Verify your key is correct and has billing enabled (for Claude) or is within rate limits (for Gemini).
Check your browser console for errors. Ensure your API key is set and the provider is reachable.
For Gemini free tier, you’ve hit the daily limit. Wait 24 hours or upgrade to a paid plan.

Learn more

Build docs developers (and LLMs) love