Agent skill · software engineering · jeremylongshore
openrouter-function-calling
Implement function/tool calling with OpenRouter models. Use when building
Why this skill is useful
Adds executable scripts for defining and dispatching tool calls across multiple AI models, which are not commonly available in public documentation.
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 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 toolcalls 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 as OPENROUTERAPIKEY — see the openrouter-install-auth skill 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 executetool() dispatcher below stubs getweather and searchdatabase) Instructions 1. Pick a model from the Model Compatibility table that supports the features you need (tool calling, JSON mode, parallel tools). 2. Define your tools as JSON Schema per Basic Tool Calling and send them with toolchoice="auto" (or "required" to force a call, or a specific function name). 3. Read response.choices[0].message.toolcalls — each entry carries function.name and JSON-encoded function.arguments to parse with json.loads(). 4. For agents, wire the Multi-Turn Tool Loop: append the assistant message, execute each tool via executetool(), append role: "tool" results keyed by toolcallid, and loop until the model returns plain text (bounded by maxrounds). 5. Use the TypeScript Tool Calling section for the identical flow in Node — same schema, same toolcalls shape. 6. When you only need structured data (no function execution), skip tools and use Structured Output (JSON Mode) with responseformat={"type": "jsonobject"}. 7. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills jeremylongshore/openrouter-function-calling