TECHNOLOGY

Keep OpenRouter SDK imports aligned with the package that owns them

In this article
THE QUICK TAKE

Migrate OpenRouter imports by the functionality and package surface they use; agent helpers and REST calls can have different owners and need distinct checks.

An SDK import is a dependency on a particular package surface, not merely a name that can be replaced everywhere with a similar string. OpenRouter’s agent-toolkit migration illustrates this clearly. The agent package and the ordinary REST client can serve different parts of an application, so migration begins by identifying what the code actually uses.

Separate agent helpers from ordinary REST calls

The migration guide moves agent-toolkit functionality to @openrouter/agent and distinguishes applications that only use REST API features. Imagine a service that lists model metadata and also runs a tool-enabled conversation loop. Those responsibilities need not migrate identically. Inventory the imports and the calls they support before editing package names. This makes the dependency change understandable: the migration follows ownership of the used functionality, while a model-list request can remain an ordinary REST-client concern.

A subpath and a package root are different

An import from a specific helper path is different from importing a client or state helpers from the package root. The guide provides mappings and warns against a blanket replacement that confuses these cases. The engineering reason is that exported names and constructor shapes belong to the target package’s actual interface. A string edit that produces a plausible path is not proof that the module exports the expected symbol or that the application now creates the intended client.

Check resolution before checking model behavior

A type check or build can reveal missing exports and incompatible call shapes before any inference request is attempted. Then a bounded runtime fixture can exercise the application’s actual agent loop. These checks cover different boundaries. In the hypothetical service, test model listing and a harmless tool interaction separately, so a successful metadata call does not hide a broken loop. An import error is a client integration issue, distinct from model quality or provider routing behavior.

Preserve the tested dependency combination

Record the package versions and the relevant migration outcome in the application’s normal dependency history. The guide allows the REST SDK and agent package to coexist when both are needed. Removing a dependency is therefore a conclusion from the inventory, not an automatic requirement for every project. A useful completion report describes which imports changed, which runtime responsibility they now serve and what was observed. This creates a maintainable explanation instead of leaving future developers to infer architecture from a partially replaced set of package strings.

Primary sources

Related context: Provider routing; Tool-calling integration.

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