Baseten Performance Client

0.1.5 · active · verified Fri Apr 17

The `baseten-performance-client` is a Python library designed for ultra-high performance interactions with Baseten's inference endpoints, particularly for embedding models. It provides a simple client interface for sending prediction requests. As of the current version `0.1.5`, it primarily focuses on optimizing HTTP requests to Baseten services. Its release cadence is tied to Baseten's internal development cycles, with updates typically driven by specific performance or feature needs.

Common errors

Warnings

Install

Imports

Quickstart

Initialize the `PerformanceClient` with your Baseten API key and make a prediction request to a specified model ID. The API key can be passed directly or set as the `BASETEN_API_KEY` environment variable.

import os
from baseten_performance_client import PerformanceClient

# Ensure your Baseten API key is set as an environment variable
# os.environ['BASETEN_API_KEY'] = 'YOUR_BASETEN_API_KEY'
api_key = os.environ.get('BASETEN_API_KEY', 'YOUR_BASETEN_API_KEY_HERE')
model_id = 'YOUR_MODEL_ID'

if api_key == 'YOUR_BASETEN_API_KEY_HERE' or not api_key:
    print("Warning: Please set the BASETEN_API_KEY environment variable or replace 'YOUR_BASETEN_API_KEY_HERE'.")
    print("Skipping prediction due to missing API key.")
else:
    try:
        client = PerformanceClient(api_key=api_key)
        response = client.predict(
            model_id=model_id,
            input={'text': 'The quick brown fox jumps over the lazy dog.'}
        )
        print("Prediction successful:")
        print(response)
    except Exception as e:
        print(f"An error occurred during prediction: {e}")

view raw JSON →