Exergy World Model
Verification receipts, JSON outputs & streaming
Read the ewm_verification receipt, consume structured_output, stream stage-by-stage events, and work in SI or US customary units in Exergy World Model (EWM-1).
Physical verification receipts
Every EWM-1 response includes a machine-checkable verification block — verification on /v1/solve, ewm_verification on /v1/chat/completions — showing that the numerical outputs came from executing real thermodynamic equations of state rather than being generated as text.
{
"verified": true,
"attempts": 1,
"exec_s": 0.412,
"code": "from ewm_thermo_lib import *\n...",
"stdout": "{\n \"optimal_option\": \"Option A\",\n ...\n}",
"stderr": "",
"history": [
{
"attempt": 1,
"ok": true,
"returncode": 0,
"exec_s": 0.412,
"ast_violation": null
}
]
}import os
import requests
response = requests.post(
"https://api.exergylab.ai/v1/solve",
headers={"Authorization": f"Bearer {os.environ['EXERGY_API_KEY']}"},
json={
"prompt": "Compare a heat pump vs. natural gas boiler for a 5 MWth process sink.",
"skip_composer": True,
},
timeout=120,
)
response.raise_for_status()
solution = response.json()
if not solution["verification"]["verified"]:
raise ValueError(f"Sandbox verification did not pass: {solution['verification']['stderr']}")
verified_metrics = solution["structured_output"]["metrics"]Check verified before you consume metrics
Downstream engineering workflows should assert verified == true before using any numerical output.
Structured JSON outputs (structured_output)
On every verified solve, EWM-1 parses the final JSON block printed by the sandboxed script and returns it as structured_output. Multi-option trade studies follow a standard schema.
With the OpenAI SDK and response_format: {type: "json_object"}, choices[0].message.content is a valid JSON string serializing structured_output.
{
"optimal_option": "Option A",
"feasible_options": ["Option A", "Option B"],
"infeasible_options": ["Option C"],
"metrics": {
"COP_heating": 3.42,
"W_elec_MW": 1.462,
"Q_source_MW": 3.538,
"option_a_total_annualized_cost_usd_yr": 1184250.0,
"option_b_total_annualized_cost_usd_yr": 1642900.0
},
"project_finance": {
"capex_incremental_usd": 2800000.0,
"annual_opex_savings_usd_yr": 685000.0,
"simple_payback_yr": 4.09,
"npv_usd": 3062410.0,
"irr_pct": 22.8,
"annual_co2_abated_t_yr": 5420.0,
"mac_usd_per_tCO2": -84.6
},
"assumptions_used": {}
}Streaming (server-sent events)
OpenAI-compatible streaming (POST /v1/chat/completions with stream: true) emits standard chat.completion.chunk events that work with the OpenAI Python and TypeScript stream iterators, then a final chunk carrying usage and structured_output, terminated by data: [DONE].
Native streaming (POST /v1/solve with stream: true) emits stage-by-stage events so a UI can render the solver code, sandbox result, and final report as they happen.
| SSE type | Payload fields | Description |
|---|---|---|
| stage | stage (solver, exec, repair_1, composer), note | Announces pipeline stage transitions |
| solver_delta | text | Token stream of the Python verification script being written |
| code | code, attempt | Extracted Python script ready for sandbox execution |
| exec_result | ok, returncode, stdout, stderr, exec_s, attempt, ast_violation | Result of running the script in the CoolProp sandbox |
| composer_delta | text | Token stream of the final Markdown engineering report |
| done | latency_s, usage, structured_output, verified, attempts | Final summary event |
Units & engineering defaults
- Prompts may use SI (bar, kPa, °C, K, kg/s, t/h, kW, MW, GJ) or US customary plant units (psig, psia, °F, lb/hr, klb/hr, gpm, SCFM, BHP, MMBtu/hr, tons of refrigeration, $/gal, $/MMBtu).
- Field inputs are converted with exact NIST/IAPWS helpers (psig_to_bar, F_to_C, klb_hr_to_kg_s, gpm_to_kg_s, mmbtu_hr_to_MW, tons_refrigeration_to_MW, bhp_to_MW, scfm_to_kg_s), and results are reported in both SI and the requested field units.
- If a prompt omits standard background parameters — annual operating hours, discount rate, equipment lifetime, baseline boiler efficiency, grid emission factor — EWM-1 calls default_industrial_assumptions(...) with your overrides and records every default it applied under structured_output.assumptions_used.