Mixedbread

TypeScript SDK

Learn how to install and configure Mixedbread's TypeScript SDK for interacting with our API services.

Installation

Installation
npm install @mixedbread/sdk

Quick Start

Here's a quick example of client initialization:

Client creation
import { Mixedbread } from "@mixedbread/sdk";
 
const mxbai = new Mixedbread({
    apiKey: "YOUR_API_KEY",
    maxRetries: 3,
});

Configuration

The Mixedbread constructor accepts the following options:

interface MixedbreadOptions {
    apiKey: string;
    maxRetries?: number;
    timeout?: number;
    baseURL?: string;
}
  • apiKey: Your Mixedbread API key (required)
  • maxRetries: Maximum number of retries for failed requests (default: 3)
  • timeout: Request timeout in milliseconds (default: 30000)
  • baseURL: Custom base URL for API requests (default: )

Error Handling

Use try/catch blocks to handle errors:

import { MixedbreadError, RateLimitError } from "@mixedbread/sdk";
 
try {
    const embeddings = await mxbai.embed({
        model: "mixedbread-ai/mxbai-embed-large-v1",
        input: ["Example text"],
    });
} catch (err) {
    if (err instanceof RateLimitError) {
        console.error(`Rate limit exceeded. Retry after ${err.retryAfter} seconds`);
    } else if (err instanceof MixedbreadError) {
        console.error(`API Error: ${err.message}`);
        console.error(`Status Code: ${err.statusCode}`);
    } else {
        console.error(`Unexpected error: ${err}`);
    }
}

Available Services

The SDK provides access to the following services:

  • mxbai.vectorStores - Create and manage vector stores
  • mxbai.vectorStores.files - Create and manage vector stores files
  • mxbai.files - Upload and manage files
  • mxbai.parsing - Manage parsing jobs
  • mxbai.embed - Generate embeddings
  • mxbai.rerank - Rerank search results

Documentation and Examples

For detailed usage examples and API documentation, check out:

Next Steps

Last updated on

On this page