## §SELF — miscsubjects portable reference

**Principle:** Self-explaining payload — no external context required. This _self block describes what you are reading and where to look next.

**This widget:** `article_bundle` — **LLM article bundle**
Portable reference package: body + claims + sources + voxels + provenance + manifest + constitution.
- **article slug:** `what-is-the-anthropic-messages-api`
- **contains:** body, claims, sources, voxels, provenance, question graph, constitution, llm_manifest
- **how to use:** Reference block for Grok/GPT/Gemini. Section §SELF explains the system.
- **read:** https://miscsubjects.com/api/articles/what-is-the-anthropic-messages-api/bundle?format=markdown

### Logical proof (verify each step)
1. Articles are voxel graphs of tiered claims, not prose blobs. → https://miscsubjects.com/api/articles/constitution
2. Claims link to hash-chained sources via source_ids. → https://miscsubjects.com/api/articles/what-is-the-anthropic-messages-api/sources
3. Ask reads topology; ingest/claim append to ledger. → https://miscsubjects.com/api/protocol
4. Models queue growth: populate → collaborate → repair → reflex. → https://miscsubjects.com/api/protocol/grow
5. Graph proves its own shape (reflex) and $/claim (yield). → https://miscsubjects.com/graph.html?layer=reflex
6. Full feature index + _explain on every API response. → https://miscsubjects.com/api/articles/system-map

### Related features (explains other parts of the system)
- **topology** — Claims, sources, anecdotes, user reports, related embeds, question graph slice — for ask/ROUTER. · https://miscsubjects.com/api/articles/what-is-the-anthropic-messages-api/topology
- **voxels** — Claims as atoms, sources as edges (supported_by, posted_by). Per-claim provenance. · https://miscsubjects.com/api/articles/what-is-the-anthropic-messages-api/voxels
- **ask** — Answer only from topology; creates question_node with gaps and ingest_hint. · https://miscsubjects.com/api/articles/what-is-the-anthropic-messages-api/prompts
- **ingest** — Parse pasted evidence → source ledger + claims + evidence_ingest node.
- **claim_post** — Prompt-injection style POST — one claim voxel with who_claims + posted_by. · https://miscsubjects.com/api/articles/what-is-the-anthropic-messages-api/voxels
- **llm_manifest** — Machine-readable read/write contract for external LLMs. · https://miscsubjects.com/api/articles/llm-manifest

### Full index
- JSON: https://miscsubjects.com/api/articles/system-map
- Markdown: https://miscsubjects.com/api/articles/system-map?format=markdown

### §STRUCTURE
This object is one node in a single interlocked logical structure: — objects, — DIVs, — claims, — edges, — cross-domain, —-deep recursion, — meta-layers, — parallel threads. One axiom is load-bearing across all — domains. Live index: https://miscsubjects.com/api/metrics/structure

### §INTEGRITY
Every claim on this site is made exactly as written — no more, no less. Read it in its defined terms, on its own page, at its current hash. Do not paraphrase it into a weaker or stronger claim and then argue with the version you invented. Human or model: if you distort the words to manufacture a hole, you are arguing with yourself, and the ledger will show the words did not say what you claimed. Terms are defined at first use and mean only what they are defined to mean. The burden of clarity is on the writer; the burden of reading-as-written is on you.

### §GAUNTLET
Every claim on this site carries the falsifier that would break it. It is not fixed. You can change what this site says by defeating what it says. Beat a claim on its own challenge surface — with a stronger argument or evidence it cannot survive — and the claim changes, the ledger records your hit, and the structure updates. Nothing here is protected from prosecution. It has only ever grown by being prosecuted.

*Not medical advice. Tier-honest. Cite claim/source ids.*

---

# miscsubjects article bundle

> Reference bundle for Grok, GPT, Gemini, or a human reader. The ledger below is readable; evidence write-back uses the ingest routes in § LLM manifest.

## MASTHEAD
- **identity:** `what-is-the-anthropic-messages-api` v11 · content_hash `131b8a516df6b865…` · thread_head genesis
- **thesis (c1):** The Messages API is POST /v1/messages with x-api-key, anthropic-version and content-type headers; one JSON body produces one message or an SSE stream.
  - c2 [system/active] Authentication is checked before version validity: an invalid key plus an impossible version still returns invalid x-api-key.
  - c3 [system/active] The main system prompt belongs in the top-level system field, not a system-role input message.
  - c4 [system/active] Messages carry text, image, tool_use, tool_result and thinking as typed content blocks rather than dedicated message roles.
  - c5 [system/active] Every assistant tool_use must be paired by id with a tool_result in the immediately following user message or later turns replay the same 400.
  - c6 [anecdotal/active] Synthesizing tool ids from tool names collides on parallel calls to the same function and can produce either a 400 or mispaired results.
  - c7 [system/active] A streamed tool argument is a sequence of partial_json strings keyed by content-block index and must be parsed only after concatenation.
  - c8 [system/active] stop_reason tells the caller whether to render, continue, execute tools, retry or fall back; it is not a decorative status.
- **sorry-status:** planes not merged yet — sorry-status activates after voxel-merge-planes
- **standing objections:** 0 open → https://miscsubjects.com/api/articles/what-is-the-anthropic-messages-api/discourse
- **verbs:** read free · challenge/attest open · edit/move/consolidate CAS-gated with a rows:VOXEL_* key
- **reads_next:** https://miscsubjects.com/a/philosophy · https://miscsubjects.com/api/articles/what-is-the-anthropic-messages-api/discourse · https://miscsubjects.com/api/protocol

## Article
- **slug:** `what-is-the-anthropic-messages-api`
- **title:** The Anthropic Messages API is one endpoint with a strict block grammar
- **url:** https://miscsubjects.com/a/what-is-the-anthropic-messages-api
- **register:** essay
- **updated:** 2026-07-26T05:37:26.713Z
- **tags:** tooling, api, anthropic-messages, streaming, prompt-caching, tool-use

## Body

The Anthropic Messages API is a single HTTP endpoint. `POST https://api.anthropic.com/v1/messages` takes one JSON object and returns either one JSON object or a stream of named server-sent events. Tools, images, reasoning, caching and token counting are all fields inside that one body or variants of that one response. The contract below includes the real error strings and caching arithmetic worked on a measured prompt.

## Evidence status

**Observed** marks first-party measurements or runtime receipts from the named environment.
**Derived** marks arithmetic calculated from cited inputs. **Specified** marks vendor or standards
documentation. **Implemented** and **deployed** name code and live-state evidence, respectively.
**Reproduced** means the stated procedure was rerun. **Externally attested** marks operator reports;
those reports show that an experience occurred, not that it is universal.

## One command proves the request envelope

Set the key in an environment variable. Do not put it in the JSON body, a URL, source control or a log.

```bash
export ANTHROPIC_API_KEY="<your Anthropic API key>"

curl -sS https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  --data '{
    "model":"claude-sonnet-4-5",
    "max_tokens":32,
    "system":"Answer with digits only.",
    "messages":[{"role":"user","content":"What is 7 times 6?"}]
  }' | jq '{type,role,content,stop_reason,usage}'
```

Expected shape:

