Skip to main content

Simulation

Backend API​

Local and Pod execution share request progress reporting through llm_d_lens.simulation.progress.report_request_progress. Pod reporting still waits for readiness; local reporting retains its original start time. Backend adapters share artifact error formatting through backends.analytics.artifact_error_message, while retaining their own error/timeout field precedence, status mapping, and metric units. Task APIs and backend environment preparation are unchanged.

Simulation routes live in llm_d_lens/simulation/router.py under the /api/simulation prefix.

List simulation backends​

List Simulation backends Lens knows about and whether each backend is available in the current environment.

GET /api/simulation/backends

Request: no body.

Response:

{
"backends": [
{
"name": "aiperf",
"display_name": "AIPerf",
"api_version": 1,
"available": true,
"version": "0.12.0",
"unavailable_reason": null,
"scenarios": [
{
"name": "chat",
"display_name": "Chat",
"description": "Conversational and general assistant traffic.",
"supported_backends": []
},
{
"name": "api-calling",
"display_name": "Tool & API Use",
"description": "Tool-use, agent, and business API traffic.",
"supported_backends": []
}
],
"capabilities": {
"prompt_kinds": ["trace"],
"arrival_patterns": [],
"supports_duration": true,
"supports_request_count": false,
"supports_request_rate": false,
"supports_streaming": true,
"supports_per_request_results": true,
"supports_cancellation": true,
"supports_trace_range": true,
"scale_factor_trace_formats": ["baseten_trace"],
"trace_format_capabilities": {
"mooncake_trace": {"supports_trace_range": true, "supports_scale_factor": false}
},
"advanced_options": [],
"trace_formats": [
"mooncake_trace",
"bailian_trace",
"baseten_trace",
"burst_gpt_trace",
"weka_public_dataset"
]
},
"managed_installation": false
}
]
}

Discover endpoint models​

Probe a model endpoint and discover which models it reports. The optional api_key is sent as a Bearer token and is not included in the response. Failed connectivity, authentication, or invalid model lists return HTTP 400.

POST /api/simulation/models/discover

Request body: ModelDiscoveryRequest

  • endpoint_url (string, required)
  • api_key (string, optional, maximum 4096 characters; used only for this request)
{
"endpoint_url": "http://127.0.0.1:38000/v1"
}

Response:

{
"endpoint": "http://127.0.0.1:38000/v1",
"models": [
"Qwen/Qwen3-8B",
"Qwen/Qwen3-8B-Instruct"
]
}

List simulation scenarios​

List the simulation scenario catalog Lens exposes, such as chat, API-calling, and coding.

GET /api/simulation/scenarios

Request: no body.

Response:

{
"scenarios": [
{
"name": "chat",
"display_name": "Chat",
"description": "Conversational and general assistant traffic.",
"supported_backends": ["aiperf", "trace-replayer"]
},
{
"name": "coding",
"display_name": "Code Generation",
"description": "Code generation and software engineering traffic.",
"supported_backends": ["aiperf"]
}
]
}

List trace datasets​

List registered trace datasets and the backends that can replay each one.

GET /api/simulation/trace-datasets

Request: no body.

Response:

{
"data_dir": "/home/prism/.local/share/prism/data/datasets",
"datasets": [
{
"name": "mooncake-arxiv",
"filename": "mooncake_trace.jsonl",
"scenario": "chat",
"trace_format": "mooncake_trace",
"description": "Mooncake chat trace derived from Arxiv summarization prompts.",
"downloaded": false,
"path": "/home/prism/.local/share/prism/data/datasets/mooncake_trace.jsonl",
"artifact_uri": "artifact://dataset/mooncake-arxiv/mooncake_trace.jsonl",
"size_bytes": null,
"license": "Apache-2.0",
"sha256": "f0c15fb14b60d0afca8b1f7c1ff29378f3df54318e6d112b47ad3b2a2f5881ef",
"source_repository": "https://github.com/kvcache-ai/Mooncake.git",
"supported_backends": ["aiperf", "trace-replayer"]
}
]
}

Download a trace dataset​

Download a registered trace dataset into Lens's local trace store.

POST /api/simulation/trace-datasets/download

Request body: TraceDatasetDownloadRequest

  • dataset (string, required)
  • force (boolean, default false)
{
"dataset": "mooncake-arxiv",
"force": false
}

Response:

