オプション
家 Skill DevOps と CI/CD openrouter-upgrade-migration

OpenRouter SDK のバージョンを安全に移行・アップグレードします。依存関係の更新や設定の移行時に使用してください。 「openrouter upgrade」、「openrouter migration」、「update openrouter」、「openrouter breaking changes」などのフレーズでトリガーします。

...すべて拡張します
49
更新された時間 2026年7月1日

概要openrouter-upgrade-migration

「openrouter-upgrade-migration 」スキルは、OpenRouter SDKのバージョンアップおよび移行プロセスを効率化するために設計されています。このスキルは、依存関係の更新時に直面する一般的な課題に対処し、開発者が互換性を損なう変更を引き起こすことなく、安全にバージョン更新を実施し、設定の移行を管理できるようにします。 このスキルは、定期的な更新や、新しいSDKバージョンにおける互換性を損なう変更への対応を行う際に特に有用であり、アップグレード中に互換性を維持するための体系的なアプローチを提供します。

このスキルは、前提条件の検証から統合の成功確保に至るまで、SDKバージョンのアップグレードを管理するための包括的なツールセットを提供します。 主な機能には、設定の容易な移行、互換性を損なう変更への対応、移行後のAPI接続性の検証などが含まれます。バージョン管理システムとの連携も良好で、問題が発生した場合のロールバック機能も備えています。テストと監視のための明確な手順により、このスキルは、更新されたOpenRouter統合が本番環境において期待どおりに機能し続けることを保証します。

主にOpenRouterを利用する開発者やチームを対象としており、SDKの更新を管理する方や、新バージョンでの互換性を損なう変更に直面している方に最適です。 また、本番システムの保守を担当するDevOpsエンジニアにとっても有益です。変更内容を追跡しつつ、依存関係や設定を安全にアップグレードできるためです。このツールは、OpenRouter SDKのバージョンを更新または移行する際、安定性を確保し、ダウンタイムを最小限に抑えるのに役立ちます。

よくある質問

openrouter-upgrade-migration スキルをどのように起動しますか?

「openrouter upgrade」、「openrouter migration」、「update openrouter」、または「openrouter breaking changes」といったフレーズを使用して、このスキルをトリガーできます。

このスキルを使用するための前提条件は何ですか?

前提条件として、既存のOpenRouter統合環境と、ロールバック機能を確保するためのバージョン管理システムが整備されている必要があります。

このスキルは、すべてのバージョンの OpenRouter SDK と互換性がありますか?

このスキルは OpenRouter SDK のバージョンアップおよび移行を目的として設計されていますが、作業を進める前に、お使いの SDK バージョンとの互換性を確認することが重要です。

移行に失敗した場合はどうすればよいですか?

移行に失敗した場合は、『{baseDir}/references/errors.md』にあるエラー処理に関するドキュメントを参照し、問題の診断と解決を行ってください。

GitHubで見る

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

# BEFORE: Direct OpenAIfrom openai import OpenAIclient = 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 OpenAIclient = 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

# BEFORE: Direct Anthropic SDKimport anthropicclient = anthropic.Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])response = client.messages.create(    model="claude-3-5-sonnet-20241022",    max_tokens=200,    messages=[{"role": "user", "content": "Hello"}],)content = response.content[0].text# AFTER: Via OpenRouter (using OpenAI SDK instead of Anthropic SDK)from openai import OpenAIclient = OpenAI(    base_url="https://openrouter.ai/api/v1",    api_key=os.environ["OPENROUTER_API_KEY"],    default_headers={        "HTTP-Referer": "https://my-app.com",        "X-Title": "my-app",    },)response = client.chat.completions.create(    model="anthropic/claude-3.5-sonnet",  # OpenRouter model ID    messages=[{"role": "user", "content": "Hello"}],    max_tokens=200,)content = response.choices[0].message.content  # OpenAI response format

TypeScript Migration

// BEFORE: Direct OpenAIimport OpenAI from "openai";const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });// AFTER: Via OpenRouterconst client = new OpenAI({  baseURL: "https://openrouter.ai/api/v1",  apiKey: process.env.OPENROUTER_API_KEY,  defaultHeaders: {    "HTTP-Referer": "https://my-app.com",    "X-Title": "my-app",  },});// Change model from "gpt-4o" to "openai/gpt-4o"

Migration Checklist

MIGRATION_CHECKLIST = {    "config": [        "base_url changed to https://openrouter.ai/api/v1",        "API key changed to OPENROUTER_API_KEY (sk-or-v1-...)",        "HTTP-Referer and X-Title headers added",        "Model IDs prefixed with provider/ (e.g., openai/gpt-4o)",    ],    "code": [        "All client initialization updated",        "Model IDs updated in all routes/configs",        "Error handling covers OpenRouter-specific codes (402, 408)",        "Streaming still works with new endpoint",        "Tool/function calling still works",    ],    "testing": [        "Same prompts produce comparable quality output",        "Latency within acceptable range (expect +50-100ms)",        "Token counts match expectations",        "Cost tracking updated for OpenRouter pricing",        "Fallback chain tested",    ],    "operations": [        "Credit balance sufficient for expected usage",        "Per-key credit limits configured",        "Monitoring updated to track OpenRouter metrics",        "Alerting on new error codes (402, 408)",        "Rollback plan documented",    ],}