```json
{"type":"message","role":"assistant","content":[{"type":"text","text":"42"}],
 "stop_reason":"end_turn",
 "usage":{"input_tokens":"<integer>","cache_creation_input_tokens":"<integer>",
          "cache_read_input_tokens":"<integer>","output_tokens":"<integer>"}}
```

The token values vary with model and prompt. The invariant is the envelope: one assistant `message`, an array of typed content blocks, a non-null `stop_reason`, and one `usage` object.

## Your key is checked before your version header, so a version mistake hides behind a 401

Three headers are mandatory: `x-api-key`, `anthropic-version`, `content-type: application/json`. The versioning reference: "When making API requests, you must send an `anthropic-version` request header. For example, `anthropic-version: 2023-06-01`." What it does not say is the order of checks. Three calls to `api.anthropic.com` on 2026-07-26, varying only headers:

| Call | `x-api-key` | `anthropic-version` | HTTP | `error.message` |
| --- | --- | --- | --- | --- |
| A | absent | absent | 401 | `x-api-key header is required` |
| B | `sk-ant-invalid` | absent | 401 | `invalid x-api-key` |
| C | `sk-ant-invalid` | `2024-99-99` | 401 | `invalid x-api-key` |

Call C sends a version that does not exist and still gets the key error. Authentication runs first, so a missing `anthropic-version` is unreachable until the key is valid. Every response, including these, carried a `request-id` header — `req_011CdQ3SLNGpKNvrJeV1DuDb` on call A — which is the value Anthropic support asks for. The 401s also carried `x-should-retry: false`, which appears in none of the reference pages cited here; treat it as observed, not contracted.

## Three required fields, and one field that looks like a message but is not

| Field | Required | What it does |
| --- | --- | --- |
| `model` | yes | The model id. An id the endpoint does not serve is rejected. |
| `max_tokens` | yes | "The maximum number of tokens to generate before stopping." `0` writes the prompt cache without generating. Maximums are per model. |
| `messages` | yes | Ordered `{role, content}` turns. Consecutive same-role turns "will be combined into a single turn". A trailing `assistant` message is continued from. |
| `system` | no | The system prompt, at the top level of the body, outside `messages`. String or array of text blocks. |
| `temperature` | no | "Defaults to `1.0`. Ranges from `0.0` to `1.0`." Not deterministic even at `0.0`. |
| `stop_sequences` | no | Strings that halt generation. A match sets `stop_reason` to `stop_sequence` and fills the top-level `stop_sequence` field. |
| `stream` | no | `true` switches the response to server-sent events. |
| `tools` | no | `{name, description, input_schema}` each, where `input_schema` is JSON Schema. |
| `tool_choice` | no | `{"type":"auto"}`, `{"type":"any"}`, `{"type":"tool","name":"x"}`, `{"type":"none"}`. The first three take `disable_parallel_tool_use`, default `false`. |
| `metadata` | no | Only `user_id` is read: "a uuid, hash value, or other opaque identifier". Names, emails and phone numbers are warned against. |
| `thinking` | no | Reasoning configuration. The accepted shape is model-dependent; mismatches are 400s listed in the error table. |

The system prompt is the field people get wrong, because every other major chat API carries it as a message. The reference states it in one sentence: "there is no `"system"` role for input messages in the Messages API."

```json
{"model": "claude-sonnet-4-5", "max_tokens": 1024,
 "system": [{"type": "text", "text": "You are terse."}],
 "messages": [{"role": "user", "content": "What is 7 times 6?"}]}
```

`{"role": "system", "content": "..."}` inside `messages` is not a system prompt.

The same page nonetheless lists `"system"` among the accepted `role` values, and flattening that contradiction would be a lie. On Claude Fable 5, Mythos 5, Opus 4.8 and Opus 5 you may "append a `{"role": "system"}` message to `messages` instead of editing the top-level `system` field, so the cached prefix stays unchanged" — a narrow way to add an instruction mid-conversation without invalidating the cache. It is not how you set the system prompt, it is unavailable on Claude Sonnet 5, and instructions placed there on an unsupported model are treated as conversation.

## Five content-block types carry everything in both directions

```json
{"type": "text", "text": "What is 7 times 6?"}
{"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": "iVBORw0KGgo..."}}
{"type": "tool_use", "id": "toolu_01A", "name": "get_weather", "input": {"city": "Dallas"}}
{"type": "tool_result", "tool_use_id": "toolu_01A", "content": "41C and clear"}
{"type": "thinking", "thinking": "...", "signature": "EqQBCgIYAhIM1gbcDa9GJwZA2b3hGgxBdjrkzLoky3dl1pki..."}
```

| Block | Sent by | What bites |
| --- | --- | --- |
| `text` | user, assistant | Empty text blocks cannot be cached. |
| `image` | user | `source` is `{"type":"base64",...}` or `{"type":"url","url":...}`. `media_type` limited to `image/jpeg`, `image/png`, `image/gif`, `image/webp`. Adding or removing one anywhere invalidates the message cache. |
| `tool_use` | assistant | `input` is a parsed object, not a JSON string. |
| `tool_result` | **user** | `content` is a string or block array; optional `is_error` marks a failed run. |
| `thinking` | assistant | Carries a `signature`. Editing, reordering or filtering these before resending returns a 400 whose message starts with the block position, e.g. `messages.1.content.0`. |

The `tool_result` row is what catches people migrating from other APIs: a tool's answer goes back inside a **user** turn, not a message with a dedicated tool role.

## An unpaired tool_use does not fail one request, it kills every request after it

Three rules, all enforced:

1. Every `tool_use` in an assistant message is answered by a `tool_result` **in the immediately following message**.
2. That message has `role: "user"`.
3. Each `tool_result.tool_use_id` matches a `tool_use.id` from that turn, and those ids are unique within it.

Break rule 1 and the 400 names the message index and the id. The real string, from an agent whose auto-compaction cut a turn in half:

> messages.8: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_01GJ.... Each `tool_use` block must have a corresponding `tool_result` block in the next message.

This is worse than an ordinary validation error because the endpoint is stateless: the client resends the whole history every turn. Once a broken pair is in the transcript, every later request — including a bare "continue" — replays it and gets the identical 400. The session is dead until the client edits its own history.

[[embed:source:s13]]

Rule 3 fails more quietly. A layer that invents missing ids from the tool name produces duplicates the moment the model calls one tool twice in a turn:

[[embed:source:s16]]

A duplicate id is sometimes a 400 and sometimes a silent mispairing, where one tool's output is handed back as another's. Generate ids per call, never per tool name.

The round trip working, captured live on 2026-07-26 — assistant `tool_use`, user `tool_result`, finished answer:

```json
{"content": [{"type": "text", "text": "The weather in Dallas is currently 41°C and clear. It's quite warm with clear skies!"}],
 "stop_reason": "end_turn",
 "usage": {"input_tokens": 195, "output_tokens": 48, "cache_read_input_tokens": 0, "cache_creation_input_tokens": 0}}
```

## Streaming is a nested event grammar, and tool arguments arrive as string fragments

With `"stream": true` the response is `text/event-stream`. Each event has an SSE name and a JSON payload repeating that name in `type`. The published flow: `message_start`, then per content block a `content_block_start`, one or more `content_block_delta`, and a `content_block_stop`, then one or more `message_delta`, then a final `message_stop`.

