LLM ROUTING

Tool calling through OpenRouter: the model proposes, your app executes

In this article
THE QUICK TAKE

A client-side tool call is a structured proposal from the model; your application remains responsible for permission and execution.

Tool calling through OpenRouter lets a model request a function provided by your application. For client tools, the model does not execute that function itself. It returns a structured proposal that your code handles. This distinction matters for database access, calculations and any operation with an external effect.

Start with a read-only function

Use a small function such as reading a prepared GPU inventory record by internal ID. A bounded, read-only example makes it easier to verify the protocol separately from infrastructure changes. Define a clear input schema and a predictable result, including an explicit not-found state.

Keep the function list appropriate to the current user and task. A model’s ability to name an operation does not authorize it. Server-provided platform tools have separate behavior and conditions; do not assume a tutorial for client tools describes those mechanisms as well.

Verify the full execution loop

StageResponsible component
Describe available functionsApplication supplies tool definitions
Propose a function and argumentsModel returns a tool call
Check rights and executeApplication code
Explain the resultA subsequent model response using the tool result

Preserve the identifiers that associate results with calls. If a function fails, return an appropriate structured failure rather than fabricating success. The next model response should reflect what the application actually observed, not what the tool was expected to find.

Check the route and arguments

Tool support depends on the selected model and endpoint. Verify a request containing the required tool definitions, not merely a successful text conversation. Provider-selection settings should reflect mandatory parameters so a fallback does not silently change the integration contract.

Before execution, validate types, allowed values, resource existence and the current user’s permission. Treat model-generated arguments as untrusted input. An inventory lookup should not become a mechanism for reading arbitrary files or requesting an unrestricted database query. Test malformed IDs, missing fields and an unauthorized record alongside a normal case.

Bound loops and external effects

Set limits on the number of tool rounds, total elapsed time and spending. A model can repeatedly request functions without reaching a useful answer. Keep retries of the model request separate from retries of a tool, particularly when the latter can change external state.

For later write operations, use the application’s established approval and idempotency rules. The pilot record should show a permitted call, a rejected call and a handled tool failure. An agentic interface does not itself prove hardware readiness, sustained demand or an approved OpenRouter provider relationship.

Official references: openrouter.ai — tool calling, openrouter.ai — provider selection.

Related guides: Structured output through OpenRouter: when to use a JSON schema, OpenRouter error 429: limits, queues and controlled retries.

← All articles