Mixedbread

Python SDK

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

Installation

Installation
pip install mixedbread

Quick Start

Here's a quick example of client initialization:

Client creation
from mixedbread import Mixedbread
 
mxbai = Mixedbread(api_key="YOUR_API_KEY", max_retries=3)

Configuration

The Mixedbread constructor accepts the following parameters:

class Mixedbread:
    def __init__(
        self,
        api_key: str,
        max_retries: int = 3,
        timeout: float = 30.0,
        base_url: str = "https://api.mixedbread.com"
    ):
        # ...
  • api_key: Your Mixedbread API key (required)
  • max_retries: Maximum number of retries for failed requests (default: 3)
  • timeout: Request timeout in seconds (default: 30.0)
  • base_url: Custom base URL for API requests (default: )

Async Support

For async applications, use the async client:

Async client
from mixedbread import AsyncMixedbread
 
async_mxbai = AsyncMixedbread(api_key="YOUR_API_KEY")

Error Handling

Use try/except blocks to handle errors:

from mixedbread.exceptions import MixedbreadError, RateLimitError
 
try:
    embeddings = mxbai.embed(
        model="mixedbread-ai/mxbai-embed-large-v1",
        input=["Example text"]
    )
except RateLimitError as e:
    print(f"Rate limit exceeded. Retry after {e.retry_after} seconds")
except MixedbreadError as e:
    print(f"API Error: {e}")
    print(f"Status Code: {e.status_code}")
except Exception as e:
    print(f"Unexpected error: {e}")

Available Services

The SDK provides access to the following services:

  • mxbai.vector_stores - Create and manage vector stores
  • mxbai.vector_stores.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

Happy baking! 🍞🚀

Last updated on

On this page