Documentation Index
Fetch the complete documentation index at: https://docs.standardagentbuilder.com/llms.txt
Use this file to discover all available pages before exploring further.
Enabled when
OPENROUTER_API_KEY is set in your environment.Overview
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
- Typed
providerOptionsfor routing configuration - Provider selection, fallbacks, and price limits
- Zero Data Retention (ZDR) endpoints
- Provider-executed OpenRouter server tools
Installation
npm
pnpm
yarn
Quick Start
agents/models/claude_sonnet.ts
OpenRouter models automatically fetch pricing from the OpenRouter API. You do not need to specify
inputPrice or outputPrice.Provider Factory
Theopenrouter export is a provider factory function:
Model ID Format
OpenRouter uses aprovider/model-name format for model IDs:
| Provider | Example Model ID |
|---|---|
| OpenAI | openai/gpt-5.4 |
| Anthropic | anthropic/claude-sonnet-4.5 |
google/gemini-2.5-pro | |
| Meta | meta-llama/llama-3.3-70b-instruct |
| Mistral | mistralai/mistral-large |
| xAI | x-ai/grok-4 |
Provider Options
Theopenrouter factory includes a typed schema for routing configuration:
Routing Options
All routing options are nested under theprovider key:
| Option | Type | Description |
|---|---|---|
order | string[] | Provider slugs to try in order |
allow_fallbacks | boolean | Allow fallback to other providers (default: true) |
require_parameters | boolean | Only use providers that support all request parameters |
data_collection | 'allow' | 'deny' | Control data storage policies |
zdr | boolean | Restrict to Zero Data Retention endpoints |
only | string[] | Restrict to these providers only |
ignore | string[] | Skip these providers |
sort | string | object | Sort by price, throughput, or latency |
max_price | object | Maximum price constraints |
quantizations | string[] | Allowed quantization levels |
preferred_min_throughput | number | object | Minimum throughput preference |
preferred_max_latency | number | object | Maximum latency preference |
Server Tool Options
OpenRouter server tools are provider-executed tools. Enable the tool names withproviderTools, 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.
Price Limits
Set hard limits on pricing (request fails if no provider meets threshold):Provider Selection
Control which providers handle your requests:Sorting
Sort available providers by different criteria:Zero Data Retention (ZDR)
For sensitive data, restrict to ZDR endpoints:Performance Preferences
Set soft preferences for throughput and latency:Type Safety
TheproviderOptions type is automatically inferred:
Model Capabilities
Set capabilities for proper framework behavior:Environment Setup
Set your OpenRouter API key:.dev.vars
Example Configurations
Budget-Conscious Model
High-Security Configuration
Multi-Provider Fallback
Performance-Optimized
Tool Calling
OpenRouter tool calls are sent with strict function schemas. The provider normalizes object schemas for OpenAI-backed endpoints by listing every object property inrequired, 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.
Provider-Executed Server Tools
The OpenRouter provider exposes these built-in server tools throughgetTools():
| 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 |
openrouter:* tools for both Chat Completions and
Responses requests, and records completed server tool usage through the generic
provider-tool log path.
Generation Metadata
OpenRouter provides additional metadata about request routing that can be fetched after completion:Exports
Next Steps
Models
Learn about model configuration
OpenAI Provider
Direct OpenAI API access
Prompts
Configure prompts with models
defineModel API
Complete API reference