{
"artifact_uri": "artifact://dataset/mooncake-arxiv/mooncake_trace.jsonl",
"path": "/home/prism/.local/share/prism/data/datasets/mooncake_trace.jsonl",
"trace_format": "mooncake_trace",
"sha256": "f0c15fb14b60d0afca8b1f7c1ff29378f3df54318e6d112b47ad3b2a2f5881ef",
"metadata_path": "/home/prism/.local/share/prism/data/datasets/mooncake_trace.jsonl.metadata.json",
"size_bytes": 1048576
}

Get a trace dataset timeline​

Get a pre-aggregated timeline view for one trace dataset.

GET /api/simulation/trace-datasets/{dataset_name}/timeline

Request: no body.

  • Path parameter: dataset_name (string, required)
  • Query parameter: bins (integer, default 800, range 50-2000)

Response:

{
"dataset": "mooncake-arxiv",
"trace_format": "mooncake_trace",
"request_count": 12000,
"duration_seconds": 3600.0,
"source_size_bytes": 1048576,
"bin_width_seconds": 4.5,
"bins": [
{"start_seconds": 0.0, "end_seconds": 4.5, "request_count": 12},
{"start_seconds": 4.5, "end_seconds": 9.0, "request_count": 18}
]
}

List simulation tasks​

List Simulation tasks with optional filters for status, scenario, backend, model, dataset, endpoint, and creation window.

GET /api/simulation/tasks

Request: no body.

  • Query parameters: status, scenario, search, backend, model, dataset, trace_format, endpoint, created_after, created_before, offset, limit.

Response:

{
"tasks": [
{
"id": "1a2b3c4d",
"name": "Trace simulation",
"description": "Replay a chat trace against a ready deployment",
"scenario": "chat",
"status": "running",
"endpoint_mode": "deployment",
"endpoint_namespace": "prism-sim",
"endpoint_service": "qwen-router",
"endpoint_deployment_execution_id": "00000000-0000-4000-8000-000000000001",
"endpoint_deployment_run_id": null,
"endpoint_deployment_case_id": null,
"endpoint_cluster_id": "cluster-1",
"endpoint_cluster_name": "dev-cluster",
"endpoint_deployment_name": "qwen3-guide",
"endpoint_url": "http://127.0.0.1:38000/v1",
"model_name": "Qwen/Qwen3-8B",
"simulation": {
"backend": "trace-replayer",
"backend_options": {},
"duration_seconds": 60.0,
"num_requests": null,
"stream": true,
"warmup_enabled": false,
"grace_period_seconds": 30.0
},
"prompt": {
"type": "trace",
"dataset": {"name": "mooncake-arxiv", "scenario": "chat", "tokenizer": null},
"trace": {
"path": "/home/prism/.local/share/prism/data/datasets/mooncake_trace.jsonl",
"format": "mooncake_trace",
"fixed_schedule": true,
"timeout_seconds": 3600.0,
"synthesis_speedup_ratio": 1.0,
"start_seconds": 0.0,
"end_seconds": null
}
},
"task_dir": "/home/prism/.local/share/prism/data/artifacts/simulations/1a2b3c4d",
"artifact_uri": null,
"artifact_error": null,
"logs_truncated": false,
"artifacts_incomplete": false,
"backend_version_inferred": false,
"backend_version": null,
"configuration_ids": ["config-1"],
"progress_percent": 42.5,
"progress_message": "Simulation running",
"logs": [],
"result": null,
"error_message": null,
"created_at": "2026-09-23T09:18:24.287000Z",
"started_at": "2026-09-23T09:18:25.000000Z",
"execution_started_at": "2026-09-23T09:18:27.000000Z",
"completed_at": null,
"owner_pid": null,
"owner_instance_id": null,
"live_summary": {
"completed_requests": 420,
"successful_requests": 418
}
}
],
"total": 1,
"offset": 0,
"limit": 10,
"counts": {
"queued": 0,
"running": 1,
"completed": 0,
"failed": 0,
"cancelled": 0
},
"facets": {
"backends": ["trace-replayer"],
"models": ["Qwen/Qwen3-8B"],
"datasets": ["mooncake-arxiv"],
"trace_formats": ["mooncake_trace"],
"endpoints": ["http://127.0.0.1:38000/v1"]
}
}

Create a simulation task​

For Endpoint URL targets (endpoint_mode != "deployment"), the service checks /v1/models with the supplied api_key before persisting or scheduling the task. A failed check returns HTTP 400; direct Python calls raise SimulationConfigurationError. Manual model names do not bypass this check. Deployment-bound Model Service tasks retain their cluster execution path.

Create a Simulation task that replays a trace dataset against a target model endpoint.

POST /api/simulation/tasks

