# Connect Vercel AI SDK to aicharged.io

> Vercel AI SDK: createMCPClient from @ai-sdk/mcp with an HTTP transport; pass the tools straight to generateText or streamText.

## At a glance

| Kind | Sign-in | Platforms | Status | Verified |
|---|---|---|---|---|
| SDKs & frameworks | API key (Bearer), OAuth sign-in | macOS, Linux, Windows | works today | 2026-10-22 |

- MCP: `https://aicharged.io/api/v1/mcp`
- Docs: https://ai-sdk.dev/docs/ai-sdk-core/mcp-tools

## Recipe

Client code:

```ts
import { createMCPClient } from '@ai-sdk/mcp';

const client = await createMCPClient({
  transport: {
    type: 'http',
    url: 'https://aicharged.io/api/v1/mcp',
    headers: { Authorization: `Bearer ${process.env.AICHARGED_API_KEY}` },
  },
});
const tools = await client.tools(); // pass to generateText / streamText
console.log(Object.keys(tools));
await client.close();
```

Install the package:

```sh
npm install ai @ai-sdk/mcp
```

[Client documentation](https://ai-sdk.dev/docs/ai-sdk-core/mcp-tools)

## Authentication

- Send `Authorization: Bearer <API_KEY>` with every request. Create a key at https://aicharged.io/admin/account/api-keys.
- OAuth 2.1 (PKCE S256) is available for clients that cannot send a static key (ChatGPT).
- Without a key the endpoint answers 401 with a WWW-Authenticate header that points to https://aicharged.io/.well-known/oauth-protected-resource.

All 51 clients: https://aicharged.io/connect.md

HTML version: https://aicharged.io/connect/vercel-ai-sdk
