Skip to main content

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:

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.

DeploymentBase URL
Hosted control planehttps://<control-plane-host>/api/postgrest
Self-hosted stack that exposes PostgRESTThe 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:

  1. Open Settings > Tokens (/settings/tokens) in the web app.
  2. Under Personal API Tokens, name the token, pick an expiry, and generate it.
  3. 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:

Resourceowneradminmemberviewer
projectallread, write, delete, executeread, write, executeread
joballread, execute, cancelread, executeread
kyaiallread, write, executeread, write, executeread
serverallread, writeread, writeread
cluster_groupread, writeread, writeread, writeread
pulse_viewread, writeread, writeread, writeread

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 typeResponse body
RETURNS TABLEA JSON array of row objects.
RETURNS JSONThe 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.

RPCPurposePermission
get_current_user_contextYour account and workspaces.not in the map
list_projectsProjects you can see, each with project_uuid.project:read
get_project_by_nameOne project by owner and exact name, with project_uuid.project:read
create_projectCreate an empty project.project:write
get_project_edit_stateWhether a project has run, its revision, and its source project.project:read
list_project_edit_workloadsSaved workload settings, machines, and BYOE endpoint details.project:read
list_project_edit_scenariosSaved scenarios with every tool setting.project:read
save_project_configCreate, update in place, or save as new, for every workload type, in one transaction.project:write
preflight_project_runPlan, hardware, machine, and endpoint checks before a run.project:read
copy_projectCopy a project with every saved setting.project:write
execute_project_runRun a project or one of its workloads.project:execute

Workloads, scenarios, and jobs​

RPCPurposePermissionReference
create_workloadAdd one workload to a project that never ran.project:writemetrumbench-llm
create_scenarioAdd one scenario to a workload.project:writemetrumbench-llm
execute_scenarioStart one scenario on one machine.job:executeEnd-to-end example
create_metrumbench_llm_jobCreate one MetrumBench LLM job and its run directly. Returns job_id, run_id, and run_name.job:executeOpenAPI
get_job_status(p_job_id)Status of one job: status_code, status_name, status_changed_at.not in the mapThis page
list_jobs_filteredJobs filtered by p_project_id, p_server_config_instance_id, p_status_code, and p_limit (default 20).not in the mapOpenAPI

KYAI​

RPCPurposeReference
create_kyai_candidate_endpoint, list_kyai_candidate_endpointsCandidate endpoints.KYAI Workload And Run
create_kyai_workload, create_kyai_scenarioA KYAI workload and its datasets.KYAI Workload And Run
create_kyai_generation_runGeneration job. Takes p_project_uuid, and uses the prompts saved with the workload first.KYAI Workload And Run
create_kyai_judge_runJudge job in the generation job's project.KYAI Workload And Run
list_kyai_judge_configsJudge 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.

RPCPurposePermission
list_kv_cache_tiers_for_recipeThe tiers and the settings each one uses.catalog:read
create_workload with p_kv_cache_tier_codeA workload with its tier and the tier's settings.project:write
create_scenario with p_job_paramsUsers, token lengths, num_rounds (5 or more, default 25), and dataset.project:write
update_scenario, update_scenario_by_codeChange a scenario, with the same rules.project:write
execute_scenario with p_gpu_countRun on one machine.job:execute
list_multiroundqa_outputs_for_jobResults 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.

RPCPurposePermission
list_cluster_groups, create_cluster_groupCluster groups of a workspace.membership check, cluster_group:write
list_kv_cache_tiers_for_recipeKV cache tiers for a tool and engine.catalog:read
preview_distributed_kv_topologyThe per-machine plan before you save.cluster_group:read
save_project_config with distributed_kvSave a distributed KV workload.project:write
upsert_workload_distributed_kv_config, get_workload_distributed_kv_configChange or read the settings of a saved workload.cluster_group:write, cluster_group:read
execute_project_runRun on the cluster group, or join its queue.project:execute
get_distributed_kv_run_statusPool and per-machine state of a run.cluster_group:read
get_run_cluster_queue_state, stop_project_execution_queuePlace in the queue, and stop a queue.project:read, project:execute
get_distributed_kv_run_report, list_distributed_kv_workload_resultsResults 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.

