CastariClient
The main client for interacting with the Castari API.
Constructor
import { CastariClient } from '@castari/sdk';
const client = new CastariClient(options);
Options
interface CastariClientOptions {
apiKey?: string;
token?: string;
baseUrl?: string;
}
| Option | Type | Description |
|---|
apiKey | string | API key for authentication (recommended) |
token | string | OAuth/JWT token for user-scoped access |
baseUrl | string | Override API base URL (default: https://api.castari.com) |
Provide either apiKey or token, not both. If neither is provided, the client will throw an error on the first request.
Authentication Methods
API Key
Best for server-side applications, CI/CD, and automation:
const client = new CastariClient({
apiKey: process.env.CASTARI_API_KEY,
});
API keys look like: cast_xxxxxxxx_xxxxxxxxxx
Generate one in the Castari Dashboard.
OAuth Token
Best for user-facing applications where you want user-scoped access:
const client = new CastariClient({
token: userJwtToken,
});
Properties
| Property | Type | Description |
|---|
agents | AgentsAPI | Agent management methods |
secrets | SecretsAPI | Secret management methods |
Example Usage
import { CastariClient } from '@castari/sdk';
// Create client
const client = new CastariClient({
apiKey: process.env.CASTARI_API_KEY,
});
// Use agents API
const agents = await client.agents.list();
const agent = await client.agents.get('my-agent');
await client.agents.deploy('my-agent');
// Use secrets API
const secrets = await client.secrets.list('my-agent');
await client.secrets.set('my-agent', 'API_KEY', 'value');
Custom Base URL
For self-hosted or development environments:
const client = new CastariClient({
apiKey: process.env.CASTARI_API_KEY,
baseUrl: 'https://api.my-castari-instance.com',
});
Environment Variables
The SDK respects these environment variables:
| Variable | Description |
|---|
CASTARI_API_KEY | Default API key if not provided in constructor |
CASTARI_API_URL | Default base URL if not provided |
// Uses CASTARI_API_KEY from environment
const client = new CastariClient({});
See Also