[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M78DJPXD3Q97D5P2K2ZEXEQK":3,"skill-same:01M78DJPXD3Q97D5P2K2ZEXEQK":63},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":34,"commitSha":35,"skillDirectory":36,"forksCount":14,"repositoryHtmlUrl":37,"repositoryHomepageUrl":38,"ownerHtmlUrl":39,"ownerBlogUrl":40,"ownerDescription":41,"updatedAt":42,"install":43,"resources":56},"01M78DJPXD3Q97D5P2K2ZEXEQK","openrouter-agent-migration",null,"Migration guide from @openrouter\u002Fsdk to @openrouter\u002Fagent for callModel, tool(), stop conditions, and agent features. This skill should be used when code imports callModel, tool(), or stop conditions from @openrouter\u002Fsdk and needs to migrate to @openrouter\u002Fagent.","Solizardking\u002Fskillhub-main","Solizardking","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F108096810?v=4","01M786KDB10AYV042N0F9BD5B5","Clawd","01M786NYYXSZK1D05WM8JQPC48",0,"MIT","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fopenrouter-agent-migration\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: openrouter-agent-migration\ndescription: Migration guide from @openrouter\u002Fsdk to @openrouter\u002Fagent for callModel, tool(), stop conditions, and agent features. This skill should be used when code imports callModel, tool(), or stop conditions from @openrouter\u002Fsdk and needs to migrate to @openrouter\u002Fagent.\nversion: 1.0.0\nmetadata:\n  solanaos:\n    emoji: \"📚\"\n    registryKey: \"openrouter.agent-migration\"\n    kind: \"doc\"\n    requires:\n      bins: []\n      env: []\n    injectAt: \"doc-only\"\n---\n\n# Migrating from @openrouter\u002Fsdk to @openrouter\u002Fagent\n\nAgent functionality (`callModel`, `tool()`, stop conditions, format converters, streaming helpers) has moved from `@openrouter\u002Fsdk` to the standalone `@openrouter\u002Fagent` package. The `@openrouter\u002Fagent` package includes its own `OpenRouter` client class, so you do not need `@openrouter\u002Fsdk` for agent use cases.\n\n---\n\n## When This Applies\n\nMigrate if your code imports any of these from `@openrouter\u002Fsdk`:\n\n- `callModel` or uses `client.callModel()`\n- `tool()` factory function\n- Stop conditions: `stepCountIs`, `hasToolCall`, `maxCost`, `maxTokensUsed`, `finishReasonIs`\n- Format converters: `fromClawdMessages`, `toClawdMessage`, `fromChatMessages`, `toChatMessage`\n- Types: `Tool`, `ToolWithExecute`, `ToolWithGenerator`, `ManualTool`, `CallModelInput`, `ModelResult`\n\n---\n\n## Quick Migration\n\n### Step 1: Install\n\n```bash\nnpm install @openrouter\u002Fagent\n```\n\nIf you only use agent features, you can remove `@openrouter\u002Fsdk`:\n\n```bash\nnpm uninstall @openrouter\u002Fsdk\nnpm install @openrouter\u002Fagent\n```\n\nIf you also use non-agent SDK features (models list, chat completions, credits, OAuth, API keys), keep both packages installed.\n\n### Step 2: Update Imports\n\nThe `OpenRouter` client class and `client.callModel()` pattern work identically. Only the import source changes:\n\n```diff\n- import OpenRouter from '@openrouter\u002Fsdk';\n+ import { OpenRouter } from '@openrouter\u002Fagent';\n```\n\nThe rest of your code stays the same:\n\n```typescript\nconst client = new OpenRouter({ apiKey: process.env.OPENROUTER_API_KEY });\n\nconst result = client.callModel({\n  model: 'openai\u002Fgpt-5-nano',\n  input: 'Hello!',\n});\n\nconst text = await result.getText();\n```\n\n---\n\n## Complete Import Mapping\n\n### Client & callModel\n\n| Old | New |\n|-----|-----|\n| `import OpenRouter from '@openrouter\u002Fsdk'` | `import { OpenRouter } from '@openrouter\u002Fagent'` |\n| `import OpenRouter, { tool, stepCountIs } from '@openrouter\u002Fsdk'` | `import { OpenRouter } from '@openrouter\u002Fagent'`\u003Cbr>`import { tool } from '@openrouter\u002Fagent\u002Ftool'`\u003Cbr>`import { stepCountIs } from '@openrouter\u002Fagent\u002Fstop-conditions'` |\n\nA standalone `callModel` function is also available for advanced use cases where a pre-existing `OpenRouterCore` instance is available:\n\n```typescript\nimport { callModel } from '@openrouter\u002Fagent\u002Fcall-model';\n\n\u002F\u002F Requires an OpenRouterCore instance (from @openrouter\u002Fsdk\u002Fcore)\nconst result = callModel(coreInstance, { model: 'openai\u002Fgpt-5-nano', input: 'Hello' });\n```\n\nFor most use cases, prefer the `client.callModel()` method shown above.\n\n### Tool Creation\n\n| Old | New |\n|-----|-----|\n| `import { tool } from '@openrouter\u002Fsdk'` | `import { tool } from '@openrouter\u002Fagent\u002Ftool'` |\n\n### Stop Conditions\n\n| Old | New |\n|-----|-----|\n| `import { stepCountIs, hasToolCall, maxCost } from '@openrouter\u002Fsdk'` | `import { stepCountIs, hasToolCall, maxCost } from '@openrouter\u002Fagent\u002Fstop-conditions'` |\n| `import { maxTokensUsed, finishReasonIs } from '@openrouter\u002Fsdk'` | `import { maxTokensUsed, finishReasonIs } from '@openrouter\u002Fagent\u002Fstop-conditions'` |\n\n### Types\n\n| Old | New |\n|-----|-----|\n| `import type { Tool, ToolWithExecute, ToolWithGenerator, ManualTool } from '@openrouter\u002Fsdk\u002Flib\u002Ftool-types'` | `import type { Tool, ToolWithExecute, ToolWithGenerator, ManualTool } from '@openrouter\u002Fagent\u002Ftool-types'` |\n| `import type { CallModelInput } from '@openrouter\u002Fsdk\u002Flib\u002Fasync-params'` | `import type { CallModelInput } from '@openrouter\u002Fagent\u002Fasync-params'` |\n| `import { ModelResult } from '@openrouter\u002Fsdk\u002Flib\u002Fmodel-result'` | `import { ModelResult } from '@openrouter\u002Fagent\u002Fmodel-result'` |\n\n### Format Converters\n\n| Old | New |\n|-----|-----|\n| `import { fromClawdMessages, toClawdMessage } from '@openrouter\u002Fsdk'` | `import { fromClawdMessages, toClawdMessage } from '@openrouter\u002Fagent'` |\n| `import { fromChatMessages, toChatMessage } from '@openrouter\u002Fsdk'` | `import { fromChatMessages, toChatMessage } from '@openrouter\u002Fagent'` |\n\n### Type Guards\n\n| Old | New |\n|-----|-----|\n| `import { hasExecuteFunction, isGeneratorTool, isRegularExecuteTool } from '@openrouter\u002Fsdk'` | `import { hasExecuteFunction, isGeneratorTool, isRegularExecuteTool } from '@openrouter\u002Fagent\u002Ftool-types'` |\n\n---\n\n## Before & After Example\n\n### Before (using @openrouter\u002Fsdk)\n\n```typescript\nimport OpenRouter, { tool, stepCountIs, hasToolCall } from '@openrouter\u002Fsdk';\nimport { z } from 'zod';\n\nconst client = new OpenRouter({\n  apiKey: process.env.OPENROUTER_API_KEY,\n});\n\nconst searchTool = tool({\n  name: 'web_search',\n  description: 'Search the web',\n  inputSchema: z.object({ query: z.string() }),\n  outputSchema: z.object({ results: z.array(z.string()) }),\n  execute: async ({ query }) => {\n    return { results: ['Result 1', 'Result 2'] };\n  },\n});\n\nconst finishTool = tool({\n  name: 'finish',\n  description: 'Complete the task',\n  inputSchema: z.object({ answer: z.string() }),\n  execute: async ({ answer }) => ({ answer }),\n});\n\nconst result = client.callModel({\n  model: 'openai\u002Fgpt-5-nano',\n  instructions: 'You are a research assistant.',\n  input: 'What are the latest AI developments?',\n  tools: [searchTool, finishTool],\n  stopWhen: [stepCountIs(10), hasToolCall('finish')],\n});\n\nconst text = await result.getText();\n```\n\n### After (using @openrouter\u002Fagent)\n\n```typescript\nimport { OpenRouter } from '@openrouter\u002Fagent';\nimport { tool } from '@openrouter\u002Fagent\u002Ftool';\nimport { stepCountIs, hasToolCall } from '@openrouter\u002Fagent\u002Fstop-conditions';\nimport { z } from 'zod';\n\nconst client = new OpenRouter({\n  apiKey: process.env.OPENROUTER_API_KEY,\n});\n\nconst searchTool = tool({\n  name: 'web_search',\n  description: 'Search the web',\n  inputSchema: z.object({ query: z.string() }),\n  outputSchema: z.object({ results: z.array(z.string()) }),\n  execute: async ({ query }) => {\n    return { results: ['Result 1', 'Result 2'] };\n  },\n});\n\nconst finishTool = tool({\n  name: 'finish',\n  description: 'Complete the task',\n  inputSchema: z.object({ answer: z.string() }),\n  execute: async ({ answer }) => ({ answer }),\n});\n\nconst result = client.callModel({\n  model: 'openai\u002Fgpt-5-nano',\n  instructions: 'You are a research assistant.',\n  input: 'What are the latest AI developments?',\n  tools: [searchTool, finishTool],\n  stopWhen: [stepCountIs(10), hasToolCall('finish')],\n});\n\nconst text = await result.getText();\n```\n\nThe only changes are the three import lines at the top.\n\n---\n\n## When to Keep @openrouter\u002Fsdk\n\nKeep `@openrouter\u002Fsdk` installed if you use any of these non-agent features:\n\n| Feature | Access |\n|---------|--------|\n| Model listing | `client.models.list()` |\n| Chat completions | `client.chat.send()` |\n| Legacy completions | `client.completions.generate()` |\n| Usage analytics | `client.analytics.getUserActivity()` |\n| Credit balance | `client.credits.getCredits()` |\n| API key management | `client.apiKeys.list()`, `.create()`, etc. |\n| OAuth PKCE flow | `client.oAuth.createAuthCode()`, `.exchangeAuthCodeForAPIKey()` |\n\nFor mixed projects, use `@openrouter\u002Fsdk` for these features and `@openrouter\u002Fagent` for agent features:\n\n```typescript\nimport OpenRouter from '@openrouter\u002Fsdk';               \u002F\u002F SDK client for models, credits, etc.\nimport { OpenRouter as Agent } from '@openrouter\u002Fagent'; \u002F\u002F Agent client for callModel\nimport { tool } from '@openrouter\u002Fagent\u002Ftool';\nimport { stepCountIs } from '@openrouter\u002Fagent\u002Fstop-conditions';\n\n\u002F\u002F Use SDK client for non-agent features\nconst sdkClient = new OpenRouter({ apiKey: process.env.OPENROUTER_API_KEY });\nconst models = await sdkClient.models.list();\nconst credits = await sdkClient.credits.getCredits();\n\n\u002F\u002F Use Agent client for callModel\nconst agent = new Agent({ apiKey: process.env.OPENROUTER_API_KEY });\nconst result = agent.callModel({\n  model: 'openai\u002Fgpt-5-nano',\n  input: 'Hello!',\n  tools: [myTool],\n  stopWhen: stepCountIs(5),\n});\n```\n\n---\n\n## New Features in @openrouter\u002Fagent\n\nThese features are only available in `@openrouter\u002Fagent`, not in `@openrouter\u002Fsdk`:\n\n### Shared Context Schema\n\nType-safe shared state across all tools in a conversation:\n\n```typescript\nimport { OpenRouter } from '@openrouter\u002Fagent';\nimport { z } from 'zod';\n\nconst client = new OpenRouter({ apiKey: '...' });\n\nconst result = client.callModel({\n  model: 'openai\u002Fgpt-5-nano',\n  input: 'Process this data',\n  sharedContextSchema: z.object({\n    userId: z.string(),\n    sessionData: z.record(z.unknown()),\n  }),\n  context: {\n    shared: { userId: '123', sessionData: {} },\n  },\n  tools: [myTool],\n});\n```\n\n### Tool Context\n\nTools can declare their own typed context and access shared context:\n\n```typescript\nimport { tool } from '@openrouter\u002Fagent\u002Ftool';\nimport { z } from 'zod';\n\nconst myTool = tool({\n  name: 'my_tool',\n  description: 'A tool with context',\n  inputSchema: z.object({ query: z.string() }),\n  contextSchema: z.object({ apiKey: z.string() }),\n  execute: async (params, context) => {\n    \u002F\u002F context.local — this tool's own context\n    \u002F\u002F context.shared — shared context across all tools\n    \u002F\u002F context.setContext({ ... }) — update this tool's context\n    \u002F\u002F context.setSharedContext({ ... }) — update shared context\n    return { result: 'done' };\n  },\n});\n```\n\n### Tool Approval Flow\n\nRequire user approval before tool execution:\n\n```typescript\nconst dangerousTool = tool({\n  name: 'delete_file',\n  description: 'Delete a file',\n  inputSchema: z.object({ path: z.string() }),\n  requireApproval: true, \u002F\u002F or a function: (toolCall, context) => boolean\n  execute: async ({ path }) => { \u002F* ... *\u002F },\n});\n```\n\n### Turn Lifecycle Callbacks\n\n```typescript\nconst result = client.callModel({\n  model: 'openai\u002Fgpt-5-nano',\n  input: 'Complex task',\n  tools: [myTool],\n  onTurnStart: async (context) => {\n    console.log(`Starting turn ${context.numberOfTurns}`);\n  },\n  onTurnEnd: async (context, response) => {\n    console.log(`Turn ${context.numberOfTurns} complete`);\n  },\n});\n```\n\n---\n\n## All Subpath Exports\n\n`@openrouter\u002Fagent` provides granular subpath imports:\n\n| Subpath | Exports |\n|---------|---------|\n| `@openrouter\u002Fagent` | Barrel: all exports below |\n| `@openrouter\u002Fagent\u002Fclient` | `OpenRouter` class |\n| `@openrouter\u002Fagent\u002Fcall-model` | `callModel` standalone function |\n| `@openrouter\u002Fagent\u002Ftool` | `tool()` factory function |\n| `@openrouter\u002Fagent\u002Ftool-types` | `Tool`, `ToolWithExecute`, `ToolWithGenerator`, `ManualTool`, type guards |\n| `@openrouter\u002Fagent\u002Fstop-conditions` | `stepCountIs`, `hasToolCall`, `maxCost`, `maxTokensUsed`, `finishReasonIs` |\n| `@openrouter\u002Fagent\u002Fmodel-result` | `ModelResult` response wrapper |\n| `@openrouter\u002Fagent\u002Fasync-params` | `CallModelInput`, `hasAsyncFunctions`, `resolveAsyncFunctions` |\n| `@openrouter\u002Fagent\u002Fanthropic-compat` | `fromClawdMessages`, `toClawdMessage` |\n| `@openrouter\u002Fagent\u002Fchat-compat` | `fromChatMessages`, `toChatMessage` |\n| `@openrouter\u002Fagent\u002Fconversation-state` | `createInitialState`, `updateState`, `appendToMessages` |\n| `@openrouter\u002Fagent\u002Fnext-turn-params` | `nextTurnParams` utilities |\n| `@openrouter\u002Fagent\u002Fstream-transformers` | `extractUnsupportedContent`, `getUnsupportedContentSummary` |\n| `@openrouter\u002Fagent\u002Ftool-context` | `buildToolExecuteContext`, `ToolContextStore` |\n| `@openrouter\u002Fagent\u002Ftool-event-broadcaster` | `ToolEventBroadcaster` |\n| `@openrouter\u002Fagent\u002Fturn-context` | `buildTurnContext` |\n\n","# Migrating from @openrouter\u002Fsdk to @openrouter\u002Fagent\n\nAgent functionality (`callModel`, `tool()`, stop conditions, format converters, streaming helpers) has moved from `@openrouter\u002Fsdk` to the standalone `@openrouter\u002Fagent` package. The `@openrouter\u002Fagent` package includes its own `OpenRouter` client class, so you do not need `@openrouter\u002Fsdk` for agent use cases.\n\n---\n\n## When This Applies\n\nMigrate if your code imports any of these from `@openrouter\u002Fsdk`:\n\n- `callModel` or uses `client.callModel()`\n- `tool()` factory function\n- Stop conditions: `stepCountIs`, `hasToolCall`, `maxCost`, `maxTokensUsed`, `finishReasonIs`\n- Format converters: `fromClawdMessages`, `toClawdMessage`, `fromChatMessages`, `toChatMessage`\n- Types: `Tool`, `ToolWithExecute`, `ToolWithGenerator`, `ManualTool`, `CallModelInput`, `ModelResult`\n\n---\n\n## Quick Migration\n\n### Step 1: Install\n\n```bash\nnpm install @openrouter\u002Fagent\n```\n\nIf you only use agent features, you can remove `@openrouter\u002Fsdk`:\n\n```bash\nnpm uninstall @openrouter\u002Fsdk\nnpm install @openrouter\u002Fagent\n```\n\nIf you also use non-agent SDK features (models list, chat completions, credits, OAuth, API keys), keep both packages installed.\n\n### Step 2: Update Imports\n\nThe `OpenRouter` client class and `client.callModel()` pattern work identically. Only the import source changes:\n\n```diff\n- import OpenRouter from '@openrouter\u002Fsdk';\n+ import { OpenRouter } from '@openrouter\u002Fagent';\n```\n\nThe rest of your code stays the same:\n\n```typescript\nconst client = new OpenRouter({ apiKey: process.env.OPENROUTER_API_KEY });\n\nconst result = client.callModel({\n  model: 'openai\u002Fgpt-5-nano',\n  input: 'Hello!',\n});\n\nconst text = await result.getText();\n```\n\n---\n\n## Complete Import Mapping\n\n### Client & callModel\n\n| Old | New |\n|-----|-----|\n| `import OpenRouter from '@openrouter\u002Fsdk'` | `import { OpenRouter } from '@openrouter\u002Fagent'` |\n| `import OpenRouter, { tool, stepCountIs } from '@openrouter\u002Fsdk'` | `import { OpenRouter } from '@openrouter\u002Fagent'`\u003Cbr>`import { tool } from '@openrouter\u002Fagent\u002Ftool'`\u003Cbr>`import { stepCountIs } from '@openrouter\u002Fagent\u002Fstop-conditions'` |\n\nA standalone `callModel` function is also available for advanced use cases where a pre-existing `OpenRouterCore` instance is available:\n\n```typescript\nimport { callModel } from '@openrouter\u002Fagent\u002Fcall-model';\n\n\u002F\u002F Requires an OpenRouterCore instance (from @openrouter\u002Fsdk\u002Fcore)\nconst result = callModel(coreInstance, { model: 'openai\u002Fgpt-5-nano', input: 'Hello' });\n```\n\nFor most use cases, prefer the `client.callModel()` method shown above.\n\n### Tool Creation\n\n| Old | New |\n|-----|-----|\n| `import { tool } from '@openrouter\u002Fsdk'` | `import { tool } from '@openrouter\u002Fagent\u002Ftool'` |\n\n### Stop Conditions\n\n| Old | New |\n|-----|-----|\n| `import { stepCountIs, hasToolCall, maxCost } from '@openrouter\u002Fsdk'` | `import { stepCountIs, hasToolCall, maxCost } from '@openrouter\u002Fagent\u002Fstop-conditions'` |\n| `import { maxTokensUsed, finishReasonIs } from '@openrouter\u002Fsdk'` | `import { maxTokensUsed, finishReasonIs } from '@openrouter\u002Fagent\u002Fstop-conditions'` |\n\n### Types\n\n| Old | New |\n|-----|-----|\n| `import type { Tool, ToolWithExecute, ToolWithGenerator, ManualTool } from '@openrouter\u002Fsdk\u002Flib\u002Ftool-types'` | `import type { Tool, ToolWithExecute, ToolWithGenerator, ManualTool } from '@openrouter\u002Fagent\u002Ftool-types'` |\n| `import type { CallModelInput } from '@openrouter\u002Fsdk\u002Flib\u002Fasync-params'` | `import type { CallModelInput } from '@openrouter\u002Fagent\u002Fasync-params'` |\n| `import { ModelResult } from '@openrouter\u002Fsdk\u002Flib\u002Fmodel-result'` | `import { ModelResult } from '@openrouter\u002Fagent\u002Fmodel-result'` |\n\n### Format Converters\n\n| Old | New |\n|-----|-----|\n| `import { fromClawdMessages, toClawdMessage } from '@openrouter\u002Fsdk'` | `import { fromClawdMessages, toClawdMessage } from '@openrouter\u002Fagent'` |\n| `import { fromChatMessages, toChatMessage } from '@openrouter\u002Fsdk'` | `import { fromChatMessages, toChatMessage } from '@openrouter\u002Fagent'` |\n\n### Type Guards\n\n| Old | New |\n|-----|-----|\n| `import { hasExecuteFunction, isGeneratorTool, isRegularExecuteTool } from '@openrouter\u002Fsdk'` | `import { hasExecuteFunction, isGeneratorTool, isRegularExecuteTool } from '@openrouter\u002Fagent\u002Ftool-types'` |\n\n---\n\n## Before & After Example\n\n### Before (using @openrouter\u002Fsdk)\n\n```typescript\nimport OpenRouter, { tool, stepCountIs, hasToolCall } from '@openrouter\u002Fsdk';\nimport { z } from 'zod';\n\nconst client = new OpenRouter({\n  apiKey: process.env.OPENROUTER_API_KEY,\n});\n\nconst searchTool = tool({\n  name: 'web_search',\n  description: 'Search the web',\n  inputSchema: z.object({ query: z.string() }),\n  outputSchema: z.object({ results: z.array(z.string()) }),\n  execute: async ({ query }) => {\n    return { results: ['Result 1', 'Result 2'] };\n  },\n});\n\nconst finishTool = tool({\n  name: 'finish',\n  description: 'Complete the task',\n  inputSchema: z.object({ answer: z.string() }),\n  execute: async ({ answer }) => ({ answer }),\n});\n\nconst result = client.callModel({\n  model: 'openai\u002Fgpt-5-nano',\n  instructions: 'You are a research assistant.',\n  input: 'What are the latest AI developments?',\n  tools: [searchTool, finishTool],\n  stopWhen: [stepCountIs(10), hasToolCall('finish')],\n});\n\nconst text = await result.getText();\n```\n\n### After (using @openrouter\u002Fagent)\n\n```typescript\nimport { OpenRouter } from '@openrouter\u002Fagent';\nimport { tool } from '@openrouter\u002Fagent\u002Ftool';\nimport { stepCountIs, hasToolCall } from '@openrouter\u002Fagent\u002Fstop-conditions';\nimport { z } from 'zod';\n\nconst client = new OpenRouter({\n  apiKey: process.env.OPENROUTER_API_KEY,\n});\n\nconst searchTool = tool({\n  name: 'web_search',\n  description: 'Search the web',\n  inputSchema: z.object({ query: z.string() }),\n  outputSchema: z.object({ results: z.array(z.string()) }),\n  execute: async ({ query }) => {\n    return { results: ['Result 1', 'Result 2'] };\n  },\n});\n\nconst finishTool = tool({\n  name: 'finish',\n  description: 'Complete the task',\n  inputSchema: z.object({ answer: z.string() }),\n  execute: async ({ answer }) => ({ answer }),\n});\n\nconst result = client.callModel({\n  model: 'openai\u002Fgpt-5-nano',\n  instructions: 'You are a research assistant.',\n  input: 'What are the latest AI developments?',\n  tools: [searchTool, finishTool],\n  stopWhen: [stepCountIs(10), hasToolCall('finish')],\n});\n\nconst text = await result.getText();\n```\n\nThe only changes are the three import lines at the top.\n\n---\n\n## When to Keep @openrouter\u002Fsdk\n\nKeep `@openrouter\u002Fsdk` installed if you use any of these non-agent features:\n\n| Feature | Access |\n|---------|--------|\n| Model listing | `client.models.list()` |\n| Chat completions | `client.chat.send()` |\n| Legacy completions | `client.completions.generate()` |\n| Usage analytics | `client.analytics.getUserActivity()` |\n| Credit balance | `client.credits.getCredits()` |\n| API key management | `client.apiKeys.list()`, `.create()`, etc. |\n| OAuth PKCE flow | `client.oAuth.createAuthCode()`, `.exchangeAuthCodeForAPIKey()` |\n\nFor mixed projects, use `@openrouter\u002Fsdk` for these features and `@openrouter\u002Fagent` for agent features:\n\n```typescript\nimport OpenRouter from '@openrouter\u002Fsdk';               \u002F\u002F SDK client for models, credits, etc.\nimport { OpenRouter as Agent } from '@openrouter\u002Fagent'; \u002F\u002F Agent client for callModel\nimport { tool } from '@openrouter\u002Fagent\u002Ftool';\nimport { stepCountIs } from '@openrouter\u002Fagent\u002Fstop-conditions';\n\n\u002F\u002F Use SDK client for non-agent features\nconst sdkClient = new OpenRouter({ apiKey: process.env.OPENROUTER_API_KEY });\nconst models = await sdkClient.models.list();\nconst credits = await sdkClient.credits.getCredits();\n\n\u002F\u002F Use Agent client for callModel\nconst agent = new Agent({ apiKey: process.env.OPENROUTER_API_KEY });\nconst result = agent.callModel({\n  model: 'openai\u002Fgpt-5-nano',\n  input: 'Hello!',\n  tools: [myTool],\n  stopWhen: stepCountIs(5),\n});\n```\n\n---\n\n## New Features in @openrouter\u002Fagent\n\nThese features are only available in `@openrouter\u002Fagent`, not in `@openrouter\u002Fsdk`:\n\n### Shared Context Schema\n\nType-safe shared state across all tools in a conversation:\n\n```typescript\nimport { OpenRouter } from '@openrouter\u002Fagent';\nimport { z } from 'zod';\n\nconst client = new OpenRouter({ apiKey: '...' });\n\nconst result = client.callModel({\n  model: 'openai\u002Fgpt-5-nano',\n  input: 'Process this data',\n  sharedContextSchema: z.object({\n    userId: z.string(),\n    sessionData: z.record(z.unknown()),\n  }),\n  context: {\n    shared: { userId: '123', sessionData: {} },\n  },\n  tools: [myTool],\n});\n```\n\n### Tool Context\n\nTools can declare their own typed context and access shared context:\n\n```typescript\nimport { tool } from '@openrouter\u002Fagent\u002Ftool';\nimport { z } from 'zod';\n\nconst myTool = tool({\n  name: 'my_tool',\n  description: 'A tool with context',\n  inputSchema: z.object({ query: z.string() }),\n  contextSchema: z.object({ apiKey: z.string() }),\n  execute: async (params, context) => {\n    \u002F\u002F context.local — this tool's own context\n    \u002F\u002F context.shared — shared context across all tools\n    \u002F\u002F context.setContext({ ... }) — update this tool's context\n    \u002F\u002F context.setSharedContext({ ... }) — update shared context\n    return { result: 'done' };\n  },\n});\n```\n\n### Tool Approval Flow\n\nRequire user approval before tool execution:\n\n```typescript\nconst dangerousTool = tool({\n  name: 'delete_file',\n  description: 'Delete a file',\n  inputSchema: z.object({ path: z.string() }),\n  requireApproval: true, \u002F\u002F or a function: (toolCall, context) => boolean\n  execute: async ({ path }) => { \u002F* ... *\u002F },\n});\n```\n\n### Turn Lifecycle Callbacks\n\n```typescript\nconst result = client.callModel({\n  model: 'openai\u002Fgpt-5-nano',\n  input: 'Complex task',\n  tools: [myTool],\n  onTurnStart: async (context) => {\n    console.log(`Starting turn ${context.numberOfTurns}`);\n  },\n  onTurnEnd: async (context, response) => {\n    console.log(`Turn ${context.numberOfTurns} complete`);\n  },\n});\n```\n\n---\n\n## All Subpath Exports\n\n`@openrouter\u002Fagent` provides granular subpath imports:\n\n| Subpath | Exports |\n|---------|---------|\n| `@openrouter\u002Fagent` | Barrel: all exports below |\n| `@openrouter\u002Fagent\u002Fclient` | `OpenRouter` class |\n| `@openrouter\u002Fagent\u002Fcall-model` | `callModel` standalone function |\n| `@openrouter\u002Fagent\u002Ftool` | `tool()` factory function |\n| `@openrouter\u002Fagent\u002Ftool-types` | `Tool`, `ToolWithExecute`, `ToolWithGenerator`, `ManualTool`, type guards |\n| `@openrouter\u002Fagent\u002Fstop-conditions` | `stepCountIs`, `hasToolCall`, `maxCost`, `maxTokensUsed`, `finishReasonIs` |\n| `@openrouter\u002Fagent\u002Fmodel-result` | `ModelResult` response wrapper |\n| `@openrouter\u002Fagent\u002Fasync-params` | `CallModelInput`, `hasAsyncFunctions`, `resolveAsyncFunctions` |\n| `@openrouter\u002Fagent\u002Fanthropic-compat` | `fromClawdMessages`, `toClawdMessage` |\n| `@openrouter\u002Fagent\u002Fchat-compat` | `fromChatMessages`, `toChatMessage` |\n| `@openrouter\u002Fagent\u002Fconversation-state` | `createInitialState`, `updateState`, `appendToMessages` |\n| `@openrouter\u002Fagent\u002Fnext-turn-params` | `nextTurnParams` utilities |\n| `@openrouter\u002Fagent\u002Fstream-transformers` | `extractUnsupportedContent`, `getUnsupportedContentSummary` |\n| `@openrouter\u002Fagent\u002Ftool-context` | `buildToolExecuteContext`, `ToolContextStore` |\n| `@openrouter\u002Fagent\u002Ftool-event-broadcaster` | `ToolEventBroadcaster` |\n| `@openrouter\u002Fagent\u002Fturn-context` | `buildTurnContext` |\n\n",{"name":5,"version":24,"metadata":25,"description":7},"1.0.0",{"solanaos":26},{"kind":27,"emoji":28,"injectAt":29,"requires":30,"registryKey":33},"doc","📚","doc-only",{"env":31,"bins":32},[],[],"openrouter.agent-migration","main","be3de0244dc1a57e323d8160787ebb40fb64930e","skills\u002Fopenrouter-agent-migration","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main","https:\u002F\u002Fskills.x402.wtf","https:\u002F\u002Fgithub.com\u002FSolizardking","https:\u002F\u002Fmusebook.trade","Got a mile high and never came down","2026-10-08 23:20:13",{"source":8,"skillName":5,"commands":44,"prompt":54,"zipAvailable":55},[45,48,51],{"tool":46,"command":47},"npx","npx skills add Solizardking\u002Fskillhub-main --skill openrouter-agent-migration",{"tool":49,"command":50},"bunx","bunx skills add Solizardking\u002Fskillhub-main --skill openrouter-agent-migration",{"tool":52,"command":53},"pnpm","pnpm dlx skills add Solizardking\u002Fskillhub-main --skill openrouter-agent-migration","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fopenrouter-agent-migration\u002FSKILL.md",true,[57],{"path":58,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":61,"sourceHtmlUrl":62},"metadata.json","REFERENCE","参考文档",680,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fopenrouter-agent-migration\u002Fmetadata.json",[64,71,78,85,92,100],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M78E0TGCAMNPS207BA3G07S7","zkrouter","Self-hosted OpenAI-compatible LLM router — smart tier-based routing, ZK-stamped routing decisions, mode overrides, free OpenRouter at install via the Birth bot. Save 60-80% on inference costs by routing to the cheapest capable model across 12+ OpenRouter models.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fzkrouter\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M78E0R1Z8BDT6EDTHY17MTNB","zk","For custom ZK Solana programs and privacy-preserving applications to prevent double spending. Guide to integrate rent-free nullifier PDAs for double-spend prevention.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fzk\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M78E0P3ZTZ1YWF8MD5MM23QE","zk-omni-messaging","Zero-knowledge omnichain messaging between Robinhood Chain and Solana using CheshireZkOmniMessenger (msgType 4) with nullifier anti-replay and the zk-omni-relayer service.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fzk-omni-messaging\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":19},"01M78E0JXZ2PNB1896VXAGDBWD","zerion-wallet-data","Use when the user asks to check a wallet's portfolio, token balances, DeFi positions, PnL, transaction history, or NFTs. Provides interpreted on-chain data across 40+ EVM chains and Solana via x402 pay-per-request or API key — no raw RPC decoding needed.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fzerion-wallet-data\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":96,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":19},"01M78E0G14FH9GRRTQYMKD5E59","youtube-clipper","YouTube 视频智能剪辑工具。下载视频和字幕，AI 分析生成精细章节（几分钟级别）， 用户选择片段后自动剪辑、翻译字幕为中英双语、烧录字幕到视频，并生成总结文案。 使用场景：当用户需要剪辑 YouTube 视频、生成短视频片段、制作双语字幕版本时。 关键词：视频剪辑、YouTube、字幕翻译、双语字幕、视频下载、clip video","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fyoutube-clipper\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fyoutube-clipper\u002FSKILL.md",[],[],{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":19},"01M78E0C2ZYA99CFFDNB7ZMK5S","yield-optimization","Multi-chain yield optimization via yield.xyz (StakeKit). Discover 2,988+ yield opportunities across 75+ blockchains, build deposit\u002Fwithdrawal transactions with shell scripts, and sign them with a MoonPay wallet. Use when the user wants to earn yield, find the best lending or staking rate, enter\u002Fexit a position, or check portfolio balances.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fyield-optimization\u002FSKILL.md",[],[]]