The @standardagents/openrouter package provides the OpenRouter provider factory for Standard Agents. OpenRouter is a multi-provider gateway that routes requests to various LLM providers (OpenAI, Anthropic, Google, Meta, and more) through a single API.
Key Features
Access to 200+ models from multiple providers
Automatic pricing data fetched from OpenRouter API
The openrouter export is a provider factory function:
import { openrouter } from '@standardagents/openrouter';defineModel({ name: 'my-model', provider: openrouter, // Pass the factory, not a string model: 'anthropic/claude-sonnet-4',});
The openrouter factory includes a typed schema for routing configuration:
import { defineModel } from '@standardagents/spec';import { openrouter } from '@standardagents/openrouter';export default defineModel({ name: 'claude-secure', provider: openrouter, model: 'anthropic/claude-sonnet-4', providerOptions: { provider: { zdr: true, // Zero Data Retention only: ['anthropic'], // Only route to Anthropic max_price: { prompt: 5, // Max $5 per million input tokens completion: 25, // Max $25 per million output tokens }, }, },});
OpenRouter server tools are provider-executed tools. Enable the tool names with
providerTools, select them from prompts like normal tools, and pass optional
OpenRouter parameters through providerOptions.serverTools:
serverTools configures native OpenRouter tool parameters only. It is stripped
from the request body after the provider converts selected tools into
openrouter:* tool definitions.
Set hard limits on pricing (request fails if no provider meets threshold):
providerOptions: { provider: { max_price: { prompt: 1, // Max $1 per million input tokens completion: 5, // Max $5 per million output tokens request: 0.01, // Max $0.01 per request image: 0.05, // Max $0.05 per image }, },}
OpenRouter tool calls are sent with strict function schemas. The provider normalizes object schemas for OpenAI-backed endpoints by listing every object property in required, while AgentBuilder still validates the returned tool arguments against the original tool Zod schema before execution.When tools are present, tool_choice: "auto" is omitted because OpenRouter treats that as the default. This keeps endpoints that support tools but do not advertise the separate tool_choice parameter eligible for routing.
The OpenRouter provider exposes these built-in server tools through getTools():
Tool
Native OpenRouter type
Description
web_search
openrouter:web_search
Search the web server-side
web_fetch
openrouter:web_fetch
Fetch and extract URL content server-side
datetime
openrouter:datetime
Resolve current date/time server-side
image_generation
openrouter:image_generation
Generate images server-side
AgentBuilder marks these tools as provider-executed. The OpenRouter provider
translates them to native openrouter:* tools for both Chat Completions and
Responses requests, and records completed server tool usage through the generic
provider-tool log path.