LLM ROUTING

Keep an OpenRouter tool conversation portable across eligible routes

In this article
THE QUICK TAKE

A tool result is meaningful only in relation to the call that requested it, so routing compatibility must preserve the conversation’s structured relationships.

An application often sends another inference request after executing a client tool. OpenRouter can route that request across eligible providers, but the client still owns coherent conversation history. The tool-calling documentation makes the sequence explicit: request a tool, execute it in the application and return the result through the matching protocol structure.

Preserve the original assistant request

For a hypothetical catalog lookup, keep the assistant record that requested the lookup, including its call identifier and arguments. The result should not appear as an unexplained paragraph detached from the operation. The model needs the relationship between question, proposed call and observation. Preserving the original request also lets the application audit whether it executed the requested operation or substituted something else during validation.

Return the result with the matching identity

Responses uses function-call output items associated with their call identifier. Chat Completions uses tool messages tied to the requested tool call. Use the shape documented for the active endpoint. If the model proposed several lookups, each returned observation must be matched to the correct request. Array order alone is a fragile substitute when independent operations can finish in a different order.

Keep tool support in the eligible route

A route used for continuation must support the tool workflow the client is sending. Consult model and endpoint capabilities and apply required-parameter controls where the contract needs them. A provider switch should not silently convert a structured tool history into a text-only approximation. The shared interface reduces adaptation work, but it does not eliminate the need to verify the specific capabilities required by the conversation.

Preserve dependent reasoning state when required

Some reasoning-capable workflows return continuation material alongside tool requests. Preserve it according to the relevant reasoning documentation rather than stripping everything except the visible function call. Keep opaque fields unchanged. For the catalog example, the application adds the actual lookup result while retaining the protocol items the model returned. A simplified chat transcript may be suitable for display but insufficient for the next inference request.

Test a routed continuation as a whole

Use a harmless catalog fixture to test the first tool request, application result and final response. Exercise the client’s serialization boundary, including multiple calls if the product supports them. Confirm that an execution error is represented as such instead of a successful empty lookup. The test verifies the application’s history handling; it should not claim that every provider or future model version behaves identically without its own current compatibility evidence.

Documentation and further study

Related engineering guides: Tool calling through OpenRouter: the model proposes, your app executes; OpenRouter provider routing: defining permitted routes.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles