Skip to content
AI agents

Read a saved run via the REST API and CLI.

Fetch metrics, target allocations, look-through trees, and side-by-side run comparisons from ENSEMBLE using the /v1 REST API or ensemble CLI.

By Updated 2 min read

An interactive chat session is great for exploring a strategy idea, but production research workflows eventually need deterministic scripts, notebooks, or downstream dashboards that read exact saved records without re-running a backtest.

ENSEMBLE's web app, MCP server, REST API, and CLI all share the same canonical /v1 resource model. Every saved run gets a stable ID (run_...) that you can read repeatedly for free.

Authenticate once across API and CLI

Generate an API key from Connections in your ENSEMBLE dashboard and export it to your shell environment. Keep API keys server-side and never commit them to source control:

export ENSEMBLE_API_KEY="YOUR_API_KEY"

Install or invoke the first-party CLI directly from ENSEMBLE's published tarball (check /cli for the current version) and verify your connected account:

ensemble account
ensemble schema

ensemble schema prints the live command contract so scripts and coding agents can discover flags and response shapes directly.

Inspecting a saved run with include blocks

Rather than downloading a massive monolithic payload every time, GET /v1/runs/{run_id} accepts granular include parameters:

include valueWhat it returnsCommon use case
latestLatest target decision, decision date, simulated current holdings, and look-through treeDaily rebalance checks and broker export pipelines
metricsCAGR, annualized volatility, max drawdown, and Sharpe (CAGR / vol, rf=0) for the requested windowReporting tables and committee summaries
returnsDated daily return series for the selected display windowCustom charts and external risk analytics
allocationHistorical allocation weights over timeTurnover audits and regime-behavior review
treeExpanded parent-to-child look-through weights for composed modelsAuditing sleeve dependencies and member data dates
feesNet-of-fee daily returns overlaid using requested fee parameters (Business)Net-of-cost reporting alongside gross returns
contributionAsset-level return contribution over the windowAttribution breakdowns
resultRaw stored backtest recordArchival inspection and auditing

REST API examples

# 1. Read a model's latest target allocation and data date
curl "https://api.ensemble.markets/v1/models/MODEL_ID/history?include=latest,metrics" \
  -H "Authorization: Bearer $ENSEMBLE_API_KEY"

# 2. Read a specific retained run over an explicit display window
curl "https://api.ensemble.markets/v1/runs/RUN_ID?include=metrics,latest&start_date=2020-01-01" \
  -H "Authorization: Bearer $ENSEMBLE_API_KEY"

# 3. Compare two retained runs side by side over their common period
curl "https://api.ensemble.markets/v1/runs/compare?run_ids=RUN_A,RUN_B" \
  -H "Authorization: Bearer $ENSEMBLE_API_KEY"

Equivalent CLI commands

# Inspect model metadata and declared inputs_schema
ensemble models get MODEL_ID -o json

# Read latest target weights and metrics in a shell pipeline
ensemble models history MODEL_ID --include latest,metrics -o json | jq '.latest.target'

# Export a retained run's target book as CSV (or altruist/ibkr on Business)
ensemble models export MODEL_ID --format csv --run-id RUN_ID

Reading display windows without re-running

Passing start_date or end_date on GET /v1/runs/{run_id} or GET /v1/models/{model}/history slices the display window on the existing stored result. It never triggers a new compute job or changes your model's defaults. Always check the returned period alongside summary_period so your downstream reports label exact observation dates honestly.

Continue with your agent

Use the workflow below to inspect one of your saved models, retrieve the exact CLI and API calls for its latest run, and wire the output into your reporting or automation scripts.

Start with this request

Use ENSEMBLE to confirm my connected account. Inspect one of my saved models and its latest run, show the equivalent REST API and CLI commands to read its target allocations and metrics, and explain how scheduled refreshes and Business webhooks fit into an automated review pipeline.

Frequently asked questions

Do REST API and CLI reads of saved models and runs consume metered credit?
No. Reading the asset catalog, inspecting model metadata, fetching saved run results, comparing retained runs, and downloading CSV or JSON exports are free on every plan. Metered usage applies only to builds, runs, and enabled refreshes.
Which include blocks can I request on GET /v1/runs/{run_id}?
You can request result (raw stored backtest), history (windowed returns and metrics), or individual history blocks: returns, allocation, tree, latest, custom, metrics, fees, and contribution. Requesting only the blocks you need keeps payloads fast and compact.
How do I compare two to eight retained runs programmatically?
Call GET /v1/runs/compare?run_ids=RUN_A,RUN_B (or use the CLI runs compare command). ENSEMBLE aligns the selected runs over their common date period, surfaces the exact inputs that differ, and returns matched-window performance metrics.
Does the CLI work in shell pipelines and CI scripts?
Yes. The ensemble CLI outputs readable tables in an interactive terminal and structured JSON automatically when piped (or when passed -o json), sending diagnostics to stderr so stdout parses cleanly with jq or Python.

Backtests are illustrative. Past performance does not guarantee future results. ENSEMBLE is a software platform, not an investment adviser.

Part of Keep investment research available across conversations..

Use the same models across MCP, REST API, CLI, and the web.Connect your agent