ManticDocs
Scenarios

Forecast with your own context

Run a forecast that takes your facts or assumptions into account, wait for it to complete, and compare it with the forecast without them.

Rerun a forecast with your own facts or assumptions, and compare it with the forecast everyone else sees. This is beta only.

Full script: forecast_with_context.py.

Each request starts a full run, private to your organisation. Once it completes, it becomes your latest_forecast and joins the forecast's history, while everyone else keeps the forecast without it. Only the beta channel marks which runs used context.

Start the forecast

Send your context to POST /beta/questions/{question_id}/forecasts:

curl "https://api.mantic.com/beta/questions/QUESTION_ID/forecasts" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"additional_context": "Assume the US and China announce a trade deal in mid-November 2026, in which China agrees to resume large purchases of US farm goods."}'

The response is 202 with the new run's ID:

{ "id": 348536 }
response = client.request(
    "POST",
    f"/beta/questions/{question_id}/forecasts",
    json={"additional_context": context},
)
return response.json()["id"]

additional_context is plain text, up to 20,000 characters. Label assumptions as hypothetical, so the forecaster doesn't weigh them as evidence.

  • 409: a run of this forecast, possibly someone else's, is already in progress. Try again later.
  • 422: the forecast can't run now, because it has resolved or is no longer active, or its scheduled release has passed.

Wait for it to complete

The run happens in the background and usually takes several minutes. GET /beta/forecasts/{forecast_id} returns 404 until it completes, then the run in the same shape as any other. It also returns 404 if the run fails, so the script gives up after 45 minutes:

deadline = time.monotonic() + timeout
while True:
    try:
        return client.request("GET", f"/beta/forecasts/{forecast_id}").json()
    except httpx.HTTPStatusError as error:
        if error.response.status_code != 404:
            raise
    if time.monotonic() > deadline:
        raise TimeoutError(f"Forecast {forecast_id} has not completed")
    time.sleep(interval)

Save the ID. If your script stops, pass it with --forecast-id to wait for the same run, rather than starting a new one.

Compare it with the forecast without your context

On the beta channel, each run in the forecast's history has user_context, which is true for runs made with someone's context. The latest run with user_context: false is the forecast everyone else sees:

history = paginate(
    client,
    f"/beta/questions/{question_id}/forecasts",
    "forecasts",
    {"show_forecasts": "true"},
)
return next((run for run in history if not run["user_context"]), None)

Run it with your context, or with the ID of a run you already started:

python forecast_with_context.py QUESTION_ID --context "Assume the US and China announce a trade deal…"
python forecast_with_context.py QUESTION_ID --forecast-id 348536
Waiting for forecast 348536 to complete…
Without your context (2026-10-24): Yes 19%, No 81%
With your context (2026-10-28): Yes 23%, No 77%

The run without your context is usually older, so part of the difference can come from news since it ran. To see what your context changed in the argument, compare both runs' reasoning, as in Read reasoning and sources.

On this page