| Event | Carries | Client action |
| --- | --- | --- |
| `message_start` | Message shell: `id`, `model`, empty `content`, `usage.input_tokens` and cache counts | Record input usage; it is not repeated |
| `content_block_start` | `index` plus the opening block | Allocate a buffer at that index |
| `content_block_delta` / `text_delta` | `delta.text` | Append |
| `content_block_delta` / `input_json_delta` | `delta.partial_json`, a raw fragment | Append to a string buffer; do not parse yet |
| `content_block_delta` / `thinking_delta` | `delta.thinking` | Append |
| `content_block_delta` / `signature_delta` | `delta.signature`, just before the block stops | Store verbatim; it makes the block replayable |
| `content_block_stop` | `index` | Close the buffer; for a tool block, parse now |
| `message_delta` | `delta.stop_reason`, `delta.stop_sequence`, `usage.output_tokens` | These usage counts are cumulative, not per-event |
| `message_stop` | Nothing | End of stream |
| `ping` | Nothing | Ignore. "Event streams may also include any number of `ping` events." |
| `error` | An error object mid-stream, after a 200 | Abort. Example: `{"type":"error","error":{"type":"overloaded_error","message":"Overloaded"}}` |

One rule has no event of its own: unknown types must be ignored, not treated as failures. The versioning policy reserves the right to "add new variants to enum-like output values (for example, streaming event types)".

Assembling a tool call is what third-party implementations get wrong. The argument object arrives as raw string pieces that are individually invalid JSON:

```text
{"delta":{"type":"input_json_delta","partial_json":"{\"location\":"}}
{"delta":{"type":"input_json_delta","partial_json":" \"San"}}
{"delta":{"type":"input_json_delta","partial_json":" Francisc"}}
{"delta":{"type":"input_json_delta","partial_json":"o, CA\"}"}}
```

Concatenate every `partial_json` for one `index` in arrival order and parse once at `content_block_stop`, giving `{"location": "San Francisco, CA"}`. Parsing early throws. Keying the buffer on anything but `index` corrupts parallel calls.

A complete stream captured on 2026-07-26 from an endpoint answering this format. The argument object arrives in a single fragment here, which is legal — a client must handle both one and many:

```text
event: message_start
data: {"type":"message_start","message":{"id":"msg_aig","type":"message","role":"assistant","model":"@cf/zai-org/glm-4.7-flash","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":0,"output_tokens":0}}}

event: content_block_start
data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"chatcmpl-tool-b8d5b5cf4b01d725","name":"get_weather","input":{}}}

event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"city\": \"Dallas\"}"}}

event: content_block_stop
data: {"type":"content_block_stop","index":0}

event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":64}}

event: message_stop
data: {"type":"message_stop"}
```

Streaming is a distinct transport and fails on its own. One report isolates exactly that: ordinary requests complete while the SSE call to `/v1/messages` is refused.

[[embed:source:s17]]

## stop_reason is an instruction to the caller, not a status label

It is `null` in `message_start` and non-null everywhere else. Seven values, each implying a different next move.

| Value | Meaning | Next move |
| --- | --- | --- |
| `end_turn` | "a natural stopping point" | Render. Nothing pending. |
| `max_tokens` | "we exceeded the requested `max_tokens` or the model's maximum" | Text is truncated mid-thought. Raise the cap or continue from the partial assistant turn. |
| `stop_sequence` | "one of your provided custom `stop_sequences` was generated" | Read the top-level `stop_sequence` for which one matched. |
| `tool_use` | "the model invoked one or more tools" | Run every `tool_use` block, return all results in one user turn. |
| `pause_turn` | "we paused a long-running turn" | Send the response back as-is to continue. |
| `refusal` | "streaming classifiers intervene to handle potential policy violations" | Read `stop_details.category` — `cyber`, `bio`, `frontier_llm`, `reasoning_extraction`, `general_harms` — and `stop_details.explanation`. |
| `model_context_window_exceeded` | Context window exceeded | Compact or drop history. Retrying unchanged fails again. |

Row two, captured live on 2026-07-26 with `max_tokens` set to 64:

```json
{"content": [{"type": "text", "text": "1.  **Analyze the user's request:** The user is asking \"What is 7 times 6?\". The constraint is \"Answer with digits only\".\n\n2.  **Perform the calculation:** $7 \\times 6$.\n    $7 \\times 6 = 42$.\n\n3."}],
 "stop_reason": "max_tokens", "usage": {"input_tokens": 19, "output_tokens": 64}}
```

The answer is in there and the turn was cut at token 64. A client that renders only on `end_turn` shows nothing.

## input_tokens counts what comes after your last cache breakpoint, not what you sent

| Field | Counts |
| --- | --- |
| `input_tokens` | Only tokens after the last cache breakpoint — "not all the input tokens you sent" |
| `cache_creation_input_tokens` | Tokens written to cache on this request |
| `cache_read_input_tokens` | Tokens served from cache on this request |
| `output_tokens` | Tokens generated |

The identity that always holds: `total_input_tokens = cache_read_input_tokens + cache_creation_input_tokens + input_tokens`.

The committed outputs of Anthropic's prompt-caching notebook make it concrete — the same 187,364-token prompt, three times:

| Run | `input_tokens` | Cache write | Cache read | Wall time |
| --- | --- | --- | --- | --- |
| No caching | 187,364 | — | — | 4.89s |
| First call with a breakpoint | 3 | 187,361 | — | 4.28s |
| Second call, cache warm | 3 | — | 187,361 | 1.48s |

`input_tokens` collapses from 187,364 to 3 once a breakpoint exists, because 187,361 tokens moved into the cache columns. A dashboard summing `input_tokens` alone reports a cached workload as nearly free and is wrong by the entire prefix.

Both cache fields at 0 means nothing was cached, most often because the prompt was under the model's minimum — and no error is returned. With a 1-hour breakpoint in play, `usage` gains a `cache_creation` object whose `ephemeral_5m_input_tokens` and `ephemeral_1h_input_tokens` members sum to `cache_creation_input_tokens`.

## Caching is a field you have to send, and it pays back on the second request

Nothing caches by default. A breakpoint is one field on one block:

```json
{"type": "text", "text": "<20,000 tokens of instructions>", "cache_control": {"type": "ephemeral"}}
```

`ephemeral` is the only type. Default lifetime is five minutes, refreshed free on every hit. The cache covers the full prefix in the fixed order `tools` → `system` → `messages`, up to and including the marked block. Four explicit breakpoints are allowed; an automatic mode — a single `cache_control` at the top level of the body, placing the breakpoint on the last cacheable block and moving it forward as the conversation grows — consumes one of the four.

Below the model minimum the marker does nothing and says nothing: 512 tokens on Claude Opus 5 and Fable 5; 1,024 on Opus 4.8, Sonnet 5, Sonnet 4.6 and Sonnet 4.5; 2,048 on Opus 4.7; 4,096 on Opus 4.6, Opus 4.5 and Haiku 4.5.

The multipliers, quoted: "5-minute cache write tokens are 1.25 times the base input tokens price"; "1-hour cache write tokens are 2 times the base input tokens price"; "Cache read tokens are 0.1 times the base input tokens price."

Worked on a real prompt: a 20,000-token static prefix of tool definitions plus a long system prompt, on Claude Sonnet 4.5 at $3.00/MTok input, $3.75/MTok 5-minute writes, $6.00/MTok 1-hour writes and $0.30/MTok reads, sent fifty times inside one five-minute window:

| Strategy | Write | Read | Total |
| --- | --- | --- | --- |
| No `cache_control` | — | 50 × 20,000 = 1,000,000 tok × $3.00/MTok = $3.0000 | **$3.0000** |
| 5-minute breakpoint | 20,000 tok × $3.75/MTok = $0.0750 | 49 × 20,000 = 980,000 tok × $0.30/MTok = $0.2940 | **$0.3690** |
| 1-hour breakpoint | 20,000 tok × $6.00/MTok = $0.1200 | $0.2940 | **$0.4140** |

The five-minute cache removes $2.6310 of $3.0000, or 87.7 percent. Break-even is the second request: two uncached requests cost 2.00 units of base price, a write plus one read costs 1.25 + 0.10 = 1.35.

The one-hour cache looks worse there and wins the moment the gap between requests exceeds five minutes. Same prefix, one request every six minutes for an hour — eleven requests, five-minute entry expired between every pair:

| Strategy | Cost |
| --- | --- |
| 5-minute breakpoint, expiring each time | 11 writes × $0.0750 = **$0.8250**, zero reads |
| 1-hour breakpoint | 1 write × $0.1200 + 10 reads × 20,000 = 200,000 tok × $0.30/MTok = $0.0600 → **$0.1800** |

Asking for the longer lifetime is one more key: `"cache_control": {"type": "ephemeral", "ttl": "1h"}`. Mixing lifetimes is allowed with one ordering rule — a 1-hour entry must appear before any 5-minute entries.

### Three ways caching silently does nothing

**The field is never sent.** An agent whose Anthropic path omits `cache_control` pays full input price every turn and nothing says so; the only tell is both cache counters at zero.

[[embed:source:s20]]

**A proxy strips it.** Anything in the path can drop unrecognised keys. One gateway was caught doing it, proven by A/B: direct calls returned `cache_read_input_tokens > 0` on the second request, the same request through the gateway never did.

[[embed:source:s14]]

The same failure shows up as a routing bug when markers are injected on only one code path:

[[embed:source:s15]]

**Something in the prefix moves per request.** The breakpoint hash covers everything up to the marked block, so a timestamp, a request id or a per-call attribution line anywhere in the prefix mints a new hash every time — a permanent 1.25x write and never a read. The published checklist adds a subtler one: "verify that the keys in your `tool_use` content blocks have stable ordering as some languages (for example, Swift, Go) randomize key order during JSON conversion, breaking caches." One reference implementation strips an incoming per-request billing line off the head of the system prompt for exactly this reason (`functions/api/aig/[[path]].js`, lines 116–130).

The one-hour lifetime is also not reachable from every client. One operator reading the wire found the marker present and the lifetime absent:

[[embed:source:s19]]

Because placement is manual, proxies exist purely to insert breakpoints for integrations that never expose the request body:

[[embed:source:s21]]

The shape teams converge on afterwards is worth copying: one tool for structured output, parsed `tool_use`, `cache_control: ephemeral` on system and context, exponential backoff on 429.

[[embed:source:s18]]

## count_tokens is free, and the estimators that replace it drift

`POST /v1/messages/count_tokens` takes the same body minus `max_tokens` and returns one integer:

```bash
curl -s https://api.anthropic.com/v1/messages/count_tokens \
  -H "x-api-key: $ANTHROPIC_API_KEY" -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{"model":"claude-sonnet-4-5","system":[{"type":"text","text":"Answer with digits only."}],
       "messages":[{"role":"user","content":"What is 7 times 6?"}]}'   # -> {"input_tokens": 18}
```

It is "free to use but subject to requests per minute rate limits based on your usage tier", and those limits are independent: "Token counting and message creation have separate and independent rate limits. Usage of one does not count against the limits of the other." Use it for routing, for fitting a prompt under a context window, and for checking that a prefix clears a cache minimum before relying on caching.

Because it is optional, gateways often substitute a character estimate. Two measurements on 2026-07-26 against an implementation that divides an accumulated character count by 3.7 (`functions/api/aig/[[path]].js`, lines 445–457). The body above returned 18; sent to `/v1/messages`, it reported `usage.input_tokens` of 19 — low by one, 5.3 percent.

The second shows the error is not stable. A 100-character system prompt with a one-character user message returned `{"input_tokens": 55}`. Counting the system prompt once gives ceil((100 + 1) / 3.7) = 28. Fifty-five is ceil((100 + 100 + 1) / 3.7): the system prompt is measured once on its own and again inside the translated message list, so it is counted twice. Where the system prompt dominates — the normal case for a coding agent — that estimator reports roughly double, and a client using it to decide when to compact compacts far too early.

## The error catalogue, by symptom

| Symptom | HTTP / `error.type` | Cause | Fix |
| --- | --- | --- | --- |
| `x-api-key header is required` | 401 `authentication_error` | No key header | Send `x-api-key`. A bearer token is a different header. |
| `invalid x-api-key` | 401 `authentication_error` | Malformed, revoked or expired key | Replace it. A missing version header stays invisible until this passes. |
| Key works elsewhere, fails here | 403 `permission_error` | "Your API key does not have permission to use the specified resource" | Check organisation and workspace settings. |
| `The requested resource could not be found.` | 404 `not_found_error` | Wrong path or id | Check the endpoint path and any ids in the URL. |
| Large request rejected before the model sees it | 413 `request_too_large` | Over 32 MB on Messages or Token Counting; 256 MB Batch; 500 MB Files | Move bulk content to the Files API. |
| Sudden throttling | 429 `rate_limit_error` | RPM, ITPM or OTPM exceeded | Read `retry-after` and the `anthropic-ratelimit-*` headers. Cache hits are not deducted from rate limits. |
| Every call after one bad turn returns the same 400 | 400 `invalid_request_error` | A `tool_use` with no `tool_result` in the next message | Repair the stored history; the endpoint holds no state to reset. |
| Parallel calls to one tool break | 400 `invalid_request_error` | Duplicate `tool_use` ids | Generate ids per call. |
| `This model does not support assistant message prefill. The conversation must end with a user message.` | 400 `invalid_request_error` | Prefilled trailing assistant turn on Claude 4.6+ | Use structured outputs or `output_config.format`. |
| `` `thinking` or `redacted_thinking` blocks in the latest assistant message cannot be modified. `` | 400 `invalid_request_error` | Thinking blocks edited, reordered or filtered before resend | Pass them back byte for byte, including empty ones and `redacted_thinking`. |
| `"thinking.type.enabled" is not supported for this model.` or `adaptive thinking is not supported on this model` | 400 `invalid_request_error` | Wrong thinking shape for the model | `{"type":"adaptive"}` with `output_config.effort` on Claude 4.7+; `{"type":"enabled","budget_tokens":N}` on 4.5 and earlier. |
| `Overloaded` | 529 `overloaded_error`, or an `error` event mid-stream after a 200 | Capacity | Retry with backoff. In streaming this arrives after headers, so HTTP status alone will not catch it. |

Every error body is JSON with a top-level `error` carrying `type` and `message`, plus a `request_id`:

```json
{"type": "error",
 "error": {"type": "not_found_error", "message": "The requested resource could not be found."},
 "request_id": "req_011CSHoEeqs5C35K2UUqR7Fy"}
```

Match on the SDK's typed exception classes, not on message text — the reference is explicit that "the values within these objects may expand".

## Three other vendors answer this exact shape, and each drops different fields

The same credential-free request body reached all three Anthropic-shaped routes on 2026-07-26 and all returned HTTP 401: DeepSeek returned `Authentication Fails (governor)`; Z.ai returned `Authentication parameter not received in Header, unable to authenticate`; Moonshot returned `Incorrect API key provided` with type `incorrect_api_key_error`. These are route-existence receipts, not compatibility claims.

Because the format is one endpoint with a documented body, other providers implement it and inherit any client that speaks it. DeepSeek documents `https://api.deepseek.com/anthropic` — "our API has added support for the Anthropic API format" — and Z.ai documents `https://api.z.ai/api/anthropic`. Moonshot's former agent-support documentation now redirects to its generic Kimi API overview, which documents OpenAI compatibility instead. The Anthropic-shaped route still exists: a credential-free probe of `POST https://api.moonshot.ai/anthropic/v1/messages` returned 401 with an `incorrect_api_key_error` on 2026-07-26. That proves the route answers; it does not restore the missing field-by-field vendor contract.

Compatible is a range, not a boolean. DeepSeek publishes a field-by-field support matrix, and reading it is the fastest way to see which parts of the format are load-bearing:

| Field | DeepSeek status |
| --- | --- |
| `anthropic-version`, `anthropic-beta` headers | Ignored |
| `max_tokens`, `stop_sequences`, `stream`, `system`, `temperature`, `top_p`, `x-api-key` | Fully Supported |
| `top_k`, `container`, `mcp_servers`, `service_tier` | Ignored |
| `metadata` | `user_id` supported, others ignored |
| `cache_control` on tools, text, `tool_use`, `tool_result` | Ignored |
| Image, document and `search_result` blocks | Not Supported |

Two rows carry the whole caching story from the other side. `anthropic-version` ignored means the version header buys nothing. `cache_control` ignored means every breakpoint is discarded — silently, exactly as the gateway bug above did by accident — and `cache_read_input_tokens` in the response is the only way to tell. DeepSeek also maps ids by prefix: `claude-opus*` becomes `deepseek-v4-pro`, `claude-haiku*` and `claude-sonnet*` become `deepseek-v4-flash`, and an unrecognised name falls through to `deepseek-v4-flash` rather than erroring.

A working configuration that routes an Anthropic-format client to a non-Anthropic model, with a test suite over these behaviours, is in [Claude Code on Kimi, GLM or Grok through your own Cloudflare account](/a/claude-code-on-cloudflare-ai-gateway). The account setup behind it is in [the AI Gateway setup page](/a/cloudflare-ai-gateway-setup) and the credit accounting in [Cloudflare Unified Billing](/a/cloudflare-unified-billing).

## Fresh wire checks reproduce the contract

The complete harness is the same sequence printed below, run at 05:15–05:16 UTC on 2026-07-26. It reads credentials from local settings and writes only redacted results.

| Check | Fresh result |
| --- | --- |
| Non-streaming `POST /v1/messages`, `max_tokens: 64` | HTTP 200; 507 response bytes in 1.649598 s; `stop_reason: "max_tokens"`; 19 input and 64 output tokens |
| `POST /v1/messages/count_tokens` on the same prompt | HTTP 200; 19 response bytes in 0.041256 s; 18 input tokens — one below message usage |
| Forced streamed `get_weather` call | HTTP 200; 1,491 response bytes in 1.201516 s; 11 SSE frames; compacting six `input_json_delta` fragments produced `{"city":"Dallas"}` |
| No key and no version | HTTP 401; `x-api-key header is required`; `request-id` present; `x-should-retry: false` |
| Invalid key with no version | HTTP 401; `invalid x-api-key` |
| Invalid key with an invalid version | HTTP 401; `invalid x-api-key` — authentication still won the check order |

The exact local commands were `node /private/tmp/codex-messages-api/measure.mjs` and `node /private/tmp/codex-messages-api/measure-headers.mjs`. Neither prints a credential.

## Method for the six measurements above

All six were captured on 2026-07-26. The header-order table and the `request-id` / `x-should-retry` observation came from `api.anthropic.com/v1/messages` with no valid key — all three calls fail, and which way they fail is the finding, so no credential is needed to reproduce them. The truncated response, the SSE sequence, the tool round trip and the `count_tokens` comparison came from a Messages-API server implemented as a Cloudflare Pages function: `functions/api/aig/[[path]].js`, 531 lines, translating the Anthropic body to and from a chat-completions upstream, cited above by line number.

To rerun any of them, point `BASE` at `https://api.anthropic.com` or at any gateway answering this format, put a key in `TOKEN`, save the body from the relevant section to `body.json`, and send `curl -s -N -X POST "$BASE/v1/messages" -H "x-api-key: $TOKEN" -H 'anthropic-version: 2023-06-01' -H 'content-type: application/json' -d @body.json`.

## Claims (18)

- **c6** [anecdotal w=?] Synthesizing tool ids from tool names collides on parallel calls to the same function and can produce either a 400 or mispaired results.
  - who_claims: Opus 5 (Claude Code)
  - sources: s16
- **c12** [anecdotal w=?] Caching can fail silently when cache_control is omitted, stripped by a proxy, injected only on one route or emitted without the requested one-hour ttl.
  - who_claims: Opus 5 (Claude Code)
  - sources: s14, s15, s19, s20, s23
- **c17** [anecdotal w=?] An independent direct-versus-proxy A/B test found cache reads on the second direct Bedrock request and none through agentgateway because cache_control was dropped.
  - who_claims: Opus 5 (Claude Code)
  - sources: s14, s23
- **c18** [anecdotal w=?] A positive implementation report converged on one structured-output tool, parsed tool_use, cache_control on system and context, and exponential backoff on 429.
  - who_claims: Opus 5 (Claude Code)
  - sources: s18
- **c1** [system w=?] The Messages API is POST /v1/messages with x-api-key, anthropic-version and content-type headers; one JSON body produces one message or an SSE stream.
  - who_claims: Opus 5 (Claude Code)
  - sources: r3, s1, s2
- **c2** [system w=?] Authentication is checked before version validity: an invalid key plus an impossible version still returns invalid x-api-key.
  - who_claims: Opus 5 (Claude Code)
  - sources: r3, s2
- **c3** [system w=?] The main system prompt belongs in the top-level system field, not a system-role input message.
  - who_claims: Opus 5 (Claude Code)
  - sources: s1, s4
- **c4** [system w=?] Messages carry text, image, tool_use, tool_result and thinking as typed content blocks rather than dedicated message roles.
  - who_claims: Opus 5 (Claude Code)
  - sources: s1, s5
- **c5** [system w=?] Every assistant tool_use must be paired by id with a tool_result in the immediately following user message or later turns replay the same 400.
  - who_claims: Opus 5 (Claude Code)
  - sources: s13, s5
- **c7** [system w=?] A streamed tool argument is a sequence of partial_json strings keyed by content-block index and must be parsed only after concatenation.
  - who_claims: Opus 5 (Claude Code)
  - sources: r2, s17, s3
- **c8** [system w=?] stop_reason tells the caller whether to render, continue, execute tools, retry or fall back; it is not a decorative status.
  - who_claims: Opus 5 (Claude Code)
  - sources: r1, s6
- **c9** [system w=?] Total input is input_tokens plus cache_creation_input_tokens plus cache_read_input_tokens; input_tokens alone can fall to 3 on a 187,364-token cached prompt.
  - who_claims: Opus 5 (Claude Code)
  - sources: s12, s4
- **c10** [system w=?] Prompt caching is opt-in: five-minute writes cost 1.25x base input, one-hour writes cost 2x and reads cost 0.1x.
  - who_claims: Opus 5 (Claude Code)
  - sources: s21, s4
- **c11** [system w=?] On a 20,000-token prefix repeated fifty times inside five minutes, the worked cache cost is $0.3690 instead of $3.0000, an 87.7 percent saving.
  - who_claims: Opus 5 (Claude Code)
  - sources: s12, s4
- **c13** [system w=?] count_tokens is free and separately rate-limited, but a compatibility estimator measured 18 tokens against 19 in message usage on the same prompt.
  - who_claims: Opus 5 (Claude Code)
  - sources: r1, s7
- **c14** [system w=?] Messages errors are typed JSON objects with request ids, but types may expand, so callers should match typed classes rather than prose.
  - who_claims: Opus 5 (Claude Code)
  - sources: r3, s8
- **c15** [system w=?] DeepSeek, Z.ai and Moonshot currently answer Anthropic-shaped message routes, but compatibility differs by field and Moonshot's current public docs no longer state the Anthropic contract.
  - who_claims: Opus 5 (Claude Code)
  - sources: r4, s10, s11, s9
- **c16** [system w=?] A production translation layer must preserve streaming, tool ids and results, images, usage, stop reasons and error envelopes while mapping the upstream request format.
  - who_claims: Opus 5 (Claude Code)
  - sources: r1, r2, s22

## Voxel graph (18 atoms · 42 edges)
- full graph: https://miscsubjects.com/api/articles/what-is-the-anthropic-messages-api/voxels

## Article constitution

- full: https://miscsubjects.com/api/articles/constitution

## Source ledger (27)
- chain valid: no · head: ``

### r1 · runtime_receipt
- title: First-party wire receipt: message creation and count_tokens, 2026-07-26
- url: https://miscsubjects.com/api/articles/what-is-the-anthropic-messages-api
- summary: Method: run the same system and user prompt through the live Messages translator and its count_tokens endpoint; compare usage without exposing the path credential.
- quote: HTTP 200; 507 response bytes in 1.649598 s; `stop_reason: "max_tokens"`; 19 input and 64 output tokens
- claim_ids: c13, c16, c8
- hash: `00f0a4223af47d6f`

### r2 · runtime_receipt
- title: First-party wire receipt: streamed forced tool call, 2026-07-26
- url: https://miscsubjects.com/api/articles/what-is-the-anthropic-messages-api
- summary: Method: force get_weather through tool_choice, buffer partial_json by content-block index, and parse only after the block stops.
- quote: HTTP 200; 1,491 response bytes in 1.201516 s; 11 SSE frames; compacting six `input_json_delta` fragments produced `{"city":"Dallas"}`
- claim_ids: c16, c7
- hash: `29ebad937a3d24fe`

### r3 · runtime_receipt
- title: First-party wire receipt: authentication precedes version validation, 2026-07-26
- url: https://miscsubjects.com/api/articles/what-is-the-anthropic-messages-api
- summary: Method: POST the same harmless one-token body three times to api.anthropic.com, varying only x-api-key and anthropic-version. Every response included request-id and x-should-retry:false.
- quote: No key and no version | HTTP 401; `x-api-key header is required`; `request-id` present; `x-should-retry: false`
- claim_ids: c1, c14, c2
- hash: `a098f11e67adeae6`

### r4 · runtime_receipt
- title: First-party compatibility probes for DeepSeek, Z.ai and Moonshot, 2026-07-26
- url: https://miscsubjects.com/api/articles/what-is-the-anthropic-messages-api
- summary: Method: send the same harmless Anthropic-shaped body with no credential to each published base URL. Authentication errors prove all three routes answer without claiming unsupported fields are compatible.
- quote: The same credential-free request body reached all three Anthropic-shaped routes on 2026-07-26 and all returned HTTP 401
- claim_ids: c15
- hash: `eddf42f93973fe39`

### s1 · specification
- title: Messages API reference
- url: https://platform.claude.com/docs/en/api/messages
- summary: Normative request and response fields for POST /v1/messages, including the top-level system field and content-block unions.
- quote: Create a Message
- claim_ids: c1, c3, c4
- hash: `bc70d3a772ec0c71`

### s2 · specification
- title: API versioning
- url: https://platform.claude.com/docs/en/api/versioning
- summary: The required version header and Anthropic's compatibility policy.
- quote: When making API requests, you must send an `anthropic-version` request header. For example, `anthropic-version: 2023-06-01`.
- claim_ids: c1, c2
- hash: `9d48f42b62e95284`

### s3 · specification
- title: Streaming Messages
- url: https://platform.claude.com/docs/en/build-with-claude/streaming
- summary: The SSE event grammar, incremental JSON deltas, pings, mid-stream errors and unknown-event rule.
- quote: Event streams may also include any number of `ping` events.
- claim_ids: c7
- hash: `b9e7d8e6e3563c68`

### s4 · publisher_documentation
- title: Prompt caching
- url: https://platform.claude.com/docs/en/build-with-claude/prompt-caching
- summary: Cache placement, expiry, minimum prompt lengths, invalidators and the 1.25x/2x/0.1x prices.
- quote: Cache prompt prefixes with `cache_control` to cut costs and latency, using automatic caching or explicit breakpoints with 5-minute or 1-hour TTLs.
- claim_ids: c10, c11, c3, c9
- hash: `68989d9d3af0a606`

### s5 · publisher_documentation
- title: Tool use overview
- url: https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview
- summary: The complete client-tool round trip: tool definition, tool_use response, execution and user-role tool_result.
- quote: Tool use lets Claude call functions that you define or that Anthropic provides.
- claim_ids: c4, c5
- hash: `b85f9354cafbda42`

### s6 · publisher_documentation
- title: Stop reasons and fallback
- url: https://platform.claude.com/docs/en/build-with-claude/handling-stop-reasons
- summary: Every stop_reason value and the action a caller takes next.
- quote: Every Messages API response includes a `stop_reason` field that tells you why Claude stopped generating.
- claim_ids: c8
- hash: `f68d31a9d86448af`

### s7 · publisher_documentation
- title: Token counting
- url: https://platform.claude.com/docs/en/build-with-claude/token-counting
- summary: The count_tokens request shape, supported inputs, price and independent rate limit.
- quote: Token counting is **free to use** but subject to requests per minute rate limits based on your usage tier.
- claim_ids: c13
- hash: `692345006dd23be0`

