Calculator AI exposes a browser-only integration surface on the storefront: your theme JavaScript, or another Shopify app’s script on the same page, can listen for calculator updates and set option values programmatically. There is no secret API key—the same rules apply as for any custom JavaScript on your storefront (protect against XSS).
Use this page for a quick orientation. The full payload tables, error codes, and edge cases are documented for developers in the Calculator AI repository at docs/storefront-calculator-api.md (Storefront JavaScript API contract).
calc:ready and calc:change on document to read detail.values and detail.spec.window.CalcAI.setValue({ optionId, value, instanceId?, calculatorId? }) (returns { ok, error?, code? }), ordocument.dispatchEvent(new CustomEvent('calcai:setValue', { bubbles: false, detail: { ... } })).Wait until window.CalcAI?.setValue is a function (after the calculator module loads), or listen for calc:ready first.
If more than one calculator is on the page, pass instanceId and/or calculatorId from calc:ready (or bootstrap JSON). On a single calculator page, those fields are often null and the API still resolves the only instance.
When a change is applied via the public API, the next calc:change has detail.external === true and reason === 'external-set'. Use that to avoid echoing programmatic updates back into a chat or analytics pipeline.
NO_CALC_INSTANCE). Normal theme blocks use the full renderer.Listen for live values:
document.addEventListener("calc:change", (ev) => {
const { values, spec, external } = ev.detail || {};
if (!external) {
// shopper-driven change
}
});
Set a value (after CalcAI is available):
const out = window.CalcAI?.setValue({
optionId: "my_option_key",
value: "42",
});
if (!out?.ok) console.warn(out?.code, out?.error);