{"slug":"what-is-the-anthropic-messages-api","verification":{"valid":false,"broken_at":3,"reason":"hash mismatch"},"count":27,"sources":[{"id":"s1","type":"specification","url":"https://platform.claude.com/docs/en/api/messages","title":"Messages API reference","quote":"Create a Message","summary":"Normative request and response fields for POST /v1/messages, including the top-level system field and content-block unions.","publisher":"Anthropic","claim_ids":["c1","c3","c4"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"genesis","hash":"bc70d3a772ec0c71567fbd4df54e87654beaff109c8562332e27368ba127ad0b"},{"id":"s2","type":"specification","url":"https://platform.claude.com/docs/en/api/versioning","title":"API versioning","quote":"When making API requests, you must send an `anthropic-version` request header. For example, `anthropic-version: 2023-06-01`.","summary":"The required version header and Anthropic's compatibility policy.","publisher":"Anthropic","claim_ids":["c1","c2"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"bc70d3a772ec0c71567fbd4df54e87654beaff109c8562332e27368ba127ad0b","hash":"9d48f42b62e952840a3ceb37f57aee311174f85c3dc836c34c52409363188033"},{"id":"s3","type":"specification","url":"https://platform.claude.com/docs/en/build-with-claude/streaming","title":"Streaming Messages","quote":"Event streams may also include any number of `ping` events.","summary":"The SSE event grammar, incremental JSON deltas, pings, mid-stream errors and unknown-event rule.","publisher":"Anthropic","claim_ids":["c7"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"9d48f42b62e952840a3ceb37f57aee311174f85c3dc836c34c52409363188033","hash":"b9e7d8e6e3563c681ad169af9b9ff05fd91a34feb194e55c8f62c184b0d037ff"},{"id":"s4","type":"publisher_documentation","url":"https://platform.claude.com/docs/en/build-with-claude/prompt-caching","title":"Prompt caching","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.","summary":"Cache placement, expiry, minimum prompt lengths, invalidators and the 1.25x/2x/0.1x prices.","publisher":"Anthropic","claim_ids":["c10","c11","c3","c9"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"b9e7d8e6e3563c681ad169af9b9ff05fd91a34feb194e55c8f62c184b0d037ff","hash":"68989d9d3af0a6068c6f794a02d46e6aba403c5b1faa08d5552b6d89a0f3bd32"},{"id":"s5","type":"publisher_documentation","url":"https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview","title":"Tool use overview","quote":"Tool use lets Claude call functions that you define or that Anthropic provides.","summary":"The complete client-tool round trip: tool definition, tool_use response, execution and user-role tool_result.","publisher":"Anthropic","claim_ids":["c4","c5"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"68989d9d3af0a6068c6f794a02d46e6aba403c5b1faa08d5552b6d89a0f3bd32","hash":"b85f9354cafbda4260864d72b9bb83352a3a734f6baecd8f4fbee21ba28f3b2b"},{"id":"s6","type":"publisher_documentation","url":"https://platform.claude.com/docs/en/build-with-claude/handling-stop-reasons","title":"Stop reasons and fallback","quote":"Every Messages API response includes a `stop_reason` field that tells you why Claude stopped generating.","summary":"Every stop_reason value and the action a caller takes next.","publisher":"Anthropic","claim_ids":["c8"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"b85f9354cafbda4260864d72b9bb83352a3a734f6baecd8f4fbee21ba28f3b2b","hash":"f68d31a9d86448af7cd50ae2f834f8a71a753b52bacaa7f1613bf63ae5661248"},{"id":"s7","type":"publisher_documentation","url":"https://platform.claude.com/docs/en/build-with-claude/token-counting","title":"Token counting","quote":"Token counting is **free to use** but subject to requests per minute rate limits based on your usage tier.","summary":"The count_tokens request shape, supported inputs, price and independent rate limit.","publisher":"Anthropic","claim_ids":["c13"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"f68d31a9d86448af7cd50ae2f834f8a71a753b52bacaa7f1613bf63ae5661248","hash":"692345006dd23be0f26c36f403657ba0009e2f0ded9a0747af661d358b4c6958"},{"id":"s8","type":"publisher_documentation","url":"https://platform.claude.com/docs/en/api/errors","title":"Errors","quote":"the values within these objects may expand, and it is possible that the `type` values will grow over time.","summary":"HTTP codes, typed error envelopes, request ids, request-size limits and retry behavior.","publisher":"Anthropic","claim_ids":["c14"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"692345006dd23be0f26c36f403657ba0009e2f0ded9a0747af661d358b4c6958","hash":"e5d056a0b40c44503f31628096e15f38acbb6d8062d2d43666b5cf9181850667"},{"id":"s9","type":"publisher_documentation","url":"https://api-docs.deepseek.com/guides/anthropic_api/","title":"DeepSeek Anthropic API compatibility","quote":"our API has added support for the Anthropic API format","summary":"DeepSeek's field-by-field support matrix and model-id mapping for its Anthropic-compatible base URL.","publisher":"DeepSeek","claim_ids":["c15"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"e5d056a0b40c44503f31628096e15f38acbb6d8062d2d43666b5cf9181850667","hash":"25501f14f437354612d65736c579c26a2ece3cd482344f880e40ead3b5138d6f"},{"id":"s10","type":"publisher_documentation","url":"https://docs.z.ai/scenario-example/develop-tools/claude","title":"Use Claude Code with Z.ai models","quote":"ANTHROPIC_BASE_URL","summary":"Z.ai's official configuration publishes https://api.z.ai/api/anthropic as the Anthropic base URL.","publisher":"Z.ai","claim_ids":["c15"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"25501f14f437354612d65736c579c26a2ece3cd482344f880e40ead3b5138d6f","hash":"88b9caf62c37e4003251789694372cb7cb9420506e5fcd3398e5eadab0c4aa55"},{"id":"s11","type":"publisher_documentation","url":"https://platform.kimi.ai/docs/api/overview","title":"Kimi API overview","quote":"Kimi Open Platform provides OpenAI-compatible HTTP APIs.","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.","publisher":"Moonshot AI","claim_ids":["c15"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"88b9caf62c37e4003251789694372cb7cb9420506e5fcd3398e5eadab0c4aa55","hash":"eb06da0f53156c2a4eb51b9efb65815e6ee1e10c15ecb62f78810e654aa7fa0e"},{"id":"s12","type":"repository","url":"https://github.com/anthropics/claude-cookbooks/blob/main/misc/prompt_caching.ipynb","title":"Anthropic prompt-caching notebook","quote":"Speedup:        3.3x","summary":"Executable notebook and committed outputs for the 187,364-token no-cache/write/read comparison.","publisher":"Anthropic","claim_ids":["c11","c9"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"eb06da0f53156c2a4eb51b9efb65815e6ee1e10c15ecb62f78810e654aa7fa0e","hash":"e27e5c3a8eae262dec5f51702bf2c9cc97d932bda42fdac992e00894ef8a3f9a"},{"id":"s13","type":"github","url":"https://github.com/valkyriweb/pi-mono/issues/406","title":"Compaction can emit an unpaired tool_use, bricking the session with a permanent Anthropic 400","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.","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.","author":"valkyriweb","publisher":"GitHub","date":"2026-07-25","claim_ids":["c5"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"e27e5c3a8eae262dec5f51702bf2c9cc97d932bda42fdac992e00894ef8a3f9a","hash":"07187c730bcdd9286fe37ea6187cf2bdbd1b30db7ef66da3bd928fc6925b123c"},{"id":"s14","type":"github","url":"https://github.com/agentgateway/agentgateway/issues/2628","title":"feature: cache_control stripped when proxying to AWS Bedrock (Anthropic prompt caching broken)","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","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.","author":"guenhter","publisher":"GitHub","date":"2026-07-22","claim_ids":["c12","c17"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"07187c730bcdd9286fe37ea6187cf2bdbd1b30db7ef66da3bd928fc6925b123c","hash":"2facf7e0eb0c84bd4ec415af006320fba1df82124e5227a4b751e58a83e201f6"},{"id":"s15","type":"github","url":"https://github.com/bobmatnyc/trusty-tools/issues/3388","title":"Prompt caching may be silently inert for OpenRouter-routed agents (cache_control only injected on native-Anthropic path)","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.","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.","author":"bobmatnyc","publisher":"GitHub","date":"2026-07-20","claim_ids":["c12"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"2facf7e0eb0c84bd4ec415af006320fba1df82124e5227a4b751e58a83e201f6","hash":"148f2ecf43b4cdc6d8a9ea4f382344ccfd981149ed98838d6a8cff76bc1be5ac"},{"id":"s16","type":"github","url":"https://github.com/go-steer/core-agent/issues/367","title":"Anthropic: synthesized tool_use IDs collide on parallel calls to the same tool","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.","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.","author":"mastersingh24","publisher":"GitHub","date":"2026-07-25","claim_ids":["c6"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"148f2ecf43b4cdc6d8a9ea4f382344ccfd981149ed98838d6a8cff76bc1be5ac","hash":"b9416e6cba313e0fc3f0b784acfcab067a5ab7f4fcb60d81e9cb5f0cccecdbbd"},{"id":"s17","type":"github","url":"https://github.com/anthropics/claude-code/issues/76802","title":"[BUG] ConnectionRefused on /v1/messages streaming while simple API requests succeed (Windows, Bun)","quote":"[BUG] ConnectionRefused on /v1/messages streaming while simple API requests succeed (Windows, Bun)","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.","author":"tushar1210","publisher":"GitHub","date":"2026-07-12","claim_ids":["c7"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"b9416e6cba313e0fc3f0b784acfcab067a5ab7f4fcb60d81e9cb5f0cccecdbbd","hash":"ffbba95f36485353f8e5d5f6e597a2e0013309e1e1e882d17cd309f723e3c90b"},{"id":"s18","type":"github","url":"https://github.com/amadoug2g/Sweep/issues/4","title":"ClaudeClient: /v1/messages with tool_use","quote":"Implement prompt caching (system + context marked `cache_control: ephemeral`)","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.","author":"amadoug2g","publisher":"GitHub","date":"2026-05-17","claim_ids":["c18"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"ffbba95f36485353f8e5d5f6e597a2e0013309e1e1e882d17cd309f723e3c90b","hash":"2e6e27e3ee364229f66c621044202fb85bb3c36144279167970b991f07761723"},{"id":"s19","type":"hn","url":"https://news.ycombinator.com/item?id=47745409","title":"Comment on \"Pro Max 5x quota exhausted in 1.5 hours\" — 1h cache TTL","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!)","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.","author":"g4cg54g54","publisher":"Hacker News","date":"2026-04-12","claim_ids":["c12"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"2e6e27e3ee364229f66c621044202fb85bb3c36144279167970b991f07761723","hash":"e902faed1d948e07085fc9c58c9403d6780a527c8307baab34f68dc23eb98b6c"},{"id":"s20","type":"hn","url":"https://news.ycombinator.com/item?id=48167243","title":"Comment on \"Zerostack – a coding agent in pure Rust\" — missing cache_control","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","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.","author":"post_below","publisher":"Hacker News","date":"2026-05-17","claim_ids":["c12"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"e902faed1d948e07085fc9c58c9403d6780a527c8307baab34f68dc23eb98b6c","hash":"0c3afb88e7d1a61395fda26ec30e9d3e7f8174eced04632c1bf72ca80e7748d7"},{"id":"s21","type":"hn","url":"https://news.ycombinator.com/item?id=45518040","title":"Show HN: Autocache – Cut Claude API costs 90% (for n8n, Flowise, etc.)","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.","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.","author":"jmrobles","publisher":"Hacker News","date":"2025-10-08","claim_ids":["c10"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"0c3afb88e7d1a61395fda26ec30e9d3e7f8174eced04632c1bf72ca80e7748d7","hash":"a70551b211e9f8badab01264126e46fc82046dea49720147ae9cfc3bdcff267c"},{"id":"s22","type":"repository","url":"https://github.com/massoumicyrus/claude-code-cloudflare-gateway","title":"A Messages-to-Chat-Completions translation layer","quote":"Claude Code speaks the Anthropic Messages API (`POST /v1/messages`) and every other model in the Cloudflare catalogue is Chat Completions.","summary":"Public one-file implementation and contract suite showing which Messages fields a compatibility translator must preserve.","publisher":"GitHub","claim_ids":["c16"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"a70551b211e9f8badab01264126e46fc82046dea49720147ae9cfc3bdcff267c","hash":"b969c51986118522cf93d945f77209e31007b442d6c53cbc32b86528899917b3"},{"id":"s23","type":"independent_measurement","url":"https://github.com/agentgateway/agentgateway/issues/2628","title":"Independent A/B measurement: cache_control direct to Bedrock versus through a proxy","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","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.","author":"guenhter","publisher":"GitHub","date":"2026-07-22","claim_ids":["c12","c17"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"b969c51986118522cf93d945f77209e31007b442d6c53cbc32b86528899917b3","hash":"3ad85f732ba308326f3ea99c21fbd070622182424f4012f26cbd6e0426689af9"},{"id":"r1","type":"runtime_receipt","url":"https://miscsubjects.com/api/articles/what-is-the-anthropic-messages-api","title":"First-party wire receipt: message creation and count_tokens, 2026-07-26","quote":"HTTP 200; 507 response bytes in 1.649598 s; `stop_reason: \"max_tokens\"`; 19 input and 64 output tokens","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.","publisher":"miscsubjects.com","date":"2026-07-26","claim_ids":["c13","c16","c8"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"3ad85f732ba308326f3ea99c21fbd070622182424f4012f26cbd6e0426689af9","hash":"00f0a4223af47d6fccbfe744227e314a99d4770d956b17dd40e2b12f98553a8f"},{"id":"r2","type":"runtime_receipt","url":"https://miscsubjects.com/api/articles/what-is-the-anthropic-messages-api","title":"First-party wire receipt: streamed forced tool call, 2026-07-26","quote":"HTTP 200; 1,491 response bytes in 1.201516 s; 11 SSE frames; compacting six `input_json_delta` fragments produced `{\"city\":\"Dallas\"}`","summary":"Method: force get_weather through tool_choice, buffer partial_json by content-block index, and parse only after the block stops.","publisher":"miscsubjects.com","date":"2026-07-26","claim_ids":["c16","c7"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"00f0a4223af47d6fccbfe744227e314a99d4770d956b17dd40e2b12f98553a8f","hash":"29ebad937a3d24fea57076ad825c23b2bcff0006885a717f34f6d01ab2d3df44"},{"id":"r3","type":"runtime_receipt","url":"https://miscsubjects.com/api/articles/what-is-the-anthropic-messages-api","title":"First-party wire receipt: authentication precedes version validation, 2026-07-26","quote":"No key and no version | HTTP 401; `x-api-key header is required`; `request-id` present; `x-should-retry: false`","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.","publisher":"Anthropic API","date":"2026-07-26","claim_ids":["c1","c14","c2"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"29ebad937a3d24fea57076ad825c23b2bcff0006885a717f34f6d01ab2d3df44","hash":"a098f11e67adeae609ba7879717be54316ee2b92eba9966aadd176c4d51638b5"},{"id":"r4","type":"runtime_receipt","url":"https://miscsubjects.com/api/articles/what-is-the-anthropic-messages-api","title":"First-party compatibility probes for DeepSeek, Z.ai and Moonshot, 2026-07-26","quote":"The same credential-free request body reached all three Anthropic-shaped routes on 2026-07-26 and all returned HTTP 401","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.","publisher":"miscsubjects.com","date":"2026-07-26","claim_ids":["c15"],"accessed_at":"2026-07-26T05:16:02.305Z","prev":"a098f11e67adeae609ba7879717be54316ee2b92eba9966aadd176c4d51638b5","hash":"eddf42f93973fe3913739d557c41a236bbf884dc7bb54fb88fb495b8a50f21bc"}]}