OpenRouter Configuration Examples for Claude Code
Tags: openrouter configuration examples kimi-k2 free-models
This guide provides practical configuration examples for using Claude Code with OpenRouter across different scenarios and use cases.
Table of Contents
- Basic Configurations
- Development Workflows
- Team Configurations
- Cost-Optimized Setups
- Advanced Scenarios
- Project Templates
Quick Start: Which Example Should I Use?
This page contains many examples. Use this guide to find the right one for your needs quickly.
-
Just starting out?
- Use the Minimal Setup to get up and running in seconds.
-
Working on a team?
- Jump to the Team Configurations to see how to enforce conventions and share settings.
-
Worried about cost?
- See our Cost-Optimized Setups, including how to use only free models.
-
Integrating with CI/CD?
- Check the CI/CD Integration example for using Claude Code in your GitHub Actions.
-
Need a project template?
- We have templates for Next.js and Python FastAPI to get you started with best practices.
Basic Configurations
Minimal Setup - Just Get Started
# ~/.zshrc or ~/.bashrc
export ANTHROPIC_BASE_URL="https://cc.yovy.app"
export ANTHROPIC_API_KEY="sk-or-v1-your-openrouter-key"
# That's it! Claude Code will now use OpenRouterSingle Model Configuration
# Use Kimi K2 exclusively
export ANTHROPIC_BASE_URL="https://cc.yovy.app"
export ANTHROPIC_API_KEY="sk-or-v1-your-key"
export ANTHROPIC_MODEL="moonshotai/kimi-k2"Multi-Model Setup
# Different models for different tasks
export ANTHROPIC_BASE_URL="https://cc.yovy.app"
export ANTHROPIC_API_KEY="sk-or-v1-your-key"
# Main model for complex tasks
export ANTHROPIC_MODEL="moonshotai/kimi-k2"
# Fast model for simple tasks
export ANTHROPIC_SMALL_FAST_MODEL="google/gemini-2.5-flash"
# Background tasks (indexing, etc)
export ANTHROPIC_BACKGROUND_MODEL="meta-llama/llama-3.1-8b"Development Workflows
Frontend Development Setup
# Optimized for React/Vue/Angular development
alias claude-frontend='ANTHROPIC_BASE_URL="https://cc.yovy.app" \
ANTHROPIC_API_KEY="$OPENROUTER_KEY" \
ANTHROPIC_MODEL="moonshotai/kimi-k2" \
ANTHROPIC_SYSTEM_PROMPT="You are an expert frontend developer specializing in React, TypeScript, and modern CSS. Focus on component architecture, performance, and accessibility." \
claude'Backend API Development
# Optimized for backend development
alias claude-backend='ANTHROPIC_BASE_URL="https://cc.yovy.app" \
ANTHROPIC_API_KEY="$OPENROUTER_KEY" \
ANTHROPIC_MODEL="deepseek/deepseek-r1" \
ANTHROPIC_SYSTEM_PROMPT="You are an expert backend developer specializing in Node.js, databases, and API design. Focus on security, scalability, and clean architecture." \
claude'Full-Stack TypeScript
.claude/settings.json:
{
"api_base_url": "https://cc.yovy.app",
"model": "moonshotai/kimi-k2",
"permission_mode": "cautious",
"system_prompt": "You are an expert TypeScript developer working on a full-stack application. Always use TypeScript, implement proper error handling, and follow clean code principles.",
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "npx prettier --write $CLAUDE_FILE_PATHS && npx eslint --fix $CLAUDE_FILE_PATHS",
"timeout": 15000
}
]
}
]
}
}Data Science Setup
# ~/.claude/ds-config.json
{
"api_base_url": "https://cc.yovy.app",
"model": "moonshotai/kimi-k2",
"system_prompt": "You are a data scientist expert in Python, pandas, numpy, and machine learning. Always include data validation and visualization.",
"working_directory": "~/data-projects",
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "black $CLAUDE_FILE_PATHS && flake8 $CLAUDE_FILE_PATHS",
"timeout": 10000
}
]
}
]
}
}
# Usage
alias claude-ds='claude --settings ~/.claude/ds-config.json'Team Configurations
Shared Team Settings
project/.claude/settings.json:
{
"api_base_url": "https://cc.yovy.app",
"model": "moonshotai/kimi-k2",
"permission_mode": "cautious",
"max_turns": 5,
"team_conventions": {
"language": "TypeScript",
"style_guide": "https://github.com/airbnb/javascript",
"commit_format": "conventional",
"test_framework": "vitest"
},
"hooks": {
"PreToolUse": [
{
"matcher": "Write|Edit|MultiEdit",
"hooks": [
{
"type": "command",
"command": "./scripts/validate-code-standards.sh",
"timeout": 30000
}
]
}
],
"Stop": [
{
"matcher": ".*",
"hooks": [
{
"type": "command",
"command": "./scripts/generate-summary.sh",
"timeout": 10000
}
]
}
]
}
}Individual Developer Overrides
project/.claude/settings.local.json:
{
"api_key": "sk-or-v1-personal-key",
"model": "google/gemini-2.5-flash",
"developer_name": "John Doe",
"preferred_tools": {
"formatter": "prettier",
"linter": "eslint",
"test_runner": "vitest"
}
}Junior Developer Config
{
"api_base_url": "https://cc.yovy.app",
"model": "moonshotai/kimi-k2",
"permission_mode": "strict",
"max_turns": 3,
"system_prompt": "Provide detailed explanations for code changes. Include learning resources and best practice references. Ask for confirmation before major changes.",
"educational_mode": true,
"hooks": {
"PreToolUse": [
{
"matcher": "Bash|Write|Edit",
"hooks": [
{
"type": "command",
"command": "echo 'Change requested: Review before proceeding' && read -p 'Continue? (y/n): ' confirm && [[ $confirm == 'y' ]]",
"timeout": 300000
}
]
}
]
}
}Cost-Optimized Setups
Free Tier Only
# Use only free models
export ANTHROPIC_BASE_URL="https://cc.yovy.app"
export ANTHROPIC_API_KEY="sk-or-v1-your-key"
# Free models rotation
export ANTHROPIC_MODEL="moonshotai/kimi-k2"
export ANTHROPIC_FALLBACK_MODELS="google/gemini-2.0-flash-thinking-exp-1219:free,meta-llama/llama-3.1-8b-instruct:free"Budget-Conscious Development
{
"api_base_url": "https://cc.yovy.app",
"cost_controls": {
"daily_limit": 1.00,
"model_preferences": [
{
"task": "simple_edits",
"model": "google/gemini-2.5-flash",
"max_cost": 0.10
},
{
"task": "complex_analysis",
"model": "moonshotai/kimi-k2",
"max_cost": 0.00
},
{
"task": "code_review",
"model": "meta-llama/llama-3.1-8b",
"max_cost": 0.05
}
]
}
}Zero-Cost Development
#!/bin/bash
# free-claude.sh - Use only free models
export ANTHROPIC_BASE_URL="https://cc.yovy.app"
export ANTHROPIC_API_KEY="$OPENROUTER_KEY"
# Cycle through free models
MODELS=(
"moonshotai/kimi-k2"
"google/gemini-2.0-flash-thinking-exp-1219:free"
"meta-llama/llama-3.1-8b-instruct:free"
"nousresearch/hermes-3-llama-3.1-8b:free"
)
# Random selection
export ANTHROPIC_MODEL=${MODELS[$RANDOM % ${#MODELS[@]}]}
echo "Using free model: $ANTHROPIC_MODEL"
claude "$@"Advanced Scenarios
CI/CD Integration
.github/workflows/claude-review.yml:
name: Claude Code Review
on: [pull_request]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Claude Code
run: |
# Install Claude Code
npm install -g @anthropic-ai/claude-code
# Configure for CI
echo "ANTHROPIC_BASE_URL=https://cc.yovy.app" >> $GITHUB_ENV
echo "ANTHROPIC_API_KEY=${{ secrets.OPENROUTER_KEY }}" >> $GITHUB_ENV
echo "ANTHROPIC_MODEL=google/gemini-2.5-flash" >> $GITHUB_ENV
- name: Run Code Review
run: |
claude review \
--changes "${{ github.event.pull_request.diff_url }}" \
--output review.md
- name: Post Review
uses: actions/github-script@v6
with:
script: |
const review = require('fs').readFileSync('review.md', 'utf8');
github.rest.pulls.createReview({
...context.repo,
pull_number: context.issue.number,
body: review,
event: 'COMMENT'
});Docker Development Environment
Dockerfile:
FROM node:20-alpine
# Install Claude Code
RUN npm install -g @anthropic-ai/claude-code
# Configure OpenRouter
ENV ANTHROPIC_BASE_URL="https://cc.yovy.app"
ENV ANTHROPIC_MODEL="moonshotai/kimi-k2"
# Add configuration
COPY .claude/settings.json /root/.claude/settings.json
# Custom entrypoint
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["claude"]docker-entrypoint.sh:
#!/bin/sh
# Pass API key from host
export ANTHROPIC_API_KEY="${OPENROUTER_API_KEY}"
# Execute claude with all arguments
exec "$@"Multi-Project Management
# ~/.claude/project-configs.sh
function claude-project() {
local project=$1
shift # Remove first argument
case $project in
frontend)
ANTHROPIC_MODEL="moonshotai/kimi-k2" \
ANTHROPIC_SYSTEM_PROMPT="Frontend React expert" \
claude "$@"
;;
backend)
ANTHROPIC_MODEL="deepseek/deepseek-r1" \
ANTHROPIC_SYSTEM_PROMPT="Backend Node.js expert" \
claude "$@"
;;
mobile)
ANTHROPIC_MODEL="google/gemini-2.5-flash" \
ANTHROPIC_SYSTEM_PROMPT="React Native expert" \
claude "$@"
;;
*)
echo "Unknown project: $project"
echo "Available: frontend, backend, mobile"
return 1
;;
esac
}
# Usage: claude-project frontend "implement user authentication"Project Templates
Next.js Starter
.claude/settings.json:
{
"api_base_url": "https://cc.yovy.app",
"model": "moonshotai/kimi-k2",
"project_type": "nextjs",
"conventions": {
"routing": "app-router",
"styling": "tailwind",
"components": "server-first",
"data_fetching": "server-components"
},
"system_prompt": "You are working on a Next.js 14+ project using App Router, Server Components, and Tailwind CSS. Follow Next.js best practices and conventions.",
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "npm run lint:fix && npm run type-check",
"timeout": 30000
}
]
}
]
}
}Python FastAPI
.claude/settings.json:
{
"api_base_url": "https://cc.yovy.app",
"model": "moonshotai/kimi-k2",
"project_type": "fastapi",
"conventions": {
"python_version": "3.11+",
"type_hints": "required",
"async": "preferred",
"testing": "pytest"
},
"system_prompt": "You are working on a FastAPI project. Use type hints, async/await, Pydantic models, and follow FastAPI best practices.",
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "black $CLAUDE_FILE_PATHS && mypy $CLAUDE_FILE_PATHS",
"timeout": 20000
}
]
}
]
}
}Monorepo Setup
.claude/settings.json:
{
"api_base_url": "https://cc.yovy.app",
"model": "moonshotai/kimi-k2",
"monorepo": {
"type": "pnpm-workspace",
"packages": {
"apps/*": {
"model": "moonshotai/kimi-k2",
"context": "application"
},
"packages/*": {
"model": "google/gemini-2.5-flash",
"context": "library"
},
"docs/*": {
"model": "meta-llama/llama-3.1-8b",
"context": "documentation"
}
}
},
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "pnpm run lint:affected && pnpm run test:affected",
"timeout": 60000
}
]
}
]
}
}Quick Reference
Environment Variables Cheatsheet
# Essential
export ANTHROPIC_BASE_URL="https://cc.yovy.app"
export ANTHROPIC_API_KEY="sk-or-v1-your-key"
# Model Selection
export ANTHROPIC_MODEL="moonshotai/kimi-k2"
export ANTHROPIC_SMALL_FAST_MODEL="google/gemini-2.5-flash"
export ANTHROPIC_BACKGROUND_MODEL="meta-llama/llama-3.1-8b"
# Performance
export ANTHROPIC_TIMEOUT="120000"
export ANTHROPIC_MAX_RETRIES="3"
# Behavior
export ANTHROPIC_TEMPERATURE="0.3"
export ANTHROPIC_MAX_TOKENS="4096"
export ANTHROPIC_SYSTEM_PROMPT="Your custom prompt"
# Debug
export CLAUDE_DEBUG="true"
export Y_ROUTER_DEBUG="true"Common Aliases
# Add to ~/.zshrc or ~/.bashrc
# Quick model switches
alias claude-free='ANTHROPIC_MODEL="moonshotai/kimi-k2" claude'
alias claude-fast='ANTHROPIC_MODEL="google/gemini-2.5-flash" claude'
alias claude-smart='ANTHROPIC_MODEL="deepseek/deepseek-r1" claude'
# Task-specific
alias claude-test='ANTHROPIC_SYSTEM_PROMPT="Write comprehensive tests" claude'
alias claude-review='ANTHROPIC_SYSTEM_PROMPT="Review code for bugs and improvements" claude'
alias claude-docs='ANTHROPIC_SYSTEM_PROMPT="Write clear documentation" claude'
# Cost tracking
alias claude-cost='echo "Today: $(curl -s https://openrouter.ai/api/v1/usage -H "Authorization: Bearer $ANTHROPIC_API_KEY" | jq .daily_cost)"'