***

title: Typescript SDK
subtitle: Integrate Alephant into your TypeScript & Node.js applications
description: 'Installation, configuration, and usage of the Alephant TypeScript SDK'
------------------------------------------------------------------------------------

The official Alephant TypeScript SDK provides convenient access to the Alephant SaaS API from TypeScript and Node.js applications. It is generated from our OpenAPI specification using Fern, ensuring full type safety and up-to-date endpoints.

## Installation

Install the SDK via npm, yarn, or pnpm:

```bash
npm install @alephantai/saas-api
```

## Initialization

Import and initialize the client with your Personal Access Token (`ALEPHANT_PAT`) or an appropriate authentication token.

```typescript
import { AlephantAi } from '@alephantai/saas-api';

const client = new AlephantAi({
  // Your API Token
  token: process.env.ALEPHANT_API_TOKEN,
  // Optional: override the base URL for private deployments
  // environment: "https://your-custom-alephant-url.com"
});
```

## Example Usage

### Listing Workspaces

Retrieve a list of all workspaces your account has access to.

```typescript
async function fetchWorkspaces() {
  try {
    const response = await client.workspaces.listWorkspaces();
    console.log(response);
  } catch (error) {
    console.error("Failed to fetch workspaces:", error);
  }
}
```

### Creating an Agent and Virtual Key

You can programmatically provision new AI Agents and their associated Virtual Keys using the SDK.

```typescript
async function createNewAgent() {
  const newAgent = await client.agents.createAgent({
    name: "Customer Support Bot",
    provider: "openai",
    model: "gpt-4-turbo",
    environment: "production"
  });
  
  console.log(`Created agent with ID: ${newAgent.id}`);
  // A Virtual Key is automatically generated for this agent
}
```

## Error Handling

The SDK throws structured errors for non-2xx API responses, allowing you to catch and handle specific failure scenarios (like rate limits or validation errors) programmatically.

## Repository

For advanced configurations, types, and source code, refer to the actual SDK generated outputs or your internal registry.
