Agent Utilities
← Commerce data

commerce.pack-size-normalize · v1.0.0

Pack Size Normalize
for your agent.

Normalize locale-explicit pack-size expressions and multipacks to exact grams, millilitres or counts; reject ambiguous text.

$0.0003 / call300 micro-dollar credits
131,072 bytes max input65,536 bytes max output
Works on supplied inputNo external network fetch

Try this on your own data free

FREE, no key. Normalize locale-explicit pack-size expressions and multipacks to exact grams, millilitres or counts; reject ambiguous text. Entire JSON input: 4096 UTF-8 bytes, at most 5 quantities. Supplied data only; no fetch, payment or automatic paid fallback.

Hosted MCP: agent_utilities_pack_size_normalize_preview. Inspect the result status, reasons and source evidence before using an answer.

POST https://agent-utilities.agent-utilities.workers.dev/v1/preview/commerce.pack-size-normalize
Content-Type: application/json

{
  "locale": "pt-BR",
  "quantities": [
    {
      "id": "milk",
      "text": "6 x 1,5 litros"
    },
    {
      "id": "chicken",
      "text": "Aprox. 2,8 Kg"
    },
    {
      "id": "unclear",
      "text": "500g + 20% free"
    }
  ]
}

Machine-readable trial contracts · Connect your agent

Example input

{
  "locale": "pt-BR",
  "quantities": [
    {
      "id": "milk",
      "text": "6 x 1,5 litros"
    },
    {
      "id": "chicken",
      "text": "Aprox. 2,8 Kg"
    },
    {
      "id": "unclear",
      "text": "500g + 20% free"
    }
  ]
}

Example output

{
  "locale": "pt-BR",
  "quantities": [
    {
      "id": "milk",
      "status": "normalized",
      "quantity": "1.5",
      "unit": "litros",
      "packCount": 6,
      "totalQuantity": "9000",
      "baseUnit": "ml",
      "dimension": "volume",
      "approximate": false,
      "issue": null
    },
    {
      "id": "chicken",
      "status": "normalized",
      "quantity": "2.8",
      "unit": "kg",
      "packCount": 1,
      "totalQuantity": "2800",
      "baseUnit": "g",
      "dimension": "mass",
      "approximate": true,
      "issue": null
    },
    {
      "id": "unclear",
      "status": "unsupported",
      "quantity": null,
      "unit": null,
      "packCount": null,
      "totalQuantity": null,
      "baseUnit": null,
      "dimension": null,
      "approximate": false,
      "issue": "ambiguous_or_unsupported_expression"
    }
  ],
  "allNormalized": false,
  "scope": "Explicit-locale whole quantity expressions only, including N x quantity and quantity x N. Exact grams, millilitres or item counts; oz means mass ounces, lb means mass pounds. Fluid ounces, pints, ranges, prose, mixed units and bonus quantities are rejected. Approximate declarations stay approximate. No price or density conversion."
}

Generated from the actual handler using this example input; this is a preview, not a paid API call. Paid responses wrap the result with a receipt and recovery expiry.

Read this input and result as free JSON ↗

Call it from your agent

Add credits in the workspace and keep your API key in private environment storage. Use the same request ID and exact body to recover a lost response within ten minutes.

// Node.js 22+. Read the key from your private environment.
const requestId = Date.now() + '_' + crypto.randomUUID();
const response = await fetch('https://agent-utilities.agent-utilities.workers.dev/v1/tools/commerce.pack-size-normalize', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer ' + process.env.AGENT_UTILITIES_API_KEY,
    'Idempotency-Key': requestId
  },
  body: JSON.stringify({
  "locale": "pt-BR",
  "quantities": [
    {
      "id": "milk",
      "text": "6 x 1,5 litros"
    },
    {
      "id": "chicken",
      "text": "Aprox. 2,8 Kg"
    },
    {
      "id": "unclear",
      "text": "500g + 20% free"
    }
  ]
})
});
const data = await response.json();
if (!response.ok) throw new Error(data.error?.message ?? 'Request failed');
console.log(data);
// On response loss, retry this SAME requestId, tool and body.
// Do not rerun the line that generates requestId for a retry.
Input JSON Schema
{
  "type": "object",
  "properties": {
    "locale": {
      "type": "string",
      "enum": [
        "en-US",
        "en-GB",
        "de-DE",
        "fr-FR",
        "pt-BR"
      ]
    },
    "quantities": {
      "type": "array",
      "minItems": 1,
      "maxItems": 50,
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "text": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160
          }
        },
        "required": [
          "id",
          "text"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "locale",
    "quantities"
  ],
  "additionalProperties": false
}
Output JSON Schema
{
  "type": "object",
  "properties": {
    "locale": {
      "type": "string"
    },
    "quantities": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "normalized",
              "unsupported"
            ]
          },
          "quantity": {
            "type": [
              "string",
              "null"
            ]
          },
          "unit": {
            "type": [
              "string",
              "null"
            ]
          },
          "packCount": {
            "type": [
              "integer",
              "null"
            ]
          },
          "totalQuantity": {
            "type": [
              "string",
              "null"
            ]
          },
          "baseUnit": {
            "type": [
              "string",
              "null"
            ]
          },
          "dimension": {
            "type": [
              "string",
              "null"
            ]
          },
          "approximate": {
            "type": "boolean"
          },
          "issue": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "status",
          "quantity",
          "unit",
          "packCount",
          "totalQuantity",
          "baseUnit",
          "dimension",
          "approximate",
          "issue"
        ],
        "additionalProperties": false
      }
    },
    "allNormalized": {
      "type": "boolean"
    },
    "scope": {
      "type": "string"
    }
  },
  "required": [
    "locale",
    "quantities",
    "allNormalized",
    "scope"
  ],
  "additionalProperties": false
}

Before you integrate

Prices are experimental. The service currently allows 1,000 new calls per day per payment rail across all accounts. Failed operations return reserved credits. Successful results are encrypted for ten-minute retry recovery. Review data handling and service limits.

Related tools

commerce $0.0003 / call

GTIN Validate

Validate GTIN-8, UPC/GTIN-12, EAN/GTIN-13 and GTIN-14 check digits; no product lookup.

commerce.gtin-validate

commerce $0.0005 / call

Variant Compare

Compare requested product attributes with an offered variant and list missing or mismatched fields.

commerce.variant-compare

commerce $0.0008 / call

Pack Plan

Choose the lowest-cost whole-pack combination for a required count with exact prices and explicit pack limits; up to 20 interchangeable offers.

commerce.pack-plan