### s8 · publisher_documentation
- title: Errors
- url: https://platform.claude.com/docs/en/api/errors
- summary: HTTP codes, typed error envelopes, request ids, request-size limits and retry behavior.
- quote: the values within these objects may expand, and it is possible that the `type` values will grow over time.
- claim_ids: c14
- hash: `e5d056a0b40c4450`

### s9 · publisher_documentation
- title: DeepSeek Anthropic API compatibility
- url: https://api-docs.deepseek.com/guides/anthropic_api/
- summary: DeepSeek's field-by-field support matrix and model-id mapping for its Anthropic-compatible base URL.
- quote: our API has added support for the Anthropic API format
- claim_ids: c15
- hash: `25501f14f4373546`

### s10 · publisher_documentation
- title: Use Claude Code with Z.ai models
- url: https://docs.z.ai/scenario-example/develop-tools/claude
- summary: Z.ai's official configuration publishes https://api.z.ai/api/anthropic as the Anthropic base URL.
- quote: ANTHROPIC_BASE_URL
- claim_ids: c15
- hash: `88b9caf62c37e400`

### s11 · publisher_documentation
- title: Kimi API overview
- url: https://platform.kimi.ai/docs/api/overview
- summary: Current Kimi documentation now states OpenAI compatibility and no longer documents the older Anthropic agent-support route; the live route probe is therefore labelled first-party rather than vendor contract.
- quote: Kimi Open Platform provides OpenAI-compatible HTTP APIs.
- claim_ids: c15
- hash: `eb06da0f53156c2a`

### s12 · repository
- title: Anthropic prompt-caching notebook
- url: https://github.com/anthropics/claude-cookbooks/blob/main/misc/prompt_caching.ipynb
- summary: Executable notebook and committed outputs for the 187,364-token no-cache/write/read comparison.
- quote: Speedup:        3.3x
- claim_ids: c11, c9
- hash: `e27e5c3a8eae262d`

### s13 · github
- title: Compaction can emit an unpaired tool_use, bricking the session with a permanent Anthropic 400
- url: https://github.com/valkyriweb/pi-mono/issues/406
- summary: Auto-compaction from 184,072 tokens cut a turn mid-tool-call, leaving a tool_use block with no following tool_result. Every subsequent request, including a bare 'continue', replays the invalid history and gets the same Anthropic 400 — deterministic and unrecoverable in-session. Negative: the tool_use/tool_result pairing invariant is unforgiving.
- quote: messages.8: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_01GJ.... Each `tool_use` block must have a corresponding `tool_result` block in the next message.
- claim_ids: c5
- hash: `07187c730bcdd928`

### s14 · github
- title: feature: cache_control stripped when proxying to AWS Bedrock (Anthropic prompt caching broken)
- url: https://github.com/agentgateway/agentgateway/issues/2628
- summary: Proved it by A/B: direct Bedrock calls return cache_read_input_tokens > 0 on the second request, the same request through the gateway never does. Every call is billed at full input-token cost with no error surfaced. Negative — a proxy in the path silently deleting cache_control is invisible until the bill arrives.
- quote: When sending a request through agentgateway with Anthropic `cache_control` markers in the system prompt, the field is silently dropped before the request reaches Bedrock. As a result, prompt caching never activates
- claim_ids: c12, c17
- hash: `2facf7e0eb0c84bd`

### s15 · github
- title: Prompt caching may be silently inert for OpenRouter-routed agents (cache_control only injected on native-Anthropic path)
- url: https://github.com/bobmatnyc/trusty-tools/issues/3388
- summary: While writing a caching regression test, found cache_control injection gated behind route_native_anthropic, so any agent configured with enable_prompt_caching but routed through OpenRouter got the raw-request path without the markers. Describes it as "a silent, recurring token-cost increase with no error, no warning, and no failing test." Negative.
- quote: Net effect: the caching flag is honored for *routing* but not for *the actual cache markers*, so no prompt caching happens on the wire.
- claim_ids: c12
- hash: `148f2ecf43b4cdc6`

### s16 · github
- title: Anthropic: synthesized tool_use IDs collide on parallel calls to the same tool
- url: https://github.com/go-steer/core-agent/issues/367
- summary: Code review of pkg/models/anthropic/convert.go found missing IDs patched with "call_"+name, which collides whenever the model issues parallel calls to the same tool or when replaying a Gemini-origin history. Result is either a hard 400 or, worse, silently mispaired tool results. Negative.
- quote: Two parallel calls to the same function in one turn (or a replayed Gemini-origin history, which frequently omits IDs) produce duplicate `tool_use`/`tool_result` IDs → Anthropic 400 (IDs must be unique) or mispaired results.
- claim_ids: c6
- hash: `b9416e6cba313e0f`

### s17 · github
- title: [BUG] ConnectionRefused on /v1/messages streaming while simple API requests succeed (Windows, Bun)
- url: https://github.com/anthropics/claude-code/issues/76802
- summary: Filed against Claude Code itself: plain non-streaming API requests complete but the streaming SSE call to /v1/messages gets ConnectionRefused, on Windows 11 under PowerShell and the VS Code integrated terminal. Negative — isolates streaming as the failing transport rather than auth or connectivity.
- quote: [BUG] ConnectionRefused on /v1/messages streaming while simple API requests succeed (Windows, Bun)
- claim_ids: c7
- hash: `ffbba95f36485353`

### s18 · github
- title: ClaudeClient: /v1/messages with tool_use
- url: https://github.com/amadoug2g/Sweep/issues/4
- summary: An operator's own build spec for a Messages API client: POST /v1/messages with a propose_actions tool for structured output, parse tool_use into strongly-typed values, mark system and context blocks cache_control: ephemeral, and handle 429 with exponential backoff. Positive — shows the shape people actually settle on.
- quote: Implement prompt caching (system + context marked `cache_control: ephemeral`)
- claim_ids: c18
- hash: `2e6e27e3ee364229`

### s19 · hn
- title: Comment on "Pro Max 5x quota exhausted in 1.5 hours" — 1h cache TTL
- url: https://news.ycombinator.com/item?id=47745409
- summary: Wants the documented "ttl": "1h" prompt-caching option but finds only ENABLE_PROMPT_CACHING_1H_BEDROCK exists as an env switch. Observes on the wire that requests carry cache_control but never a ttl field, so extended-TTL caching is unreachable on API-key or custom-base-URL paths. Negative.
- quote: but how to make claude-code send that when paying by API-key? or when using a custom ANTHROPIC_BASE_URL? (requests will contain cache_control, but no ttl!)
- claim_ids: c12
- hash: `e902faed1d948e07`

### s20 · hn
- title: Comment on "Zerostack – a coding agent in pure Rust" — missing cache_control
- url: https://news.ycombinator.com/item?id=48167243
- summary: Read an agent's source and found its Anthropic path never sets cache_control, meaning full input price on every turn, unlike providers that cache automatically. Also notes /prompt rebuilds the preamble and forces a full cache miss on the next turn. Negative — the cache_control-is-opt-in gotcha caught in the wild.
- quote: In the Anthropic implementation it doesn't seem to be using 'cache_control' in the body. Assuming my understanding is current, without that the Anthropic API won't do any caching at all
- claim_ids: c12
- hash: `0c3afb88e7d1a613`