RPCPurposePermission
pulse_list_source_jobsOne page of runs you can put in a View, with search, filters, dates, and groups.pulse_view:read
pulse_list_curator_facetsRun counts per tool, project, and status.pulse_view:read
pulse_list_filtered_job_idsEvery matching job id, at most 5000.pulse_view:read
pulse_list_private_project_optionsPrivate projects you may include.pulse_view:read
pulse_create_view, pulse_add_jobs_to_viewCreate a View or add runs, with optional whole source projects.pulse_view:write
pulse_update_viewChange a View you own.pulse_view:write
pulse_get_view, pulse_get_view_dataView metadata, and its chart and table data.pulse_view:read
pulse_list_new_source_runsRuns 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.

RoutePurpose
GET /api/public/v1/leaderboard/optionsThe models, precisions, and workload presets that have entries, and the defaults.
GET /api/public/v1/leaderboardRanked 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​

RPCPurposeReference
list_server_config_instancesMachines of a workspace.Distributed KV Cache
create_server_config, create_server_config_gpu, create_server_config_instanceRegister a machine.End-to-end example
validate_server_readinessReadiness checks of a machine.End-to-end example
record_server_config_instance_heartbeatHeartbeat. The agent calls it.OpenAPI

Plans and features​

RPCPurposePermission
list_self_serve_plansSelf-serve plans with their Stripe price items.not in the map
get_plan_featuresFeature 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​

ViewWhat it returns
v_job_current_statusLatest status per job
v_job_status_historyFull status timeline per job
v_run_jobs_with_paramsRun jobs joined with their parameters
v_project_run_current_statusLatest run status per project
v_project_runs_with_statusRuns with their current status
v_run_cost_summaryAggregated cost per run
v_run_health_checksPre-run and post-run validation outcomes for a run

Results​

ViewWhat it returns
v_benchmark_resultsBenchmark results across all tools
v_metrumbench_llm_outputsLLM result detail
v_metrumbench_vlm_outputsVLM result detail
v_metrumbench_asr_outputsASR result detail
v_inferencex_outputsInferenceX capacity estimates

Comparison and leaderboards​

ViewWhat it returns
v_throughput_leaderboardRanked leaderboard
v_model_comparisonCross-model performance comparison
v_framework_comparisonCross-framework comparison
v_quantization_comparisonQuantization impact analysis
v_concurrency_scalingConcurrency compared with throughput and latency
v_cost_efficiencyTokens per dollar and tokens per hour
v_hardware_utilizationAggregated telemetry per job

Telemetry​

ViewWhat it returns
v_telemetry_with_serverTime-series telemetry joined with server info
v_telemetry_job_summaryAggregated telemetry per job
v_telemetry_per_gpu_summaryPer-GPU breakdown
v_tpu_telemetry_job_summaryTPU-specific aggregates

KYAI​

ViewWhat it returns
v_kyai_jobsKYAI job listing
v_kyai_outputsScored outputs: instruction, response, score
v_kyai_generation_outputsPhase 1 generations
v_kyai_resultsAggregated KYAI results
v_kyai_leaderboardKYAI ranking
v_kyai_builtin_sets_with_prompt_countBuilt-in prompt set catalog

Cloud and audit​

ViewWhat it returns
v_cloud_resource_lifecycleCloud resource state transitions
v_audit_logsAudit 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.

FormWhat you receive
Raised errorA non-2xx response with the PostgREST error body below.
Error objectAn 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 URLResponse
Hosted /api/postgrestHTTP 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 PostgRESTHTTP 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.

codeMeaningHTTP status
P0001Raised with no specific code400
22023Invalid parameter value400
42501Insufficient privilege, including a permission map denial403, or 401 without a token
23505Unique violation409
PT404Not found, such as Project not found from the project editor RPCs404
P0002No data found, raised by older RPCs500
PGRST202No function with this name and these parameter names404

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​