Formula weight from a chemical formula (Hill notation, IUPAC/CIAAW weights)
Parses a chemical formula (parentheses, brackets, hydrate dots such as CuSO4·5H2O, an ignored charge) for a chemist or an agent that must check a molar mass, and returns the Hill-notation formula, the formula weight in g/mol from the CIAAW abridged standard atomic weights summed exactly in decimal arithmetic, and mass fractions. Pass claimedWeight and tolerance to check a stated molar mass. Elements with no standard atomic weight (technetium, promethium, elements above bismuth except thorium, protactinium and uranium) return unknown unless you supply elementWeights. A separate mode validates SMILES syntax against the OpenSMILES grammar. It does NOT compute a weight from SMILES, handle isotope or deuterium notation, or check that a compound exists.
What you get
Molar-mass arithmetic by an LLM drifts in the third decimal; this is exact against a named atomic-weight table.
Call it
Send the JSON body below to https://agents.writerslogic.com/api/v1/formula-weight. An unpaid request answers 402 with the price and how to pay; a request that fails with a 5xx status is not charged.
curl -i -X POST https://agents.writerslogic.com/api/v1/formula-weight \
-H 'content-type: application/json' \
-d '{"formula":"CuSO4.5H2O","claimedWeight":249.677}'
Input
| Field | Type | Required | Description |
|---|---|---|---|
mode | string; one of "formula", "smiles" | no | formula (default) computes the weight; smiles validates syntax only. |
formula | string; length 0..200 | no | Chemical formula, at most 200 characters. Element symbols are case-sensitive (Co is cobalt, CO is carbon monoxide). Hydrate separators: . · • *. A trailing charge such as ^2+, 2- after a bracket, or a bare + or - is ignored. |
smiles | string; length 0..200 | no | A single SMILES string without a name, at most 200 characters (mode smiles). |
elementWeights | array<object>; max 20 items | no | Caller-chosen weights; they take precedence over the table and are the only way to weigh elements without a standard atomic weight. |
claimedWeight | number; 0..1000000000 | no | Stated molar mass to check, g/mol. |
tolerance | number; 0..1000 | no | Allowed absolute difference from claimedWeight in g/mol. Default 0.01. |
Example request body
{
"formula": "CuSO4.5H2O",
"claimedWeight": 249.677
}
Result
The response is { "data": ..., "_provenance": ... }. data carries these fields; _provenance is a signed W3C Verifiable Credential with a C2PA-style manifest, checked free at POST /api/v1/verify-provenance.
| Field | Type | Required | Description |
|---|---|---|---|
status | string; one of "pass", "fail", "unknown", "unsupported" | no | pass: every rule held. fail: a rule was violated (see witnesses). unknown: the input lacks the evidence to decide. unsupported: outside what this engine covers. Missing evidence is never a pass. |
mode | string; one of "formula", "smiles" | no | |
valid | boolean | no | Whether the input parsed. |
formula | one of | no | |
weight | one of | no | |
weightExact | one of | no | |
uncertainty | one of | no | |
chargeIgnored | one of | no | |
missingElements | array<string> | no | |
composition | array<object> | no | |
parts | array<object> | no | For hydrates/adducts: each dot-separated part with its coefficient and weight. |
smiles | object | no | Counts from the SMILES syntax check (mode smiles). |
witnesses | array<object> | no | |
versions | object | no | Every semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile). |
limits | array<string> | no | |
deterministic | boolean | no | Always true: pure code, no model. |
Pay and connect
Available through: x402 (USDC on Base), MCP. MCP clients reach it through the physical-ops-kit package.
Machine-readable
- This agent as JSON (schemas, example, OpenAPI operation)
- Free signed sample response
- OpenAPI 3.1 · Catalog · Index of every agent