Skip to main content

SDK Overview

The @castari/sdk package lets you manage agents programmatically.

Installation

npm install @castari/sdk

Quick Example

import { CastariClient } from '@castari/sdk';

const client = new CastariClient({
  apiKey: process.env.CASTARI_API_KEY,
});

// List agents
const agents = await client.agents.list();
console.log(agents);

// Deploy an agent
await client.agents.deploy('my-agent');

// Invoke an agent
const result = await client.agents.invoke('my-agent', { prompt: 'Hello!' });
console.log(result.response_content);

When to Use the SDK

Use CaseCLI or SDK?
Manual deploysCLI
CI/CD pipelinesSDK
Building apps that manage agentsSDK
Quick testingCLI
Programmatic invocationsSDK

Authentication

The SDK supports two authentication methods:
const client = new CastariClient({
  apiKey: 'cast_xxxxxxxx_xxxxxxxxxx',
});
Generate an API key in the Castari Dashboard.

OAuth Token (For user-scoped access)

const client = new CastariClient({
  token: 'eyJhbGciOiJSUzI1NiIs...', // Clerk JWT
});

TypeScript Support

The SDK is written in TypeScript and exports all types:
import {
  CastariClient,
  Agent,
  AgentStatus,
  InvocationResponse,
} from '@castari/sdk';

Error Handling

import { CastariClient, CastariError } from '@castari/sdk';

try {
  await client.agents.deploy('my-agent');
} catch (error) {
  if (error instanceof CastariError) {
    console.error(`API Error: ${error.message}`);
    console.error(`Status: ${error.status}`);
  }
}

Next Steps