Installation
The AICP JavaScript SDK works in Node.js (18+) and modern browsers. It uses the native fetch API, so no polyfills are needed in Node 18+.
Install
npm install @aicp/sdk
# or
yarn add @aicp/sdk
# or
pnpm add @aicp/sdk
Basic setup
import { AICPClient } from '@aicp/sdk';
const client = new AICPClient({
apiKey: 'aicp-...', // your API key
baseUrl: 'https://your-gateway', // AICP gateway URL
timeout: 30_000, // request timeout in ms (default: 30 000)
});
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | none | Bearer token. Can be omitted and set later with client.setApiKey(). |
baseUrl | string | http://localhost:3000 | AICP gateway base URL. |
timeout | number | 30000 | Request timeout in milliseconds. |
Update the API key at runtime
After a login or signup call you receive a session JWT. You can apply it without creating a new client:
const { token } = await client.auth.login({ email, password });
client.setApiKey(token);