Learning resourcesReviewed · OpenRouter

OpenRouter Agent SDK: Dynamic Parameters for callModel

This is a documentation page for TypeScript developers using the OpenRouter Agent SDK. It shows how to make callModel settings change from turn to turn. It covers one feature with code fragments rather than a full project, and it gives no pricing, install steps or licence. Any callModel parameter (model, temperature, instructions, maxOutputTokens, provider) can be a sync or async function that receives a TurnContext (numberOfTurns, turnRequest, toolCall). The page shows patterns such as upgrading the model after a few turns, adjusting temperature by task type and enabling Anthropic thinking on later turns.

Researched 13 Nov 2026

In short.

This is a single documentation page for developers using the OpenRouter Agent SDK in TypeScript. It explains how to replace fixed callModel settings with functions that are resolved at the start of each turn. It is a focused feature guide made of code fragments, and it gives no install steps, version, pricing or licence. The page states that any callModel parameter can be a function of type (context: TurnContext) => T | Promise<T>. TurnContext has numberOfTurns (1-indexed), turnRequest and toolCall. The page shows five patterns: progressive model upgrade, adaptive temperature, context-aware instructions, dynamic maxOutputTokens and feature flags through the provider option. It also covers combining these with tools, a seven-step execution order, a try/catch fallback, and advice to keep functions pure, cache expensive lookups and use default values. Nothing was run, so every behaviour below is as the page describes it.

Researched and written by an AI model and checked by a second AI model. How it works

The selected scope is exactly one page, [https://openrouter.ai/docs/agent-sdk/call-model/dynamic-parameters.md], captured in full as a single 7,499-byte text file on 13 November 2026. Pages it links to (nextTurnParams, Stop Conditions, Tools and the llms.txt documentation index at [https://openrouter.ai/docs/llms.txt]) are excluded and were not read. The captured file contained no licence, notice, package metadata, pricing or version information. The code was not executed or tested, and the behaviour described is what the page states, not something observed.

The overview

What this resource is

This is the Dynamic Parameters page of the OpenRouter Agent SDK documentation, in the call-model section, at [https://openrouter.ai/docs/agent-sdk/call-model/dynamic-parameters.md]. Its subtitle is 'Use async functions for adaptive model behavior across turns'. It is a Markdown documentation page, not a software package. It begins with a header that points readers to a full documentation index at [https://openrouter.ai/docs/llms.txt].

The code samples import OpenRouter from the package @openrouter/agent, create a client with an API key and call openrouter.callModel(...). The page names no individual author or version. The openrouter.ai domain suggests OpenRouter publishes it, but the page does not say so.

Overall assessment

The page contains a one-sentence statement of the core idea, the function signature, a table of the context fields, several example patterns and the order in which things happen each turn. Our editorial view is that this makes it a clear, compact feature guide, most useful to developers who already use callModel. How long it takes to learn the feature from it was not measured.

It is not a complete reference. It has no installation steps, no SDK version, no pricing, no licence statement and no full runnable project. Several helper names used in the snippets (myTool, fetchUserPreferences, userId, fetchRules and others) are never defined. Editorially, some examples are also rough (see Limitations). Treat it as a starting point, and check details against the SDK version you install.

Who it is for

The page suits TypeScript or JavaScript developers building chat or agent features on OpenRouter with the Agent SDK, especially multi-turn flows that call tools. The page shows these goals: switching from one model to another as a conversation goes on, tuning temperature or output length by task type, and loading business rules into the instructions at run time. The page describes the model switch as starting with a fast model and upgrading to a capable one for complex tasks. It does not compare the prices or sizes of the models it names, so those are unknown.

Beginners can follow the idea, but the page assumes you already know what callModel, tools and a conversation turn are, and it gives no background on them. It is not aimed at people who call OpenRouter through plain HTTP requests or another SDK, because the page covers neither.

What it teaches and what the feature can do

The page says any parameter in callModel can be a function that computes its value from conversation context. Functions may be synchronous or async, so they can fetch data from a database or service before returning a value.

The examples cover five parameters. For model, they switch from openai/gpt-5-nano to openai/gpt-5.2 after a number of turns, or to anthropic/claude-sonnet-4.5 when the serialized turnRequest.input contains the text 'function_call' (the page's code comment calls this 'if tools have been used'). For temperature, they return 1.0, 0.2 or 0.7 depending on keywords found in the serialized turnRequest.input, or 0.7 on the first turn and 0.3 after it. For instructions, they build text from the turn number and optional fetched rules. For maxOutputTokens, they return 200, 500 or 2000 depending on keywords found in the serialized turnRequest.input. For provider, they return an Anthropic thinking setting with type 'enabled' and budgetTokens 1000 after turn 2, and undefined otherwise.

According to the page's table, the TurnContext passed to each function has three properties. numberOfTurns is a number, described as the current turn number, 1-indexed. turnRequest has the type OpenResponsesRequest or undefined and is described as the 'current request object containing messages and model settings'. toolCall has the type OpenResponsesFunctionToolCall or undefined and is described as 'the specific tool call being executed'. The page does not explain exactly when turnRequest or toolCall is populated. It also recommends keeping functions free of side effects, caching expensive lookups and always returning a fallback value.

Using it

What you need

From the examples you need the @openrouter/agent package, an OpenRouter API key (the samples read it from process.env.OPENROUTER_API_KEY) and a TypeScript or JavaScript project. The tool examples also need tools you define yourself. The page does not show how to define one and refers readers to a separate Tools page.

The model names used (openai/gpt-5-nano, openai/gpt-5.2, anthropic/claude-sonnet-4.5) must be available to your account, but the page does not say whether they are or what they cost. It also does not state a minimum Node.js or TypeScript version, a package version, an install command or any account prerequisites. All of these are unknown from this evidence.

How it works

The page says dynamic parameters are resolved at the start of each turn. Its outline of a turn is: 1) resolve all parameter functions with the current TurnContext; 2) build the request with the resolved values; 3) send it to the model; 4) execute tools, if any; 5) check stop conditions; 6) update the TurnContext for the next turn; 7) repeat from step 1.