Model ID Migration Map

Direct ProviderOpenRouter ID
gpt-4oopenai/gpt-4o
gpt-4o-miniopenai/gpt-4o-mini
o1openai/o1
claude-3-5-sonnet-20241022anthropic/claude-3.5-sonnet
claude-3-haiku-20240307anthropic/claude-3-haiku
gemini-2.0-flashgoogle/gemini-2.0-flash-001
llama-3.1-8b-instructmeta-llama/llama-3.1-8b-instruct

Comparison Test Script

def compare_migration(prompt: str, old_model: str, new_model: str):    """Run same prompt through old and new configurations to compare."""    import time    # New: OpenRouter    or_client = OpenAI(        base_url="https://openrouter.ai/api/v1",        api_key=os.environ["OPENROUTER_API_KEY"],        default_headers={"HTTP-Referer": "https://my-app.com", "X-Title": "migration-test"},    )    start = time.monotonic()    or_response = or_client.chat.completions.create(        model=new_model,        messages=[{"role": "user", "content": prompt}],        max_tokens=200, temperature=0,    )    or_latency = (time.monotonic() - start) * 1000    return {        "openrouter": {            "model": or_response.model,            "content": or_response.choices[0].message.content[:100],            "tokens": or_response.usage.prompt_tokens + or_response.usage.completion_tokens,            "latency_ms": round(or_latency),        },    }# Testresult = compare_migration(    "What is 2+2?",    old_model="gpt-4o",    new_model="openai/gpt-4o",)print(json.dumps(result, indent=2))

Feature Flag Migration

import osUSE_OPENROUTER = os.environ.get("USE_OPENROUTER", "false").lower() == "true"def get_llm_client():    """Feature flag for gradual migration."""    if USE_OPENROUTER:        return OpenAI(            base_url="https://openrouter.ai/api/v1",            api_key=os.environ["OPENROUTER_API_KEY"],            default_headers={"HTTP-Referer": "https://my-app.com", "X-Title": "my-app"},        )    else:        return OpenAI(api_key=os.environ["OPENAI_API_KEY"])def get_model_id(model: str) -> str:    """Map model IDs based on current backend."""    if USE_OPENROUTER and "/" not in model:        MODEL_MAP = {"gpt-4o": "openai/gpt-4o", "gpt-4o-mini": "openai/gpt-4o-mini"}        return MODEL_MAP.get(model, f"openai/{model}")    return model

Error Handling

ErrorCauseFix
401 after migrationUsing old API key with new base_urlUpdate to OpenRouter API key (sk-or-v1-...)
model_not_foundMissing provider prefixAdd openai/ or anthropic/ prefix to model ID
Different response formatSwitched from Anthropic SDK to OpenAI SDKUpdate response parsing: .choices[0].message.content
Higher latencyOpenRouter proxy overheadExpected: +50-100ms; use streaming to mask it

Enterprise Considerations

  • Migration from direct provider to OpenRouter requires only 3 lines of code change
  • Use feature flags for gradual migration (10% -> 50% -> 100%)
  • Run comparison tests on critical prompts before full migration
  • OpenRouter adds ~50-100ms overhead; use streaming to mask perceived latency
  • Keep direct provider keys active during migration for quick rollback
  • Update monitoring dashboards for OpenRouter-specific metrics (generation_id, provider used)

References

  • Examples | Errors
  • Quickstart | OpenAI Compatibility

すべてのファイル

1件のファイル

openrouter-upgrade-migrationをインストール

スキルファイルをダウンロードし、.claude/skills/ ディレクトリに解凍してください。

ZIPをダウンロード

リポジトリをクローンし、スキルファイルをプロジェクトにコピーしてください。

git clone https://github.com/jeremylongshore/claude-code-plugins-plus-skills/blob/main/plugins/saas-packs/openrouter-pack/skills/openrouter-upgrade-migration/SKILL.md # Copy SKILL.md to your .claude/skills/ directory

コピー コピー
クイックセットアップ: skill フォルダを .claude/skills/ にコピーしてください。Claude が自動的にスキルを検出して使用します。

関連スキル

Verification & Quality Assurance
更新された時間 2026年6月29日
klingai-upgrade-migration
更新された時間 2026年7月3日
base44-cli
更新された時間 2026年6月29日
Railway CLI Management
更新された時間 2026年7月2日
OR