Overview
OpenRouter is a model gateway, not an execution runtime. The model never runs tools itself: it returns atool_calls array, and your
host code executes the tool and feeds the result back. That execution boundary
in your host is exactly where Sigil Open Framework (SOF) belongs. Before you run
any tool call OpenRouter returns, submit it to Sigil Sign /v1/authorize and
block on DENIED.
Because this hooks the execution step rather than any OpenRouter-specific feature,
the same pattern works for every model OpenRouter routes to. Set
framework: 'openrouter' so the intents are tagged correctly in your audit log.
HTTP note: the host may emit typed http only when an OpenRouter tool call includes an explicit valid method. Otherwise submit web_fetch; do not infer GET from a URL alone.
@sigilcore/agent-hooks ships a dedicated OpenRouter export:
createOpenRouterToolGate. It parses tool calls, normalizes function names and
arguments into Sigil intents, and returns rejection context as a tool result.
Use recordOpenRouterModelUsageAndCheckBudget after model responses when your
signed Warrant includes model spend or token caps.
Prerequisites
- A Sigil API key: sigilcore.com/tools/keys
- A signed policy: sigilcore.com/tools/warrant
- An OpenRouter API key
Usage
Run the OpenRouter tool gate on each returned tool call before executing it. Map your function names to Sigil action types and pass the parsed arguments through as intent fields plusmetadata for custom policy rules.
How It Works
createOpenRouterToolGate returns a typed JSON object the
model understands (sigil_decision, sigil_message, sigil_next_steps) as the
tool result, so the agent adjusts instead of blindly retrying. The model never
executes anything: your host remains the single enforcement point.
Notes
- This pattern is provider-agnostic. The same OpenRouter tool gate governs OpenAI, Anthropic, Google, and open-weight models served through OpenRouter.
- For Execution Limits v2 model budgets, call
recordOpenRouterModelUsageAndCheckBudget(response, sigilConfig)after each model response and before the next model step or tool execution. - If you also expose MCP servers to the agent, govern those calls with the Sigil MCP Proxy so MCP tools are authorized at the protocol layer as well.
- For multi-turn loops, the OpenRouter Agent SDK
manages tool execution for you. Run each returned tool call through
createOpenRouterToolGatebefore the host executes the handler.
Configuration
Source
- github.com/Sigil-Core/agent-hooks — TypeScript package, MIT License
- OpenRouter tool calling documentation