This tutorial walks you through creating a custom AIPerf endpoint plugin from scratch. By the end, you’ll have a working plugin package that can benchmark any custom API.
Contributing directly to AIPerf? The endpoint class (Step 2) and manifest format (Step 3) are the same, but you can skip the external packaging:
src/aiperf/ instead of a separate packagesrc/aiperf/plugin/plugins.yaml instead of creating a new oneWe’ll create a plugin for a hypothetical “Echo API” that returns the input text with some metadata. This simple example demonstrates all the core concepts you need to build more complex plugins.
uv pip install aiperf)Before diving in, understand the plugin system terminology:
What you’re building:
For complete plugin system documentation, see the Plugin System Reference.
Create a new directory for your plugin package:
You should see:
Now fill in each file in the steps below.
The key part is the [project.entry-points."aiperf.plugins"] section - this tells AIPerf where to find your plugin manifest.
Your endpoint needs two methods: format_payload() and parse_response().
What’s happening:
format_payload()converts AIPerf’sRequestInfointo your API’s format.parse_response()extracts the response text into aParsedResponse.
From your plugin directory, install into the same Python environment where AIPerf is installed. AIPerf discovers plugins via entry points, which only works when both packages share the same environment.
You should see:
Important: If you use virtual environments or conda, make sure you activate the environment where AIPerf is installed before running
uv pip install.
Confirm both packages are installed in the same environment:
You should see both packages listed in the same environment:
Check that AIPerf discovers your plugin:
You should see your plugin in the table:
You should see:
You should see:
To test your plugin end-to-end, create a minimal Echo API server. Save this as echo_server.py in your project root:
Start the server:
You should see:
With the test server running, use your endpoint with AIPerf:
You should see:
Fixtures: The
mock_model_endpoint,mock_request_info, andmock_responsefixtures in this snippet are illustrative, not built into AIPerf. Create them in your package’sconftest.py(or replace them with concreteRequestInfo/ response objects) before running the test.
Solutions:
uv pip install -e . completed successfullypyproject.toml matches your package structureaiperf plugins --validate to check for errorsSolutions:
module.path:ClassNamepython -c "from my_plugins.endpoints.echo_endpoint import EchoEndpoint"Solutions:
-vv flag to see raw responses in debug logsparse_response handles your API’s actual response formatauto_detect_and_extract() as a fallback for unknown formats