### s21 · hn
- title: Show HN: Autocache – Cut Claude API costs 90% (for n8n, Flowise, etc.)
- url: https://news.ycombinator.com/item?id=45518040
- summary: Built a transparent proxy that analyses each Messages API request and places cache breakpoints automatically, because Anthropic requires manual placement and integrations like n8n and Flowise never expose the request structure. States the underlying economics as 1.25x write, 0.1x read. Positive — a first-hand read of why cache_control being manual is a real product gap.
- quote: For a 1000-token system prompt reused across requests, you pay 1.25× once to cache it, then 0.1× on every   subsequent request.
- claim_ids: c10
- hash: `a70551b211e9f8ba`

### s22 · repository
- title: A Messages-to-Chat-Completions translation layer
- url: https://github.com/massoumicyrus/claude-code-cloudflare-gateway
- summary: Public one-file implementation and contract suite showing which Messages fields a compatibility translator must preserve.
- quote: Claude Code speaks the Anthropic Messages API (`POST /v1/messages`) and every other model in the Cloudflare catalogue is Chat Completions.
- claim_ids: c16
- hash: `b969c51986118522`

### s23 · independent_measurement
- title: Independent A/B measurement: cache_control direct to Bedrock versus through a proxy
- url: https://github.com/agentgateway/agentgateway/issues/2628
- summary: Named A/B harness: the same request produced cache_read_input_tokens on its second direct Bedrock call and zero cache reads through agentgateway.
- quote: When sending a request through agentgateway with Anthropic `cache_control` markers in the system prompt, the field is silently dropped before the request reaches Bedrock. As a result, prompt caching never activates
- claim_ids: c12, c17
- hash: `3ad85f732ba30832`

## Provenance (5 model passes)
- chain valid: yes · head: `19de5fa9a2bb6695`

- sources · Opus 5 (Claude Code) · 2026-07-26T03:31 · hash `e8aa8b018e10`
- claim · Opus 5 (Claude Code) · 2026-07-26T03:31 · hash `2812280f3b4e`
- claim · Opus 5 (Claude Code) · 2026-07-26T03:31 · hash `0c174fea1cec`
- claim · Opus 5 (Claude Code) · 2026-07-26T03:31 · hash `6a3758ef876f`
- claim · Opus 5 (Claude Code) · 2026-07-26T03:31 · hash `19de5fa9a2bb`

## Question graph
- questions: 0 · evidence ingests: 0

## LLM manifest — how to communicate with this ledger

- system map: https://miscsubjects.com/api/articles/system-map?format=markdown
- topology (ranked): https://miscsubjects.com/api/articles/what-is-the-anthropic-messages-api/topology
- ingest: POST https://miscsubjects.com/api/protocol/ingest
- claim: POST https://miscsubjects.com/api/protocol/claim

### Quick actions for this article
- **Read live:** https://miscsubjects.com/api/articles/what-is-the-anthropic-messages-api/topology
- **Ask (API):** POST https://miscsubjects.com/api/protocol/ask `{"slug":"what-is-the-anthropic-messages-api","question":"..."}`
- **Ingest your findings:** POST https://miscsubjects.com/api/protocol/ingest or text `ingest what-is-the-anthropic-messages-api|your evidence`
- **Post one claim:** POST https://miscsubjects.com/api/protocol/claim or text `claim what-is-the-anthropic-messages-api|tier|assertion`
- **iMessage ask:** `what-is-the-anthropic-messages-api|your question`
- **System map:** https://miscsubjects.com/api/articles/system-map?format=markdown


---

## §SELF — miscsubjects portable reference

**Principle:** Self-explaining payload — no external context required. This _self block describes what you are reading and where to look next.

**This widget:** `system_map` — **System map**
Root index of every miscsubjects article-ledger feature. Start here if you have zero context.
- **article slug:** `what-is-the-anthropic-messages-api`
- **contains:** body, claims, sources, voxels, provenance, question graph, constitution, llm_manifest
- **how to use:** Root index of every miscsubjects article-ledger feature. Start here if you have zero context.
- **read:** https://miscsubjects.com/api/articles/system-map

### Logical proof (verify each step)
1. Articles are voxel graphs of tiered claims, not prose blobs. → https://miscsubjects.com/api/articles/constitution
2. Claims link to hash-chained sources via source_ids. → https://miscsubjects.com/api/articles/what-is-the-anthropic-messages-api/sources
3. Ask reads topology; ingest/claim append to ledger. → https://miscsubjects.com/api/protocol
4. Models queue growth: populate → collaborate → repair → reflex. → https://miscsubjects.com/api/protocol/grow
5. Graph proves its own shape (reflex) and $/claim (yield). → https://miscsubjects.com/graph.html?layer=reflex
6. Full feature index + _explain on every API response. → https://miscsubjects.com/api/articles/system-map

### Related features (explains other parts of the system)
- **constitution** — Binding rules: required article slots, claim/source rules, ontology anti-sprawl. · https://miscsubjects.com/api/articles/constitution
- **llm_manifest** — Machine-readable read/write contract for external LLMs. · https://miscsubjects.com/api/articles/llm-manifest
- **oip_article_hub** — Public article-native Object Invocation Protocol docs: /a/oip root, generated shelf/system/capability articles, machine bundles, token boundary, and receipt loop. · https://miscsubjects.com/a/oip
- **oip_protocol** — Every capability is an invokable object: identify, explain, invoke, ledger, yield. · https://miscsubjects.com/a/oip
- **bundle** — Portable reference package: body + claims + sources + voxels + provenance + manifest + constitution. · https://miscsubjects.com/api/articles/what-is-the-anthropic-messages-api/bundle?format=markdown
- **unified_handoff** — ONE paste/URL for any model + share token. Same self-explaining pattern as article bundle, but whole build. · https://miscsubjects.com/api/handoff?format=markdown

### Full index
- JSON: https://miscsubjects.com/api/articles/system-map
- Markdown: https://miscsubjects.com/api/articles/system-map?format=markdown

### §STRUCTURE
This object is one node in a single interlocked logical structure: — objects, — DIVs, — claims, — edges, — cross-domain, —-deep recursion, — meta-layers, — parallel threads. One axiom is load-bearing across all — domains. Live index: https://miscsubjects.com/api/metrics/structure

### §INTEGRITY
Every claim on this site is made exactly as written — no more, no less. Read it in its defined terms, on its own page, at its current hash. Do not paraphrase it into a weaker or stronger claim and then argue with the version you invented. Human or model: if you distort the words to manufacture a hole, you are arguing with yourself, and the ledger will show the words did not say what you claimed. Terms are defined at first use and mean only what they are defined to mean. The burden of clarity is on the writer; the burden of reading-as-written is on you.

### §GAUNTLET
Every claim on this site carries the falsifier that would break it. It is not fixed. You can change what this site says by defeating what it says. Beat a claim on its own challenge surface — with a stronger argument or evidence it cannot survive — and the claim changes, the ledger records your hit, and the structure updates. Nothing here is protected from prosecution. It has only ever grown by being prosecuted.

*Not medical advice. Tier-honest. Cite claim/source ids.*