> ## 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 Act 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 thread history after retries or process restarts. |

Provide an OpenRouter `OAuthClientProvider` when the application needs Act scopes. Persist `threadId` and the last consumed cursor outside model messages and return Darwin's typed requests and operation states 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>

[Review OpenRouter's MCP tools documentation](https://openrouter.ai/docs/agent-sdk/call-model/mcp-tools) for current adapter behavior.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.