Skip to main content

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;
}
OptionTypeDescription
apiKeystringAPI key for authentication (recommended)
tokenstringOAuth/JWT token for user-scoped access
baseUrlstringOverride 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

PropertyTypeDescription
agentsAgentsAPIAgent management methods
secretsSecretsAPISecret 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:
VariableDescription
CASTARI_API_KEYDefault API key if not provided in constructor
CASTARI_API_URLDefault base URL if not provided
// Uses CASTARI_API_KEY from environment
const client = new CastariClient({});

See Also