Skip to main content
OpenRouter provides unified API access to 100+ AI models from multiple providers including OpenAI, Anthropic, Google, Meta, and more.

Prerequisites

  • OpenRouter account: openrouter.ai
  • API key (free credits available)
  • Credits for paid models (or use free models)

Setup

1

Get API Key

  1. Sign up at openrouter.ai
  2. Navigate to Keys in your account
  3. Click Create Key
  4. Copy the key (starts with sk-or-)
OpenRouter provides $1 in free credits to test models.
2

Open Glyph AI Settings

Go to Settings → AI and select the OpenRouter profile.
3

Add API Key

  1. Click Set API Key in the authentication section
  2. Paste your OpenRouter API key
  3. Click Save
The key is stored in .glyph/app/ai_secrets.json in your space directory.
4

Select Model

Click the Model dropdown. Glyph fetches 100+ available models from OpenRouter.Popular models:
  • anthropic/claude-3.5-sonnet
  • openai/gpt-4o
  • google/gemini-pro-1.5
  • meta-llama/llama-3.1-70b-instruct
  • mistralai/mistral-large
Free models are marked in the OpenRouter model list.
5

Test Connection

Open the AI panel and send a test message. You should receive a response from your selected model.

Configuration

Provider Settings

  • Service: openrouter
  • Base URL: https://openrouter.ai/api/v1 (default)
  • Authentication: Bearer token (API key)

Model Routing

OpenRouter automatically routes your request to the best available provider for your selected model.

Model Selection

Glyph fetches the latest model list from OpenRouter’s /v1/models endpoint.

Model Details

OpenRouter provides rich model metadata:
  • Context length - Maximum tokens per request
  • Pricing - Input and output token costs
  • Modalities - Text, image, audio support
  • Max output tokens - Maximum response length
  • Supported parameters - Available model options
Hover over the info icon in the model selector to view these details.

Free Models

ModelProviderUse Case
meta-llama/llama-3.1-8b-instruct:freeMetaGeneral purpose
mistralai/mistral-7b-instruct:freeMistralFast tasks
google/gemini-flash-1.5:freeGoogleMultimodal
Free models have rate limits but are great for testing and light usage.
ModelInput CostOutput Cost
anthropic/claude-3.5-sonnet$3/1M tokens$15/1M tokens
openai/gpt-4o$2.50/1M tokens$10/1M tokens
google/gemini-pro-1.5$1.25/1M tokens$5/1M tokens
meta-llama/llama-3.1-70b-instruct$0.88/1M tokens$0.88/1M tokens
Check current pricing at openrouter.ai/models.

Features

Chat Mode

Conversational interaction:
  • Back-and-forth dialogue with any model
  • No file system access
  • Fast responses
  • Best for discussion and brainstorming

Create Mode

AI with workspace tools:
  • read_file - Read files from your space
  • search_notes - Search note content
  • list_dir - List directory contents
  • Tool usage tracked in timeline view
  • Best for research and knowledge retrieval
Tool support varies by model. Most modern models (GPT-4, Claude, Gemini) support function calling.

Context Attachment

Attach notes for grounded responses:
  • Attach files or folders via context menu
  • Mention with @filename syntax
  • Configure character budget (up to 250K chars)
  • Context limits vary by model

API Usage and Billing

Credits

OpenRouter uses a credit system:

Cost Estimation

Use the model selector to view pricing before sending:
  1. Select a model
  2. Hover over the info icon
  3. View input/output pricing
  4. Estimate cost: (input_tokens × input_price) + (output_tokens × output_price)

Rate Limits

Rate limits depend on your credit balance and model:

Troubleshooting

”API key not set for this profile”

Solution: Add your OpenRouter API key in Settings → AI.

”model list failed (401)”

Solution: Your API key is invalid. Generate a new key from OpenRouter.

”insufficient credits”

Solution: Add credits at openrouter.ai/credits or use a free model.

”model not found”

Cause: The model ID is incorrect or the model is no longer available. Solution: Refresh the model list or check openrouter.ai/models for valid model IDs.

Model list is very long

Solution: Use the search/filter in the model selector. Type to filter by provider or model name.

Responses from different providers

Cause: OpenRouter routes to the best available provider for your model. If primary provider is unavailable, it uses a fallback. Solution: This is expected behavior. Check OpenRouter’s dashboard for routing details.

Advanced Features

Provider Preferences

Some OpenRouter models allow provider selection (e.g., anthropic/claude-3.5-sonnet:beta vs anthropic/claude-3.5-sonnet). Use the full model ID from openrouter.ai/models to specify routing.

Custom Headers

OpenRouter supports custom headers for advanced use cases:
[
  { "key": "HTTP-Referer", "value": "https://yourdomain.com" },
  { "key": "X-Title", "value": "Glyph Integration" }
]
These headers may provide better rate limits and routing.

Security Best Practices

  • Never commit .glyph/app/ai_secrets.json to version control
  • Rotate API keys if exposed
  • Monitor usage at openrouter.ai/activity
  • Set spending limits in your OpenRouter account

OpenRouter vs Direct Providers

Advantages of OpenRouter

✅ Single API key for 100+ models ✅ Automatic provider failover ✅ Unified billing ✅ Model comparison and discovery ✅ Free models available

When to Use Direct Providers

  • Lower latency (no routing layer)
  • Provider-specific features (e.g., Anthropic’s thinking models)
  • Direct billing relationship
  • Higher rate limits with provider-native keys

Next Steps

Chat Modes

Learn about chat vs create modes

Context Management

Attach notes to conversations

OpenAI

Compare with direct OpenAI integration

Profiles

Manage multiple AI profiles