The table describes numberOfTurns as the current turn number, 1-indexed, and step 6 updates the TurnContext before the next turn. From this you can deduce that a function reading numberOfTurns sees 1 on the first turn and higher numbers on later turns. This was not observed. turnRequest has the type OpenResponsesRequest or undefined. The page does not explain what it contains at the moment parameters are resolved, or when it is undefined.

The keyword examples run JSON.stringify on turnRequest?.input, lowercase the result and search that text for substrings. The variable is named lastMessage, but the code searches the whole serialized input and does not pick out the latest message.

The page lists toolCall as 'the specific tool call being executed', but none of its examples use it. It does not explain when toolCall is populated for parameters resolved at the start of a turn, so that behaviour is unclear from this page.

Setup

There is nothing to install from this page itself, and it gives no install command. The setup it implies is: import OpenRouter from '@openrouter/agent', create new OpenRouter({ apiKey: process.env.OPENROUTER_API_KEY }), then call openrouter.callModel with a function in place of a fixed value for any parameter.

The page does not describe package installation, authentication beyond the environment-variable pattern or project configuration. Check the SDK's own documentation for those. The page itself points to [https://openrouter.ai/docs/llms.txt] as the documentation index.

Worked example from the page

The simplest example is model selection by turn count. The call passes model: (ctx) => ctx.numberOfTurns > 3 ? 'openai/gpt-5.2' : 'openai/gpt-5-nano', input: 'Hello!' and tools: [myTool]. The example requests openai/gpt-5-nano on turns 1–3 and openai/gpt-5.2 from turn 4. The page's Progressive Model Upgrade section describes this kind of switch as starting with a fast model and upgrading to a capable model for complex tasks. The page does not give the comparative prices or sizes of these models, so those are unknown.

A second example uses an async function: temperature: async (ctx) => { const prefs = await fetchUserPreferences(userId); return prefs.preferredTemperature ?? 0.7; }. Here the value comes from user preferences, with 0.7 as the fallback. fetchUserPreferences and userId are placeholders you must supply.

This describes the page's code, not a result. Nothing was run, so output, latency and the models' actual behaviour are unknown.

Assessment & evidence

Limitations and gaps

The snippets are fragments. Several require helpers your application must define (myTool, analysisTool, searchTool, helpTool, userId, fetchUserPreferences, fetchBusinessRules, fetchRules, fetchExpensiveRules, getPreferredModel). Only the first snippet shows the openrouter client being created, so the others rely on that earlier setup. The caching example omits the model parameter, and whether that stops it from running is unknown from this page. No code was executed.

Error behaviour is only partly covered. The page recommends a try/catch inside async functions with a fallback value. It does not say what the SDK does if a function throws or rejects, whether there is a timeout, or whether a function can be called more than once per turn. It says 'any parameter' can be a function, but it only shows model, temperature, instructions, maxOutputTokens and provider. It does not list the allowed return types for each parameter.

