API Reference
The Metrum AI Bench API is a PostgREST API. Stored functions (RPCs) change state, and database views return results. The web app, the CLI, and the MCP server all call the same RPCs.
This page covers:
- Base URL and authentication
- Calling conventions
- Quickstart
- RPCs by area, with links to the full parameter references
- View endpoints
- Pagination, filtering, and ordering
- Errors
- OpenAPI document
The API section holds the full parameter, return, and error tables for each workflow.
Base URL and authentication
Base URL
The hosted control plane serves the API through the web app at
/api/postgrest. For the configured control plane, the base URL is
https://bench.metrum.ai/api/postgrest.
| Deployment | Base URL |
|---|---|
| Hosted control plane | https://<control-plane-host>/api/postgrest |
| Self-hosted stack that exposes PostgREST | The PostgREST URL, for example https://<postgrest-host> |
The hosted proxy forwards reads of tables and views, and calls of RPCs. It
refuses a direct POST, PATCH, PUT, or DELETE on a table with HTTP 403
and the error Direct table mutations are not allowed. Use RPC functions.
Authentication
Use a personal access token:
- Open Settings > Tokens (
/settings/tokens) in the web app. - Under Personal API Tokens, name the token, pick an expiry, and generate it.
- Copy the token. The page shows it once.
Send the token in every request as Authorization: Bearer <token>. The token
is a JWT. Its account_id claim is your account UUID, and its org_id claim
is the workspace you chose when you created it.
The token carries your own roles, so an API call can do only what you can do in the web app.
export METRUM_TOKEN="<personal-access-token>"
export METRUM_BASE="https://<control-plane-host>/api/postgrest"
Through the hosted proxy, every request needs a token. A self-hosted
PostgREST runs a request without a token as the anonymous role. That role can
call only the RPCs that the permission map does not list, such as the public
catalog RPCs list_self_serve_plans and get_plan_features.
Permissions
The permission map lists most RPCs that change data. A row names a Casbin
resource and action, for example project:write, and the parameter that names
the workspace, usually p_org_id. When the request has no such
parameter, the check uses the org_id claim of your token. The roles hold
these actions:
| Resource | owner | admin | member | viewer |
|---|---|---|---|---|
project | all | read, write, delete, execute | read, write, execute | read |
job | all | read, execute, cancel | read, execute | read |
kyai | all | read, write, execute | read, write, execute | read |
server | all | read, write | read, write | read |
cluster_group | read, write | read, write | read, write | read |
pulse_view | read, write | read, write | read, write | read |
Many RPCs also check access to the project or workspace inside the function. An RPC that the map does not list relies on that check alone.
Identity context
Most RPCs take your account UUID and a workspace UUID. Read your workspaces first:
curl -X POST "$METRUM_BASE/rpc/get_current_user_context" \
-H "Authorization: Bearer $METRUM_TOKEN" \
-H "Content-Type: application/json" \
-d '{"p_account_id": "<account-uuid>"}'
The response holds your account and every workspace you belong to, with your
role in each. The data model calls a workspace an organization, so the
parameter is p_org_id.
Calling conventions
Write operations: RPCs
Call an RPC with POST /rpc/<function_name>. The body is a JSON object whose
keys are the parameter names, which start with p_:
curl -X POST "$METRUM_BASE/rpc/<function_name>" \
-H "Authorization: Bearer $METRUM_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "p_param_one": "...", "p_param_two": 42 }'
PostgREST picks the function by its name and the parameter names you send. An
unknown parameter name gives HTTP 404 with code PGRST202.
An RPC returns one of these:
| Return type | Response body |
|---|---|
RETURNS TABLE | A JSON array of row objects. |
RETURNS JSON | The JSON value, often an object. |
Read operations: views
Read a view with GET /<view_name>. Use query parameters to filter, order,
and page:
curl "$METRUM_BASE/v_benchmark_results?order=created_at.desc&limit=20" \
-H "Authorization: Bearer $METRUM_TOKEN"
Content types
- Requests:
Content-Type: application/json. - Responses:
application/json.
Quickstart (API version)
This sequence creates a project, checks it, runs it, and reads the results. The Project Lifecycle page documents each call in full.
1. Read your context
Call get_current_user_context as shown above. Pick a workspace UUID.
2. Save a project
curl -X POST "$METRUM_BASE/rpc/save_project_config" \
-H "Authorization: Bearer $METRUM_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"p_account_id": "<account-uuid>",
"p_org_id": "<org-uuid>",
"p_project_uuid": null,
"p_save_as_new": false,
"p_expected_revision": null,
"p_payload": {
"project_name": "API Quickstart",
"visibility_code": "org",
"workloads": [{
"type": "benchmark",
"workload_code": "llm-baseline",
"tool_code": "metrumbench-llm",
"model_codes": ["<model-code>"],
"framework_code": "vllm",
"version": "<framework-version>",
"target_selections": [{"server_id": 0, "gpu_count": 1}],
"scenarios": [{
"scenario_code": "c10-isl512-osl256",
"concurrency": 10,
"input_sequence_length": 512,
"output_sequence_length": 256,
"streaming": true
}]
}]
}
}'
Replace 0 with a machine id from list_server_config_instances. The
response row holds project_uuid.
3. Check the run before it starts
Send the same p_account_id, p_org_id, and p_payload to
preflight_project_run. An empty array means every check passed.
4. Start the run
curl -X POST "$METRUM_BASE/rpc/execute_project_run" \
-H "Authorization: Bearer $METRUM_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"p_owner_account_id": "<account-uuid>",
"p_project_name": "API Quickstart",
"p_project_uuid": "<project-uuid>",
"p_run_name": "api-quickstart-run-1",
"p_server_config_instance_id": 0
}'
The response holds run_id and job_ids.
5. Poll each job
curl -X POST "$METRUM_BASE/rpc/get_job_status" \
-H "Authorization: Bearer $METRUM_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "p_job_id": 42 }'
status_code is one of pending, queued, running, completed, failed,
cancelled, timeout, or partial. The last five are final.
6. Read the results
curl "$METRUM_BASE/v_benchmark_results?job_id=eq.42" \
-H "Authorization: Bearer $METRUM_TOKEN"
RPCs by area
The tables list the RPCs that each workflow needs. The linked pages hold the parameters, return columns, errors, and an example for each one. The OpenAPI document lists every RPC.
Projects and the project editor
A project that has run cannot be changed. Every RPC that changes a project's
configuration refuses it with HTTP 400 and the message project_executed.
Copy the project with copy_project and change the copy. See
Project Lifecycle.
| RPC | Purpose | Permission |
|---|---|---|
get_current_user_context | Your account and workspaces. | not in the map |
list_projects | Projects you can see, each with project_uuid. | project:read |
get_project_by_name | One project by owner and exact name, with project_uuid. | project:read |
create_project | Create an empty project. | project:write |
get_project_edit_state | Whether a project has run, its revision, and its source project. | project:read |
list_project_edit_workloads | Saved workload settings, machines, and BYOE endpoint details. | project:read |
list_project_edit_scenarios | Saved scenarios with every tool setting. | project:read |
save_project_config | Create, update in place, or save as new, for every workload type, in one transaction. | project:write |
preflight_project_run | Plan, hardware, machine, and endpoint checks before a run. | project:read |
copy_project | Copy a project with every saved setting. | project:write |
execute_project_run | Run a project or one of its workloads. | project:execute |
Workloads, scenarios, and jobs
| RPC | Purpose | Permission | Reference |
|---|---|---|---|
create_workload | Add one workload to a project that never ran. | project:write | metrumbench-llm |
create_scenario | Add one scenario to a workload. | project:write | metrumbench-llm |
execute_scenario | Start one scenario on one machine. | job:execute | End-to-end example |
create_metrumbench_llm_job | Create one MetrumBench LLM job and its run directly. Returns job_id, run_id, and run_name. | job:execute | OpenAPI |
get_job_status(p_job_id) | Status of one job: status_code, status_name, status_changed_at. | not in the map | This page |
list_jobs_filtered | Jobs filtered by p_project_id, p_server_config_instance_id, p_status_code, and p_limit (default 20). | not in the map | OpenAPI |
KYAI
| RPC | Purpose | Reference |
|---|---|---|
create_kyai_candidate_endpoint, list_kyai_candidate_endpoints | Candidate endpoints. | KYAI Workload And Run |
create_kyai_workload, create_kyai_scenario | A KYAI workload and its datasets. | KYAI Workload And Run |
create_kyai_generation_run | Generation job. Takes p_project_uuid, and uses the prompts saved with the workload first. | KYAI Workload And Run |
create_kyai_judge_run | Judge job in the generation job's project. | KYAI Workload And Run |
list_kyai_judge_configs | Judge configurations. | KYAI Evaluation |
KV Cache Offload (single node)
A KV Cache Offload workload has tool code multiroundqa and a KV cache tier
(gpu, cpu, or nvme). The API stores the same tier settings, scenario
defaults, and round count as the web app.
| RPC | Purpose | Permission |
|---|---|---|
list_kv_cache_tiers_for_recipe | The tiers and the settings each one uses. | catalog:read |
create_workload with p_kv_cache_tier_code | A workload with its tier and the tier's settings. | project:write |
create_scenario with p_job_params | Users, token lengths, num_rounds (5 or more, default 25), and dataset. | project:write |
update_scenario, update_scenario_by_code | Change a scenario, with the same rules. | project:write |
execute_scenario with p_gpu_count | Run on one machine. | job:execute |
list_multiroundqa_outputs_for_job | Results of a job. | job:read |
See KV Cache Offload (Single Node).
Distributed KV cache
The MCP server has no distributed KV tool. Use these RPCs.
| RPC | Purpose | Permission |
|---|---|---|
list_cluster_groups, create_cluster_group | Cluster groups of a workspace. | membership check, cluster_group:write |
list_kv_cache_tiers_for_recipe | KV cache tiers for a tool and engine. | catalog:read |
preview_distributed_kv_topology | The per-machine plan before you save. | cluster_group:read |
save_project_config with distributed_kv | Save a distributed KV workload. | project:write |
upsert_workload_distributed_kv_config, get_workload_distributed_kv_config | Change or read the settings of a saved workload. | cluster_group:write, cluster_group:read |
execute_project_run | Run on the cluster group, or join its queue. | project:execute |
get_distributed_kv_run_status | Pool and per-machine state of a run. | cluster_group:read |
get_run_cluster_queue_state, stop_project_execution_queue | Place in the queue, and stop a queue. | project:read, project:execute |
get_distributed_kv_run_report, list_distributed_kv_workload_results | Results per job. | cluster_group:read |
See Distributed KV Cache.
Pulse Views
Pulse RPCs read your account from the token and take no p_account_id.
| RPC | Purpose | Permission |
|---|---|---|
pulse_list_source_jobs | One page of runs you can put in a View, with search, filters, dates, and groups. | pulse_view:read |
pulse_list_curator_facets | Run counts per tool, project, and status. | pulse_view:read |
pulse_list_filtered_job_ids | Every matching job id, at most 5000. | pulse_view:read |
pulse_list_private_project_options | Private projects you may include. | pulse_view:read |
pulse_create_view, pulse_add_jobs_to_view | Create a View or add runs, with optional whole source projects. | pulse_view:write |
pulse_update_view | Change a View you own. | pulse_view:write |
pulse_get_view, pulse_get_view_data | View metadata, and its chart and table data. | pulse_view:read |
pulse_list_new_source_runs | Runs of the source projects that the View does not hold yet. | pulse_view:read |
See Pulse Views.
Public leaderboard
Three routes return the public hardware leaderboard. They belong to the web app, need no token, and live under /api/public/v1/leaderboard. They are not PostgREST routes.
| Route | Purpose |
|---|---|
GET /api/public/v1/leaderboard/options | The models, precisions, and workload presets that have entries, and the defaults. |
GET /api/public/v1/leaderboard | Ranked entries of one model, precision, and workload preset, in one category. |
GET /api/public/v1/leaderboard/entries/{entryUuid} | One entry with all its concurrency points. |
curl -fsS "https://bench.metrum.ai/api/public/v1/leaderboard/options"
A response is cached for 300 seconds. Each client IP address can send 60 requests per minute, and a request over the limit gets HTTP 429 with a Retry-After header. See Public leaderboard API.
Servers
| RPC | Purpose | Reference |
|---|---|---|
list_server_config_instances | Machines of a workspace. | Distributed KV Cache |
create_server_config, create_server_config_gpu, create_server_config_instance | Register a machine. | End-to-end example |
validate_server_readiness | Readiness checks of a machine. | End-to-end example |
record_server_config_instance_heartbeat | Heartbeat. The agent calls it. | OpenAPI |
Plans and features
| RPC | Purpose | Permission |
|---|---|---|
list_self_serve_plans | Self-serve plans with their Stripe price items. | not in the map |
get_plan_features | Feature matrix: {"<plan_code>": {"<feature_code>": <quantity>}}. A quantity of 1 or null means included. | not in the map |
Image generation (feature:image_gen) is included in every Tier 2, Tier 3,
and Tier 4 plan. See
metrumbench-imagegen
for the three places the platform checks it.
MCP tools
The MCP server wraps a subset of these RPCs for agents. The copy_project
tool calls copy_project. The MCP tools that create workloads and scenarios
fail with project_executed on a project that has run. See
Using Metrum AI Bench with an Agent.
View endpoints
Every view supports PostgREST filtering at GET /<view_name>.
Job and run status
| View | What it returns |
|---|---|
v_job_current_status | Latest status per job |
v_job_status_history | Full status timeline per job |
v_run_jobs_with_params | Run jobs joined with their parameters |
v_project_run_current_status | Latest run status per project |
v_project_runs_with_status | Runs with their current status |
v_run_cost_summary | Aggregated cost per run |
v_run_health_checks | Pre-run and post-run validation outcomes for a run |
Results
| View | What it returns |
|---|---|
v_benchmark_results | Benchmark results across all tools |
v_metrumbench_llm_outputs | LLM result detail |
v_metrumbench_vlm_outputs | VLM result detail |
v_metrumbench_asr_outputs | ASR result detail |
v_inferencex_outputs | InferenceX capacity estimates |
Comparison and leaderboards
| View | What it returns |
|---|---|
v_throughput_leaderboard | Ranked leaderboard |
v_model_comparison | Cross-model performance comparison |
v_framework_comparison | Cross-framework comparison |
v_quantization_comparison | Quantization impact analysis |
v_concurrency_scaling | Concurrency compared with throughput and latency |
v_cost_efficiency | Tokens per dollar and tokens per hour |
v_hardware_utilization | Aggregated telemetry per job |
Telemetry
| View | What it returns |
|---|---|
v_telemetry_with_server | Time-series telemetry joined with server info |
v_telemetry_job_summary | Aggregated telemetry per job |
v_telemetry_per_gpu_summary | Per-GPU breakdown |
v_tpu_telemetry_job_summary | TPU-specific aggregates |
KYAI
| View | What it returns |
|---|---|
v_kyai_jobs | KYAI job listing |
v_kyai_outputs | Scored outputs: instruction, response, score |
v_kyai_generation_outputs | Phase 1 generations |
v_kyai_results | Aggregated KYAI results |
v_kyai_leaderboard | KYAI ranking |
v_kyai_builtin_sets_with_prompt_count | Built-in prompt set catalog |
Cloud and audit
| View | What it returns |
|---|---|
v_cloud_resource_lifecycle | Cloud resource state transitions |
v_audit_logs | Audit trail |
Distributed KV cache and Pulse results come from RPCs, not views.
Pagination, filtering, and ordering
Views use PostgREST conventions.
Filtering
# Equality
curl "$METRUM_BASE/v_benchmark_results?status_code=eq.completed"
# Comparison
curl "$METRUM_BASE/v_kyai_outputs?score=gte.8"
# IN list
curl "$METRUM_BASE/v_benchmark_results?framework_code=in.(vllm,sglang)"
# Pattern match
curl "$METRUM_BASE/v_benchmark_results?job_name=like.*llama*"
Ordering
curl "$METRUM_BASE/v_throughput_leaderboard?order=tokens_per_second.desc"
curl "$METRUM_BASE/v_benchmark_results?order=created_at.desc,job_name.asc"
Limit and offset
curl "$METRUM_BASE/v_benchmark_results?limit=20&offset=40"
Total count
Add Prefer: count=exact to read the size of the whole filtered set. The
hosted proxy forwards the Prefer request header and returns the
Content-Range response header:
curl -i "$METRUM_BASE/v_benchmark_results?order=created_at.desc&limit=20&offset=40" \
-H "Authorization: Bearer $METRUM_TOKEN" \
-H "Prefer: count=exact"
Content-Range then holds the range and the total, such as 40-59/12345.
Errors
RPCs report errors in two ways.
| Form | What you receive |
|---|---|
| Raised error | A non-2xx response with the PostgREST error body below. |
| Error object | An RPC that returns JSON answers with an object that has an error key. Older RPCs such as create_project, create_workload, get_job_status, and execute_project_run use this form for most validation failures. |
The status of an error object depends on the base URL:
| Base URL | Response |
|---|---|
Hosted /api/postgrest | HTTP 400 with {"message": "<the error text>", "code": "RPC_ERROR"}. The proxy keeps only the error text, for an object of at most 4096 bytes. |
| Self-hosted PostgREST | HTTP 200 with the whole object, including keys such as error_code and hint. |
A raised error has this body:
{
"code": "P0001",
"details": null,
"hint": "This project has run, so it cannot be changed. Copy it with \"benchctl project copy\" or Save as New in the project editor, then change the copy.",
"message": "project_executed"
}
code is the PostgreSQL SQLSTATE, or a PostgREST code that starts with
PGRST. When message is a machine code such as project_executed, hint
holds the sentence to show a person.
code | Meaning | HTTP status |
|---|---|---|
P0001 | Raised with no specific code | 400 |
22023 | Invalid parameter value | 400 |
42501 | Insufficient privilege, including a permission map denial | 403, or 401 without a token |
23505 | Unique violation | 409 |
PT404 | Not found, such as Project not found from the project editor RPCs | 404 |
P0002 | No data found, raised by older RPCs | 500 |
PGRST202 | No function with this name and these parameter names | 404 |
PostgREST returns HTTP 500 for P0002. Some older RPCs still raise it for a
missing record, so read code, not only the status, to tell a missing record
from a server failure.
OpenAPI document
PostgREST serves an OpenAPI 2.0 document at the root of the PostgREST URL.
Request it with Accept: application/openapi+json. The document lists every
RPC and view with its parameters. The hosted /api/postgrest proxy forwards
only paths below it, so read the document from a PostgREST URL that you can
reach directly. You can generate a client from the document with any
OpenAPI 2.0 generator.
See also
- Quickstart: the web app version of the same flow.
- User Guide: workflows that combine several API calls.
- Feature Reference: settings per feature.
- API section: parameter references per workflow.