Agent skill · software engineering · jeremylongshore
openrouter-openai-compat
Migrate from OpenAI to OpenRouter with minimal code changes. Use when
Why this skill is useful
Provides specific migration instructions and model ID mappings for transitioning from OpenAI to OpenRouter, which the AI wouldn't reliably generate on its own.
What it needs
Requires node, python installed locally. Requires openrouter account access. About 5k tokens when loaded. Last updated 2026-08-07. 2,604 stars on the source repository.
What this skill does
OpenRouter OpenAI Compatibility Overview OpenRouter implements the OpenAI Chat Completions API specification (/v1/chat/completions). Existing OpenAI SDK code works with OpenRouter by changing two values: baseurl and apikey. This gives you access to 400+ models from all providers through the same SDK interface. Prerequisites An existing OpenAI SDK integration to migrate — Python or TypeScript code calling chat.completions.create An OpenRouter API key exported as OPENROUTERAPIKEY — see the openrouter-install-auth skill for setup Python 3.8+ with the openai package, or Node.js 18+ with the openai npm package — the same SDK you already use, no new dependency Optionally keep OPENAIAPIKEY exported too, so the Dual-Provider Pattern can switch back to direct OpenAI Instructions 1. Apply The Two-Line Migration: point baseurl at https://openrouter.ai/api/v1 and swap apikey to OPENROUTERAPIKEY; optionally add the HTTP-Referer / X-Title headers for app attribution. 2. Prefix every model string per Model ID Mapping — gpt-4o becomes openai/gpt-4o, o1 becomes openai/o1 — and try a non-OpenAI model (anthropic/claude-3.5-sonnet) through the same client. 3. Confirm your feature usage against What Works Identically (streaming, tools, JSON mode, stop, n) and adjust per What Differs — remove the organization param, plan around limited embeddings, and check logprobs support per model via /api/v1/models. 4. Layer in OpenRouter-Only Features through extrabody: ordered fallback model lists with "route": "fallback", provider preferences with sort: "price", or the plugins: [{"id": "web"}] web-search plugin. 5. Keep the migration reversible with the Dual-Provider Pattern — createclient() switches between direct OpenAI and OpenRouter off the LLMPROVIDER environment variable. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills jeremylongshore/openrouter-openai-compat