> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mindblix.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# JavaScript SDK

> The official MINDBLIX JavaScript/TypeScript SDK. Built with TypeScript for excellent type safety and developer experience.

## Installation

```bash theme={null}
npm install @mindblix/sdk
```

Or with yarn:

```bash theme={null}
yarn add @mindblix/sdk
```

***

## Initialization

```typescript theme={null}
import { MindBlix } from '@mindblix/sdk';

const client = new MindBlix({
  apiKey: process.env.MINDBLIX_API_KEY,
});
```

***

## Agents

### List Agents

```typescript theme={null}
const agents = await client.agents.list();

agents.forEach(agent => {
  console.log(`${agent.name} (${agent.status})`);
});
```

### Create Agent

```typescript theme={null}
const agent = await client.agents.create({
  name: 'My Research Agent',
  template: 'research',
  config: {
    maxIterations: 5,
    tools: ['web_search'],
  },
});
```

### Execute Agent

```typescript theme={null}
const result = await client.agents.execute({
  agentId: 'agent_abc123',
  input: { query: 'Latest AI trends' },
});

console.log(result.output);
console.log(`Tokens: ${result.metadata.tokensUsed}`);
```

### Streaming

```typescript theme={null}
const stream = client.agents.executeStream({
  template: 'research',
  query: 'Explain quantum computing',
});

for await (const chunk of stream) {
  process.stdout.write(chunk.text);
}
```

***

## Workflows

```typescript theme={null}
const workflow = await client.workflows.create({
  name: 'Analysis Pipeline',
  steps: [
    { id: 'research', agentTemplate: 'research' },
    { id: 'analyze', agentTemplate: 'data', dependsOn: ['research'] },
  ],
});

const run = await client.workflows.trigger(workflow.id, {
  query: 'Market analysis for Q1 2026',
});

console.log(`Run status: ${run.status}`);
```

***

## Error Handling

```typescript theme={null}
import {
  MindBlixError,
  AuthenticationError,
  RateLimitError,
} from '@mindblix/sdk';

try {
  const result = await client.agents.execute({ ... });
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.error('Invalid API key');
  } else if (error instanceof RateLimitError) {
    console.error(`Rate limited. Retry after ${error.retryAfter}s`);
  } else if (error instanceof MindBlixError) {
    console.error(`API error: ${error.message}`);
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.