> ## Documentation Index
> Fetch the complete documentation index at: https://darwin.so/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenRouter Agent SDK

> Expose bounded Darwin tools to an agent built with the OpenRouter Agent SDK.

Use OpenRouter's MCP adapter to discover Darwin's tools and pass them directly to the Agent SDK.

Install the two SDKs and Zod:

```bash theme={null}
npm install @openrouter/agent @openrouter/mcp
```

```typescript theme={null}
import { OpenRouter } from '@openrouter/agent';
import { callModel } from '@openrouter/agent/call-model';
import { createMCPTools } from '@openrouter/mcp';

const client = new OpenRouter({ apiKey: process.env.OPENROUTER_API_KEY });
const mcp = await createMCPTools({ url: 'https://mcp.darwin.so/mcp' });

try {
  const result = callModel(client, {
    model: 'openai/gpt-5',
    input: 'Search for a PDF text extraction capability. Do not start it.',
    tools: mcp.tools,
  });
  console.log(await result.getText());
} finally {
  await mcp.close();
}
```

## Add Action tools deliberately

| Tool class                      | Application responsibility                                            |
| ------------------------------- | --------------------------------------------------------------------- |
| Search                          | Preserve canonical order and the selected capability revision.        |
| Start / Update / Approve / Stop | Validate input server-side and use one stable `requestId` per change. |
| Get / List                      | Recover authoritative Action state after retries or process restarts. |

Provide an OpenRouter `OAuthClientProvider` when the application needs Action scopes. Persist `actionId` outside model messages and return Darwin's structured pauses to the application without rewriting them as success prose.

<Warning>
  Keep Darwin and OpenRouter credentials on the server. Provider tokens, payment data, and approval payloads do not
  belong in prompts or client-visible tool arguments.
</Warning>

[View the complete Darwin recipe](https://github.com/darwin-studios/darwin-integrations/blob/main/frameworks/openrouter-agent-sdk.md) or OpenRouter's [MCP tools documentation](https://openrouter.ai/docs/agent-sdk/call-model/mcp-tools).