Request body: SimulationTaskCreateRequest

  • name, description, scenario, backend, endpoint_mode
  • cluster_session_id, endpoint_namespace, endpoint_service, endpoint_deployment_execution_id, endpoint_cluster_id, endpoint_cluster_name, endpoint_deployment_name
  • model_service_group_id (string, optional) — target a published, continuously health-probed Model Service instead of a raw deployment execution. When set, the backend resolves it to the group's active member and published name and forces endpoint_mode to "deployment", overriding any supplied endpoint_deployment_execution_id/model_name. Requires api_key.
  • api_key (string, optional) — model access token; required when model_service_group_id is set.
  • endpoint_url, model_name, trace_dataset, trace_path
  • duration_seconds, scale_factor, trace_start_seconds, trace_end_seconds, trace_timeout_seconds, fixed_schedule, stream, backend_options
{
"name": "Trace simulation",
"description": "Replay a chat trace against a ready deployment",
"scenario": "chat",
"backend": "trace-replayer",
"endpoint_mode": "deployment",
"cluster_session_id": "123e4567-e89b-12d3-a456-426614174000",
"endpoint_namespace": "prism-sim",
"endpoint_service": "qwen-router",
"endpoint_deployment_execution_id": "00000000-0000-4000-8000-000000000001",
"endpoint_cluster_id": "cluster-1",
"endpoint_cluster_name": "dev-cluster",
"endpoint_deployment_name": "qwen3-guide",
"endpoint_url": "http://127.0.0.1:38000/v1",
"model_name": "Qwen/Qwen3-8B",
"trace_dataset": "mooncake-arxiv",
"trace_path": "/home/prism/.local/share/prism/data/datasets/mooncake_trace.jsonl",
"duration_seconds": 60,
"scale_factor": 1,
"trace_start_seconds": 0,
"trace_end_seconds": null,
"trace_timeout_seconds": 3600,
"fixed_schedule": true,
"stream": true,
"backend_options": {}
}

To target a published Model Service instead, set model_service_group_id and api_key; the backend discards the supplied endpoint_deployment_execution_id/endpoint_url/model_name and re-resolves them from the group's active member (a syntactically valid placeholder URL still satisfies request validation):

{
"name": "Trace simulation",
"scenario": "chat",
"backend": "trace-replayer",
"endpoint_mode": "deployment",
"model_service_group_id": "01998e6b-4b2e-7c7e-8c6d-8e2a3f0c9b11",
"api_key": "lens-mk-…",
"endpoint_url": "http://model-service.internal",
"model_name": "qwen3-8b",
"trace_dataset": "mooncake-arxiv",
"trace_path": "/home/prism/.local/share/prism/data/datasets/mooncake_trace.jsonl"
}

Response:

{
"task_id": "1a2b3c4d",
"status": "queued",
"task": {
"id": "1a2b3c4d",
"name": "Trace simulation",
"description": "Replay a chat trace against a ready deployment",
"scenario": "chat",
"status": "queued",
"endpoint_mode": "deployment",
"endpoint_namespace": "prism-sim",
"endpoint_service": "qwen-router",
"endpoint_deployment_execution_id": "00000000-0000-4000-8000-000000000001",
"endpoint_deployment_run_id": null,
"endpoint_deployment_case_id": null,
"endpoint_cluster_id": "cluster-1",
"endpoint_cluster_name": "dev-cluster",
"endpoint_deployment_name": "qwen3-guide",
"endpoint_url": "http://127.0.0.1:38000/v1",
"model_name": "Qwen/Qwen3-8B",
"simulation": {
"backend": "trace-replayer",
"backend_options": {},
"duration_seconds": 60.0,
"num_requests": null,
"stream": true,
"warmup_enabled": false,
"grace_period_seconds": 30.0
},
"prompt": {
"type": "trace",
"dataset": {"name": "mooncake-arxiv", "scenario": "chat", "tokenizer": null},
"trace": {
"path": "/home/prism/.local/share/prism/data/datasets/mooncake_trace.jsonl",
"format": "mooncake_trace",
"fixed_schedule": true,
"timeout_seconds": 3600.0,
"synthesis_speedup_ratio": 1.0,
"start_seconds": 0.0,
"end_seconds": null
}
},
"task_dir": "/home/prism/.local/share/prism/data/artifacts/simulations/1a2b3c4d",
"artifact_uri": null,
"artifact_error": null,
"logs_truncated": false,
"artifacts_incomplete": false,
"backend_version_inferred": false,
"backend_version": null,
"configuration_ids": ["config-1"],
"progress_percent": 0.0,
"progress_message": "Queued",
"logs": [],
"result": null,
"error_message": null,
"created_at": "2026-09-23T09:18:24.287000Z",
"started_at": null,
"execution_started_at": null,
"completed_at": null,
"owner_pid": null,
"owner_instance_id": null
}
}

