Sponsored byOutsenseAI that finds your next clients
SponsorGROUOutbound, LinkedIn content and leads for B2B teamsSponsorOutsenseAI that finds your next clientsAd+Your tool hereSeen by people installing AI tools@Weekly picksThe best new tools, one email a week

openrouter-openai-compat

Skill by jeremylongshore

Migrates existing OpenAI SDK code to OpenRouter by changing the base URL and API key. It covers model ID mapping, feature differences, and a dual-provider switch for developers who already use the OpenAI SDK.

  • Score 76
  • 3k stars
  • MIT
  • Updated
Works withClaude CodeClaude apps Antigravity CLI

Install openrouter-openai-compat

Built from the published package, never by AI.

git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace /tmp/tons-of-skills-marketplace && mkdir -p ~/.claude/skills && cp -r /tmp/tons-of-skills-marketplace/skills/.curated/openrouter-openai-compat ~/.claude/skills/openrouter-openai-compat

Run in your terminal. Claude Code loads skills from ~/.claude/skills automatically.

Step-by-step: install openrouter-openai-compat in Claude Code

Skills can run scripts on your machine. Some need an API key: check the README.

About

This agent skill explains how to move existing OpenAI SDK code to OpenRouter. The source says OpenRouter implements the OpenAI Chat Completions API, so changing base_url and api_key is the main step. It also covers prefixing model IDs such as openai/gpt-4o, and lists which features work the same and which differ, such as the organization parameter and limited embeddings.

It describes OpenRouter-only options passed through extra_body, including model fallbacks, provider preferences, and a web search plugin. A Dual-Provider Pattern uses the LLM_PROVIDER environment variable to switch between direct OpenAI and OpenRouter. It is aimed at developers who already use the OpenAI Python or TypeScript SDK and want to switch providers or keep both working.

Written from the project's SKILL.md and checked against it.

What it can do

  • Two-line migrationPoints an existing OpenAI SDK client at OpenRouter by changing base_url and api_key.
  • Model ID mappingShows how OpenAI model names map to provider-prefixed OpenRouter IDs such as openai/o1.
  • Feature compatibility checkLists which features work identically, including streaming, tools, JSON mode, and stop sequences.
  • Difference workaroundsGives workarounds for differences such as the organization parameter, embeddings, and logprobs.
  • Model fallbacksSets an ordered list of models with the fallback route through extra_body.
  • Provider preferencesSets provider order, fallback behaviour, and price sorting through extra_body.
  • Web search pluginEnables the web plugin on a request to add real-time web search.
  • Dual-provider clientUses a create_client function that switches between OpenAI and OpenRouter based on LLM_PROVIDER.

What you need

  • OpenRouter API key set as OPENROUTER_API_KEY
  • Existing OpenAI SDK integration (chat.completions.create)
  • Python 3.8+ with the openai package, or Node.js 18+ with the openai npm package
  • Optional OPENAI_API_KEY for switching back to direct OpenAI

Try asking

  • Migrate my OpenAI chat code to OpenRouter with minimal changes
  • Convert my model names to OpenRouter provider-prefixed IDs
  • Add a create_client function that switches between OpenAI and OpenRouter

Good to know

  • Embeddings have limited support on OpenRouter
  • Fine-tuned models are not directly accessible
  • The organization parameter is not used
  • The Responses API is in beta support

Security check

B
  • Allowed to use Write, Edit without limitsIn SKILL.md

Checked automatically: skills/.curated/openrouter-openai-compat/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work

Inside the skill

Allowed tools: ReadWriteEditGrepBash(python3:*)Bash(node:*)

Alternatives to openrouter-openai-compat

All alternatives →

Compare with agent-reproduce-align, google_contacts or m06-error-handling

openrouter-openai-compat: common questions

Does the migration require a new SDK?

No. The source says you keep the same openai package or npm package you already use, with no new dependency.

Can I use non-OpenAI models through the same code?

Yes. The source says you change the model string to a provider-prefixed ID such as anthropic/claude-3.5-sonnet, and the same client works.

Can I switch back to direct OpenAI later?

Yes. The Dual-Provider Pattern uses the LLM_PROVIDER environment variable to move traffic between direct OpenAI and OpenRouter.

How do I install openrouter-openai-compat?

Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.

Is openrouter-openai-compat free?

The code is published under the MIT licence. The service it connects to may have its own pricing.

Is openrouter-openai-compat safe to use?

It scores 76 of 100. Grades: maintenance A, licence A, quality A. Security check: grade B (allowed to use write, edit without limits). Review the code before you install. How grades work.

What are alternatives to openrouter-openai-compat?

Similar skills: agent-reproduce-align, google_contacts, m06-error-handling, caveman.

openrouter-openai-compat Install

Add to stack

Loading.