Prerequisites
- OpenRouter account: openrouter.ai
- API key (free credits available)
- Credits for paid models (or use free models)
Setup
Get API Key
- Sign up at openrouter.ai
- Navigate to Keys in your account
- Click Create Key
- Copy the key (starts with
sk-or-)
OpenRouter provides $1 in free credits to test models.
Add API Key
- Click Set API Key in the authentication section
- Paste your OpenRouter API key
- Click Save
.glyph/app/ai_secrets.json in your space directory.Select Model
Click the Model dropdown. Glyph fetches 100+ available models from OpenRouter.Popular models:
anthropic/claude-3.5-sonnetopenai/gpt-4ogoogle/gemini-pro-1.5meta-llama/llama-3.1-70b-instructmistralai/mistral-large
Free models are marked in the OpenRouter model list.
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
Recommended Models
Free Models
| Model | Provider | Use Case |
|---|---|---|
meta-llama/llama-3.1-8b-instruct:free | Meta | General purpose |
mistralai/mistral-7b-instruct:free | Mistral | Fast tasks |
google/gemini-flash-1.5:free | Multimodal |
Free models have rate limits but are great for testing and light usage.
Paid Models (High Performance)
| Model | Input Cost | Output 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 |
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
@filenamesyntax - Configure character budget (up to 250K chars)
- Context limits vary by model
API Usage and Billing
Credits
OpenRouter uses a credit system:- 1 credit = $1 USD
- Purchase credits at openrouter.ai/credits
- Free credits on signup
Cost Estimation
Use the model selector to view pricing before sending:- Select a model
- Hover over the info icon
- View input/output pricing
- Estimate cost: (input_tokens × input_price) + (output_tokens × output_price)
Rate Limits
Rate limits depend on your credit balance and model:- Higher credit balance = higher rate limits
- Free models have stricter limits
- Check limits at openrouter.ai/docs/limits
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:Security Best Practices
OpenRouter vs Direct Providers
Advantages of OpenRouter
✅ Single API key for 100+ models ✅ Automatic provider failover ✅ Unified billing ✅ Model comparison and discovery ✅ Free models availableWhen 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