In our assessment, some examples are rough. The keyword checks serialize turnRequest.input with JSON.stringify and match substrings such as 'code', 'creative' or 'function_call' anywhere in that text. This may match unrelated text and is a crude way to classify a task. The 'Keep Functions Pure' snippet uses the model names 'gpt-4' and 'gpt-4o-mini' without the provider prefix used elsewhere on the page ('openai/gpt-5-nano'). The caching example stores one module-level value with no expiry or per-user key, which would be wrong if the rules differ by user or change over time. The provider example shows an Anthropic-specific thinking option, and the page does not explain how that option applies to other providers.

The page does not discuss security, the privacy of data your parameter functions fetch, rate limits, or how this feature interacts with streaming or the returned result object. No behaviour was tested.

Why this assessment

The page teaches one named feature of an SDK, so it is best described as a learning resource, not a tool or library in itself. Its claims come directly from a single vendor-style documentation page. That makes the described behaviour (functions receive a TurnContext, parameters resolve at the start of each turn, the seven-step order) first-hand statements of intended behaviour, but they were not confirmed by running the SDK.

Confidence is high about what the page says and low about anything it leaves out, such as versions, error handling, licence and cost. Where the page is silent, this report says unknown instead of filling the gap.

Alternatives and related options

The simplest alternative inside the same SDK is to pass fixed values to callModel, which is easier to reason about when you do not need behaviour to change between turns. The page itself points to three related pages: nextTurnParams (tool-driven parameter modification) at [https://openrouter.ai/docs/agent-sdk/call-model/next-turn-params.md], Stop Conditions (dynamic execution control) at [https://openrouter.ai/docs/agent-sdk/call-model/stop-conditions.md] and Tools (multi-turn orchestration) at [https://openrouter.ai/docs/agent-sdk/call-model/tools.md]. Their content was not reviewed here.

Outside this SDK, you could write your own loop around a model API, or use another agent framework, to change settings between turns. This page does not compare those options, so how they differ in effort or capability is not assessed.

Evidence base

The report rests on one captured file: the complete text of the Dynamic Parameters page (7,499 bytes), retrieved on 13 November 2026 at 10:08 UTC from [https://openrouter.ai/docs/agent-sdk/call-model/dynamic-parameters.md].

Some statements describe what the page documents: what the feature does, its signature, the TurnContext fields and the execution order. Others are editorial assessments, such as judgements about clarity, the roughness of some examples and who the page suits. A few points are deductions from the page's table and execution order rather than direct statements, such as how numberOfTurns changes between turns.

No source code for the SDK, release notes, package registry entry, licence file, pricing page or running system was examined. Claims about real-world behaviour, performance, availability of the named models and cost are therefore unverified.

Access & freshness

Costs

The page states no prices, plans, free tier or usage limits. The cost of the Agent SDK, of an OpenRouter account and of the named models is therefore unknown from this evidence. The examples use an API key and call hosted models, so OpenRouter or the underlying providers may bill for usage. The amounts and terms are not on this page.

Dynamic settings change what each turn requests; their effect on charges is unknown because this page supplies no pricing. For example, a function can choose a different model, a larger maxOutputTokens value or an Anthropic thinking setting with budgetTokens on later turns. Async parameter functions that call your own database or other services may also add costs and latency of their own. The page does not quantify either.

Rights and reuse

The captured page contains no licence, copyright notice or terms of use for the documentation text, the code snippets or the SDK. Reuse and redistribution rights are therefore unknown from this evidence, and no licence file was captured with it.

Documentation is evidently meant to be read and used as a guide for writing your own code from the described pattern. Whether you may copy the page or its snippets into another publication is a separate question this evidence does not answer.

Freshness

The page shows no publication date, last-updated date, SDK version or changelog. The only known date is the retrieval date, 13 November 2026. The examples name openai/gpt-5.2, openai/gpt-5-nano and anthropic/claude-sonnet-4.5. These model IDs appear in the captured page; their availability when written, when captured or now is not established.

Whether the SDK's behaviour or option names have changed since the page was written is unknown. Check the version of @openrouter/agent you install against the current documentation.

Suggested next steps

If you already use callModel, try turning one static value into a function (model or temperature is the easiest). Always return a fallback value, and log what the function returns on each turn while you check that it behaves as you expect. Confirm that the model IDs you use appear in your OpenRouter account, since the page gives no guarantee.

Before relying on it in production, test what happens when a parameter function throws or is slow, because the page does not specify this. Read the linked Stop Conditions and Tools pages, since a multi-turn tool loop can run several model calls. Find the SDK's pricing, install steps and licence from sources other than this page. Avoid copying the keyword-matching and shared-cache snippets as they stand; use more reliable task detection and per-user data handling of your own.

Evidence for this report

selected-page.txtselected · checked 2026-11-13