openrouter-upgrade-migration

Featured

Migrate to OpenRouter from direct provider APIs or upgrade between SDK/model versions. Triggers: 'openrouter migrate', 'openrouter upgrade', 'switch to openrouter', 'migrate from openai to openrouter'.

AI & Automation 2,926 stars 433 forks Updated yesterday MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# OpenRouter Upgrade & Migration ## Current State !`npm list openai 2>/dev/null | head -5` !`pip show openai 2>/dev/null | head -5` ## Overview Migrating to OpenRouter from a direct provider API (OpenAI, Anthropic) is minimal: change `base_url` and `api_key`, add two headers. The OpenAI SDK works natively with OpenRouter. This skill covers migrating from direct APIs, switching between models, upgrading SDK versions, and running comparison tests. ## Migration from Direct OpenAI ```python # BEFORE: Direct OpenAI from openai import OpenAI client = OpenAI(api_key=os.environ["OPENAI_API_KEY"]) response = client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": "Hello"}], max_tokens=200, ) # AFTER: Via OpenRouter (3 lines changed) from openai import OpenAI client = OpenAI( base_url="https://openrouter.ai/api/v1", # ← Changed api_key=os.environ["OPENROUTER_API_KEY"], # ← Changed default_headers={ # ← Added "HTTP-Referer": "https://my-app.com", "X-Title": "my-app", }, ) response = client.chat.completions.create( model="openai/gpt-4o", # ← Add provider prefix messages=[{"role": "user", "content": "Hello"}], max_tokens=200, ) ``` ## Migration from Direct Anthropic ```python # BEFORE: Direct Anthropic SDK import anthropic client = anthropic.Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"]) response = client.messages.create( model="claude-3-5-sonnet-2024...

Details

Author
jeremylongshore
Repository
jeremylongshore/claude-code-plugins-plus-skills
Created
1 years ago
Last Updated
yesterday
Language
Python
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Featured

openrouter-openai-compat

Migrate from OpenAI to OpenRouter with minimal code changes. Use when switching to OpenRouter or maintaining dual compatibility. Triggers: 'openrouter openai compatible', 'openrouter drop-in', 'openai to openrouter', 'openrouter migration'.

2,926 Updated yesterday
jeremylongshore
AI & Automation Listed

anthropic-sdk-via-openrouter

Route Anthropic SDK calls through OpenRouter as a fallback when ANTHROPIC_API_KEY is absent but OPENROUTER_API_KEY is present. Pattern: anthropic.Anthropic(api_key=OPENROUTER_API_KEY, base_url="https://openrouter.ai/api/v1") + provider-prefixed model id "anthropic/claude-sonnet-4.6" (note dots, not dashes). The Anthropic SDK speaks Anthropic Messages API at the base_url; OpenRouter implements that contract at /v1/messages, so the same .messages.create(model=..., tools=..., tool_choice=...) call works without any code change beyond the constructor. Use when: (1) supporting users on Claude Code subscription auth (no direct ANTHROPIC_API_KEY but OPENROUTER_API_KEY available), (2) building any Python tool that uses the Anthropic SDK and wants to support OpenRouter-only environments without rewriting to use the OpenAI SDK or a different API contract, (3) implementing the symmetric fallback to a similar pattern on the OpenAI SDK side.

1 Updated today
MrBinnacle
AI & Automation Featured

clade-migration-deep-dive

Migrate from OpenAI/GPT to Anthropic/Claude — API differences, Use when working with migration-deep-dive patterns. prompt adaptation, SDK swap, and feature mapping. Trigger with "migrate to claude", "openai to anthropic", "switch from gpt to claude", "replace openai with anthropic".

2,926 Updated yesterday
jeremylongshore