openrouter-function-calling
Installation
SKILL.md
OpenRouter Function Calling
Overview
OpenRouter supports OpenAI-compatible tool/function calling across multiple providers. Define tools as JSON Schema, send them with your request, and the model returns structured tool_calls instead of free text. This works with GPT-4o, Claude 3.5, Gemini, and other tool-capable models via the same API. The key difference from direct provider APIs: OpenRouter normalizes the tool calling interface, so the same code works across providers.
Prerequisites
- An OpenRouter API key (
sk-or-v1-...) exported asOPENROUTER_API_KEY— see theopenrouter-install-authskill for setup - Python 3.8+ or Node.js 18+ with the OpenAI SDK (
pip install openai/npm install openai) - A tool-capable model — check the Model Compatibility table below or query
/api/v1/models(e.g.,openai/gpt-4o,anthropic/claude-3.5-sonnet) - Real function implementations to dispatch tool calls to (the
execute_tool()dispatcher below stubsget_weatherandsearch_database)