Migrating to @openrouter/agent
Migrating to @openrouter/agent
Move agent toolkit imports from @openrouter/sdk to the standalone @openrouter/agent package
Migrating to @openrouter/agent
Move agent toolkit imports from @openrouter/sdk to the standalone @openrouter/agent package
Using an AI coding assistant? Install the migration skill
to let your agent handle the import updates for you:
gh skill install OpenRouterTeam/skills openrouter-agent-migration
The agent toolkit (callModel, tool, stop conditions, etc.)
has moved from @openrouter/sdk to a standalone
@openrouter/agent package. The agent package includes
its own OpenRouter client class, so you no longer need
@openrouter/sdk as a dependency for agent workflows.
You need to migrate if your code imports any of the following
from @openrouter/sdk:
callModel / ModelResulttool / Tool / tool type guardsstepCountIs, hasToolCall, etc.)CallModelInput, resolveAsyncFunctions)fromClaudeMessages,
fromChatMessages, etc.)If you only use the REST API client for non-agent features
(client.chat.send(...), client.models.list(), etc.),
no changes are needed.
Replace @openrouter/sdk subpath imports with
the equivalent @openrouter/agent subpath.
@openrouter/agent ships its own OpenRouter client, so
you can drop the @openrouter/sdk dependency entirely if
you only use agent features:
You can also import the client from a direct subpath:
Conversation helpers and message format converters are available from the package barrel:
Run your type checker and tests to confirm everything resolves correctly:
The script below handles subpath imports automatically.
Barrel imports (from '@openrouter/sdk') and client class
imports (import OpenRouter from '@openrouter/sdk') must
be updated manually — a blanket replacement on the bare
package name would also match subpath imports and break
your code. See the Client class and
Conversation state
sections above for the correct replacements.
The tool-types replacement runs before tool to avoid
partial matches. After running the script, search your
codebase for any remaining from '@openrouter/sdk' (without
a / subpath) to find barrel and client imports that need
manual updates.
@openrouter/sdk?Only if you use non-agent REST API features like
client.models.list(), client.credits.get(), or
client.chat.send(). If your code only uses callModel,
tools, and the agent client, you can remove
@openrouter/sdk entirely.
Yes. They are designed to work side by side. Use
@openrouter/sdk for REST API features and
@openrouter/agent for the agent toolkit:
The agent exports will be removed from @openrouter/sdk
in a future major version. Update your imports now to
avoid a breaking change later.
No. @openrouter/agent uses the same API key and
endpoints. No server-side changes are required.