Source: https://guthlabs.ai/docs/instruments/token-context-window-cost-calculator/implementation/

instrument implementation / implementation-contract

# Token / Context-Window Cost Calculator implementation

A source-bound implementation contract for Token / Context-Window Cost Calculator; deployment and executable qualification remain separate.

Status: **VERIFIED_CLEAN**Lifecycle: **implementation-contract**

## Binding contract

This record describes what an executable surface must bind and validate. It does not claim that a public calculator, package, or production route is deployed.

**Record owner**: Guth Instruments

**Lifecycle**: verified-clean

**Evidence ID**: t7-008

**Effect**: Computation or source lookup only

## Input and validation requirements

A zero-valued context window produces an undefined percentage unless explicitly rejected. The specification also does not define the context-token convention or explicitly define an operational branch for requests exceeding the context window, so different implementations can report materially different results.

## Required corrections

No binding erratum is attached to this unique-name record. Implementers must still preserve the declared units, domain, and failure behavior.

## Inspectable interface fixture

The sample below is evidence for interface and validation tests, not a production implementation.

````
{
  "inputs": {
    "model": "gpt-4o",
    "input_tokens": 1000,
    "expected_output_tokens": 500
  },
  "expected_outputs": {
    "total_tokens": 1500,
    "estimated_cost_usd": 0.0125,
    "context_used_percent": 1.171875,
    "context_limit_exceeded": false,
    "input_cost_per_1K_tokens_usd": 0.005,
    "output_cost_per_1K_tokens_usd": 0.015,
    "input_cost_per_1M_tokens_usd": 5,
    "output_cost_per_1M_tokens_usd": 15
  },
  "reference_data": {
    "model": "gpt-4o",
    "context_window_tokens": {
      "value": 128000,
      "source_convention": "OpenAI official model/pricing documentation, as of 2025-02-01, https://openai.com/api/pricing/"
    },
    "input_price_usd_per_1M_tokens": {
      "value": 5,
      "source_convention": "OpenAI official pricing page, as of 2025-02-01, https://openai.com/api/pricing/"
    },
    "output_price_usd_per_1M_tokens": {
      "value": 15,
      "source_convention": "OpenAI official pricing page, as of 2025-02-01, https://openai.com/api/pricing/"
    }
  },
  "working": "Total tokens = 1,000 + 500 = 1,500. Input cost = (1,000 / 1,000,000) × $5.00 = 0.001 × 5.00 = $0.0050. Output cost = (500 / 1,000,000) × $15.00 = 0.0005 × 15.00 = $0.0075. Total cost = $0.0050 + $0.0075 = $0.0125. Context use = (1,500 / 128,000) × 100 = 1.171875%. Per-1K rates: $5.00 / 1,000 = $0.005 input and $15.00 / 1,000 = $0.015 output. The $5.00 and $15.00 per-1M entries are used exactly from the dated table."
}
````

## Other records

[01**Overview**](<https://guthlabs.ai/docs/instruments/token-context-window-cost-calculator/>)[02**Mechanism**](<https://guthlabs.ai/docs/instruments/token-context-window-cost-calculator/mechanism/>)[04**Qualification**](<https://guthlabs.ai/docs/instruments/token-context-window-cost-calculator/qualification/>)

## Sources and evidence

These pointers bind the page to evidence. They do not grant authority or collapse verification into deployment.

- `VERIFIED_LEDGER.json`

- `evidence-tranche7/tranche7-results.json`
