AGENT SKILL

openrouter-openai-compat

Leverage OpenRouter's OpenAI API compatibility layer. Use when migrating from OpenAI or maintaining dual compatibility. Trigger with phrases like 'openrouter openai compatible', 'openrouter drop-in', 'openrouter migration from openai', 'openai to openrouter'.

License 许可
MIT
最近更新
2026-05-26
Stars
★ 0
Forks
0

01 前言 Front Matter

name
openrouter-openai-compat
author
Jeremy Longshore <jeremy@intentsolutions.io>
license
MIT
version
1.0.0
description
Leverage OpenRouter's OpenAI API compatibility layer. Use when migrating from OpenAI or maintaining dual compatibility. Trigger with phrases like 'openrouter openai compatible', 'openrouter drop-in', 'openrouter migration from openai', 'openai to openrouter'.
allowed-tools
Read, Write, Edit, Grep
compatible-with
claude-code, codex, openclaw

02 资源文件 5

03 SKILL.md 正文

Openrouter Openai Compat

Overview

This skill explains how to use existing OpenAI SDK code with OpenRouter by changing only the base URL and API key, enabling access to 100+ models with minimal code changes.

Prerequisites

  • Existing OpenAI SDK integration (Python or Node.js)
  • OpenRouter API key

Instructions

  1. Swap the base URL: Change base_url from https://api.openai.com/v1 to https://openrouter.ai/api/v1 in your OpenAI client initialization
  2. Update the API key: Replace your OpenAI key with your OpenRouter sk-or-... key
  3. Update model IDs: Change model names to OpenRouter format (e.g., gpt-4 becomes openai/gpt-4 or use any other provider's model)
  4. Add OpenRouter-specific headers: Optionally set HTTP-Referer and X-Title headers for better analytics tracking in the OpenRouter dashboard
  5. Test compatibility: Run your existing test suite against OpenRouter; most endpoints work identically, but verify edge cases like streaming, tools, and embeddings

Output

  • Existing OpenAI code working through OpenRouter with no logic changes
  • Access to non-OpenAI models (Anthropic, Google, etc.) through the same SDK
  • Side-by-side comparison showing the minimal changes needed

Error Handling

Error Cause Fix
400 unsupported parameter OpenRouter doesn't support a parameter your code sends Remove or conditionally set parameters like logprobs or response_format based on the target model
Different embedding format Embedding endpoints may behave differently Use OpenRouter-specific embedding models or fall back to direct OpenAI for embeddings
Missing organization header OpenRouter doesn't use org-level auth Remove the organization parameter from client initialization

See ${CLAUDE_SKILL_DIR}/references/errors.md for full error reference.

Examples

See ${CLAUDE_SKILL_DIR}/references/examples.md for runnable code samples.

Resources

04 同仓库更多 Skills

SamuelChien
SamuelChien/mega-skills-collection

zustand-store-ts

Create Zustand stores with TypeScript, subscribeWithSelector middleware, and proper state/action separation. Use when building React state management, creating global stores, or implementing reactive state patterns with Zustand.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zustand-store-creator

Zustand Store Creator - Auto-activating skill for Frontend Development. Triggers on: zustand store creator, zustand store creator Part of the Frontend Development skill category.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zero-trust-config-helper

Zero Trust Config Helper - Auto-activating skill for Security Advanced. Triggers on: zero trust config helper, zero trust config helper Part of the Security Advanced skill category.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zapier-integration-helper

Zapier Integration Helper - Auto-activating skill for Business Automation. Triggers on: zapier integration helper, zapier integration helper Part of the Business Automation skill category.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zai-cli

Execute z.AI CLI providing vision, search, reader, and GitHub exploration via CLI and MCP. Use when user needs image/video analysis, OCR, UI-to-code conversion, error diagnosis, real-time web search, web page to markdown extraction, or GitHub code exploration. Trigger with phrases like "analyze this image", "search the web for", "read this page", "explore this repo", or "use zai". Requires Z_AI_API_KEY.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

yt-research

Research competitor YouTube channels, niches, and trending topics for your content strategy. Use this skill whenever the user says "research channels", "analyze competitors", "find trending topics", "niche analysis", "competitive research", "what are other creators doing", "scrape YouTube channels", or wants to understand the competitive landscape for a specific tool or topic area. Use when working with yt research. Trigger with 'yt', 'research'.

★ 0