Get a simulation task​

Get one Simulation task by id, including progress, logs, and result artifacts when they exist.

Artifact publication status and errors, log truncation, artifact completeness, backend version provenance, and configuration IDs persist with the task in the database. An artifact URI is returned only after publication has been recorded; an older on-disk manifest alone does not make an unpublished result available.

GET /api/simulation/tasks/{task_id}

Request: no body.

  • Path parameter: task_id (string, required)

Response:

{
"id": "1a2b3c4d",
"name": "Trace simulation",
"description": "Replay a chat trace against a ready deployment",
"scenario": "chat",
"status": "completed",
"endpoint_mode": "deployment",
"endpoint_namespace": "prism-sim",
"endpoint_service": "qwen-router",
"endpoint_deployment_execution_id": "00000000-0000-4000-8000-000000000001",
"endpoint_deployment_run_id": null,
"endpoint_deployment_case_id": null,
"endpoint_cluster_id": "cluster-1",
"endpoint_cluster_name": "dev-cluster",
"endpoint_deployment_name": "qwen3-guide",
"endpoint_url": "http://127.0.0.1:38000/v1",
"model_name": "Qwen/Qwen3-8B",
"simulation": {
"backend": "trace-replayer",
"backend_options": {},
"duration_seconds": 60.0,
"num_requests": null,
"stream": true,
"warmup_enabled": false,
"grace_period_seconds": 30.0
},
"prompt": {
"type": "trace",
"dataset": {"name": "mooncake-arxiv", "scenario": "chat", "tokenizer": null},
"trace": {
"path": "/home/prism/.local/share/prism/data/datasets/mooncake_trace.jsonl",
"format": "mooncake_trace",
"fixed_schedule": true,
"timeout_seconds": 3600.0,
"synthesis_speedup_ratio": 1.0,
"start_seconds": 0.0,
"end_seconds": null
}
},
"task_dir": "/home/prism/.local/share/prism/data/artifacts/simulations/1a2b3c4d",
"artifact_uri": "artifact://simulation/1a2b3c4d",
"artifact_error": null,
"logs_truncated": false,
"artifacts_incomplete": false,
"backend_version_inferred": false,
"backend_version": "0.2.0",
"configuration_ids": ["config-1"],
"progress_percent": 100.0,
"progress_message": "Simulation completed",
"logs": ["Starting trace-replayer", "Simulation completed"],
"result": {
"run_id": "trace-replayer-1",
"backend": "trace-replayer",
"backend_version": "0.2.0",
"summary": {
"throughput_tps": 1180.4,
"success_rate": 99.8,
"completion_timeline": []
},
"artifacts": [
{
"uri": "artifact://simulation/1a2b3c4d/summary.json",
"kind": "summary-json",
"path": "/home/prism/.local/share/prism/data/artifacts/simulations/1a2b3c4d/summary.json",
"media_type": "application/json"
}
],
"per_request": [
{
"request_id": 1,
"status_code": 200,
"successful": true,
"error": null,
"started_at_seconds": 0.0,
"completed_at_seconds": 0.42,
"latency_ms": 420.0,
"ttft_ms": 110.0,
"tpot_ms": 8.3,
"input_tokens": 512.0,
"output_tokens": 128.0,
"metadata": {}
}
],
"backend_metrics": {},
"warnings": []
},
"error_message": null,
"created_at": "2026-09-23T09:18:24.287000Z",
"started_at": "2026-09-23T09:18:25.000000Z",
"execution_started_at": "2026-09-23T09:18:27.000000Z",
"completed_at": "2026-09-23T09:19:32.000000Z",
"owner_pid": null,
"owner_instance_id": null
}

Download a simulation artifact​

Download a saved simulation artifact by task id and artifact kind as a file attachment.

GET /api/simulation/tasks/{task_id}/artifacts/{kind}

Request: no body.

  • Path parameters: task_id (string, required), kind (string, required)

Response: file attachment streamed from the saved artifact path. No JSON body is returned. The task's result.artifacts list tells you which kind values are available.

Get response-code issues for a simulation task​

Get requests from a Simulation task that returned a specific HTTP status code.

GET /api/simulation/tasks/{task_id}/response-code-issues

Request: no body.

  • Path parameter: task_id (string, required)
  • Query parameters: status_code (string, required; use unknown for missing status), offset (integer, default 0), limit (integer, default 100, max 500)

