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:
npx skills add 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.
Who needs to migrate?
You need to migrate if your code imports any of the following
from @openrouter/sdk:
callModel/ModelResulttool/Tool/ tool type guards- Stop conditions (
stepCountIs,hasToolCall, etc.) - Async parameters (
CallModelInput,resolveAsyncFunctions) - Conversation state helpers
- Message format converters (
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.
Step 1: Install the new package
Step 2: Update imports
Replace @openrouter/sdk subpath imports with
the equivalent @openrouter/agent subpath.
Client class
@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:
Core imports
Tool types and guards
Stop conditions
Async parameters
Conversation state and message formats
Conversation helpers and message format converters are available from the package barrel:
Step 3: Verify your build
Run your type checker and tests to confirm everything resolves correctly:
Full import mapping reference
Automated migration
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.
FAQ
Do I still need @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.
Can I use both packages together?
Yes. They are designed to work side by side. Use
@openrouter/sdk for REST API features and
@openrouter/agent for the agent toolkit:
Will the old imports keep working?
The agent exports will be removed from @openrouter/sdk
in a future major version. Update your imports now to
avoid a breaking change later.
Do I need to change my API key or configuration?
No. @openrouter/agent uses the same API key and
endpoints. No server-side changes are required.