{"id":9546,"library":"baseten-performance-client","title":"Baseten Performance Client","description":"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.","status":"active","version":"0.1.5","language":"en","source_language":"en","source_url":"https://github.com/basetenlabs/baseten-performance-client","tags":["baseten","client","api","performance","inference","embeddings","mlops"],"install":[{"cmd":"pip install baseten-performance-client","lang":"bash","label":"Install Baseten Performance Client"}],"dependencies":[{"reason":"Requires Python 3.8 or newer","package":"python","optional":false},{"reason":"Used internally for making asynchronous HTTP requests","package":"httpx","optional":false}],"imports":[{"symbol":"PerformanceClient","correct":"from baseten_performance_client import PerformanceClient"}],"quickstart":{"code":"import os\nfrom baseten_performance_client import PerformanceClient\n\n# Ensure your Baseten API key is set as an environment variable\n# os.environ['BASETEN_API_KEY'] = 'YOUR_BASETEN_API_KEY'\napi_key = os.environ.get('BASETEN_API_KEY', 'YOUR_BASETEN_API_KEY_HERE')\nmodel_id = 'YOUR_MODEL_ID'\n\nif api_key == 'YOUR_BASETEN_API_KEY_HERE' or not api_key:\n    print(\"Warning: Please set the BASETEN_API_KEY environment variable or replace 'YOUR_BASETEN_API_KEY_HERE'.\")\n    print(\"Skipping prediction due to missing API key.\")\nelse:\n    try:\n        client = PerformanceClient(api_key=api_key)\n        response = client.predict(\n            model_id=model_id,\n            input={'text': 'The quick brown fox jumps over the lazy dog.'}\n        )\n        print(\"Prediction successful:\")\n        print(response)\n    except Exception as e:\n        print(f\"An error occurred during prediction: {e}\")","lang":"python","description":"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."},"warnings":[{"fix":"Ensure the `BASETEN_API_KEY` environment variable is set, or pass `api_key` directly to the `PerformanceClient` constructor or `predict` method.","message":"The client requires a valid Baseten API key for most models. Without it, requests will fail with authentication errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consult your Baseten model's API documentation or the model's 'deploy' tab on the Baseten platform for the exact expected input format (e.g., keys, types, array structures).","message":"The `input` dictionary passed to the `predict` method must strictly adhere to the target Baseten model's expected input schema. Mismatched or malformed inputs will result in HTTP 400 Bad Request errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Understand that 'performance' here refers to optimized HTTP usage. For truly extreme low-latency scenarios, consider alternatives or ensure your Baseten model is optimized for such throughput. Be mindful of its blocking nature when integrating into existing asynchronous applications.","message":"While named 'performance client', the current implementation primarily uses standard HTTP/1.1 and `asyncio.run()` internally for synchronous calls. Users expecting ultra-low latency typical of gRPC or raw socket connections for very small requests might encounter higher overheads due to HTTP and Python's async-to-sync bridging.","severity":"gotcha","affected_versions":"All versions (0.1.x)"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Verify your `BASETEN_API_KEY` environment variable or the `api_key` argument. Generate a new API key from your Baseten account settings if needed.","cause":"The Baseten API key provided is either missing, incorrect, or expired.","error":"baseten_performance_client.errors.BasetenAuthenticationError: Invalid API key"},{"fix":"Double-check the `model_id` for typos. Ensure the model is deployed and you have the correct permissions to access it on the Baseten platform.","cause":"The `model_id` specified in the `predict` call does not correspond to an existing, deployed, and accessible model on your Baseten account.","error":"baseten_performance_client.errors.BasetenModelNotFoundError: Model with ID '...' not found"},{"fix":"Review the specific error message for details on the validation failure. Compare your `input` structure (keys, data types, nested objects/arrays) against the model's documented API schema.","cause":"The `input` dictionary provided to the `predict` method does not match the schema expected by the Baseten model.","error":"baseten_performance_client.errors.BasetenAPIError: 400 Bad Request: Input validation failed"}]}