Response:

{
"task_id": "1a2b3c4d",
"status_code": 500,
"issues": [
{
"request_number": 12,
"request_id": 12,
"status_code": 500,
"error": "Transport error: upstream reset the connection",
"started_at_seconds": 14.2,
"latency_ms": 982.5,
"input_tokens": 512.0,
"output_tokens": 0.0
}
],
"total": 1,
"offset": 0,
"limit": 100
}

Stop a simulation task​

Stop an active Simulation task.

POST /api/simulation/tasks/{task_id}/stop

Request: no body.

  • Path parameter: task_id (string, required)

Response:

{
"task_id": "1a2b3c4d",
"status": "cancelling"
}

Rerun a simulation task​

For Endpoint URL targets (endpoint_mode != "deployment"), the service checks /v1/models with the supplied api_key before persisting or scheduling the task. A failed check returns HTTP 400; direct Python calls raise SimulationConfigurationError. Manual model names do not bypass this check. Deployment-bound Model Service tasks retain their cluster execution path.

Queue a rerun of a previous Simulation task, optionally rebinding it to a fresh endpoint or deployment execution.

POST /api/simulation/tasks/{task_id}/rerun

Request body: SimulationTaskRerunRequest (optional)

  • Path parameter: task_id (string, required)
  • Optional body fields: endpoint_url, endpoint_deployment_execution_id, endpoint_cluster_id, endpoint_cluster_name, endpoint_deployment_name
  • model_service_group_id (string, optional) — re-bind to a published, health-probed Model Service instead of a raw deployment execution; resolved the same way as on task creation and preferred over endpoint_deployment_execution_id when both are supplied.
{
"endpoint_url": "http://127.0.0.1:39000/v1",
"endpoint_deployment_execution_id": "00000000-0000-4000-8000-000000000002",
"endpoint_cluster_id": "cluster-1",
"endpoint_cluster_name": "dev-cluster",
"endpoint_deployment_name": "qwen3-guide-rerun"
}

Response:

{
"task_id": "5e6f7a8b",
"status": "queued",
"task": {
"id": "5e6f7a8b",
"name": "Trace simulation · rerun 5e6f7a8b",
"description": "Replay a chat trace against a ready deployment",
"scenario": "chat",
"status": "queued",
"endpoint_mode": "deployment",
"endpoint_namespace": "prism-sim",
"endpoint_service": "qwen-router",
"endpoint_deployment_execution_id": "00000000-0000-4000-8000-000000000002",
"endpoint_deployment_run_id": null,
"endpoint_deployment_case_id": null,
"endpoint_cluster_id": "cluster-1",
"endpoint_cluster_name": "dev-cluster",
"endpoint_deployment_name": "qwen3-guide-rerun",
"endpoint_url": "http://127.0.0.1:39000/v1",
"model_name": "Qwen/Qwen3-8B",
"simulation": {
"backend": "trace-replayer",
"backend_options": {},
"duration_seconds": 60.0,
"num_requests": null,
"stream": true,
"warmup_enabled": false,
"grace_period_seconds": 30.0
},
"prompt": {
"type": "trace",
"dataset": {"name": "mooncake-arxiv", "scenario": "chat", "tokenizer": null},
"trace": {
"path": "/home/prism/.local/share/prism/data/datasets/mooncake_trace.jsonl",
"format": "mooncake_trace",
"fixed_schedule": true,
"timeout_seconds": 3600.0,
"synthesis_speedup_ratio": 1.0,
"start_seconds": 0.0,
"end_seconds": null
}
},
"task_dir": "/home/prism/.local/share/prism/data/artifacts/simulations/5e6f7a8b",
"artifact_uri": null,
"artifact_error": null,
"logs_truncated": false,
"artifacts_incomplete": false,
"backend_version_inferred": false,
"backend_version": null,
"configuration_ids": ["config-2"],
"progress_percent": 0.0,
"progress_message": "Queued",
"logs": [],
"result": null,
"error_message": null,
"created_at": "2026-09-23T09:25:24.287000Z",
"started_at": null,
"execution_started_at": null,
"completed_at": null,
"owner_pid": null,
"owner_instance_id": null
}
}

Delete a simulation task​

Delete a Simulation task record.

DELETE /api/simulation/tasks/{task_id}

Request: no body.

  • Path parameter: task_id (string, required)

Response:

{
"task_id": "1a2b3c4d",
"status": "deleted"
}

See the full request/response schemas in the FastAPI OpenAPI schema (regenerate with npm run docs:api).