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 value | What it returns | Common use case |
|---|---|---|
latest | Latest target decision, decision date, simulated current holdings, and look-through tree | Daily rebalance checks and broker export pipelines |
metrics | CAGR, annualized volatility, max drawdown, and Sharpe (CAGR / vol, rf=0) for the requested window | Reporting tables and committee summaries |
returns | Dated daily return series for the selected display window | Custom charts and external risk analytics |
allocation | Historical allocation weights over time | Turnover audits and regime-behavior review |
tree | Expanded parent-to-child look-through weights for composed models | Auditing sleeve dependencies and member data dates |
fees | Net-of-fee daily returns overlaid using requested fee parameters (Business) | Net-of-cost reporting alongside gross returns |
contribution | Asset-level return contribution over the window | Attribution breakdowns |
result | Raw stored backtest record | Archival 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.
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.
Related
- AI agentsAutomate model refreshes with the API and webhooks.
Combine scheduled ENSEMBLE refreshes, Business HMAC-signed webhooks, and REST allocation exports to automate model review and reporting pipelines.
- AI agentsAn MCP server for investment research you can return to.
Give your agent access to asset research, allocation models and saved runs. Work through a supported client while ENSEMBLE keeps the underlying records.
- AI agentsQuant workflows with Cursor and Claude Code.
Pair Cursor or Claude Code with ENSEMBLE's remote MCP server and CLI to author custom Python strategies, validate free, and maintain reusable optimizers.
- BacktestingRead a backtest in context.
Understand annualized return, volatility, drawdown and ENSEMBLE’s Sharpe convention. Use the saved run’s dates and assumptions when comparing results.