SPB Git forge

spb/doc-api

Public
2commits 1branches 0releases
15.7 MBsize
maindefault branch
13 days agolast push
Python 88.3% TypeScript 7.6% Shell 4.1%
62.9 KB · 344 lines python
Raw Blame History
1#!/usr/bin/env python32"""Emit the anthropic-advanced fragments (parameters, endpoints, objects, compatibility, streaming events)."""3import json4from pathlib import Path56ROOT = Path(__file__).resolve().parents[2]7F = ROOT / "generated" / "fragments"8RET = "2026-09-18"9VER = "2026-09-18"10D = "https://platform.claude.com/docs/en/"11S = {12    "cache": D + "build-with-claude/prompt-caching",13    "cachediag": D + "build-with-claude/cache-diagnostics",14    "thinking": D + "build-with-claude/thinking",15    "ext": D + "build-with-claude/extended-thinking",16    "steer": D + "build-with-claude/thinking-steering-and-cost",17    "trouble": D + "build-with-claude/thinking-troubleshooting",18    "preserved": D + "build-with-claude/preserved-thinking",19    "effort": D + "build-with-claude/effort",20    "fast": D + "build-with-claude/fast-mode",21    "ctxwin": D + "build-with-claude/context-windows",22    "ctxedit": D + "build-with-claude/context-editing",23    "compact": D + "build-with-claude/compaction",24    "taskb": D + "build-with-claude/task-budgets",25    "so": D + "build-with-claude/structured-outputs",26    "cite": D + "build-with-claude/citations",27    "search": D + "build-with-claude/search-results",28    "vision": D + "build-with-claude/vision",29    "coords": D + "build-with-claude/vision-coordinates",30    "pdf": D + "build-with-claude/pdf-support",31    "files": D + "build-with-claude/files",32    "filesapi": D + "api/files",33    "msgs": D + "api/messages/create",34    "betamsgs": D + "api/beta/messages",35    "beta": D + "api/beta-headers",36    "midsys": D + "build-with-claude/mid-conversation-system-messages",37    "models": D + "models/overview",38    "release": D + "release-notes/api",39}404142def src(*keys):43    return [{"url": S[k], "retrieved_at": RET} for k in keys]444546ALL_ACTIVE = ["claude-fable-5-1", "claude-opus-5", "claude-sonnet-5", "claude-fable-5", "claude-opus-4-8", "claude-opus-4-7",47              "claude-sonnet-4-6", "claude-opus-4-6", "claude-opus-4-5-20251101", "claude-haiku-4-5-20251001", "claude-sonnet-4-5-20250929"]48ADAPTIVE = ["claude-fable-5-1", "claude-opus-5", "claude-sonnet-5", "claude-fable-5", "claude-opus-4-8", "claude-opus-4-7", "claude-sonnet-4-6", "claude-opus-4-6"]49ENABLED = ["claude-sonnet-4-6", "claude-opus-4-6", "claude-opus-4-5-20251101", "claude-haiku-4-5-20251001", "claude-sonnet-4-5-20250929"]50EFFORT = ["claude-fable-5-1", "claude-opus-5", "claude-sonnet-5", "claude-fable-5", "claude-opus-4-8", "claude-opus-4-7", "claude-sonnet-4-6", "claude-opus-4-6", "claude-opus-4-5-20251101"]51XHIGH = ["claude-fable-5-1", "claude-opus-5", "claude-sonnet-5", "claude-fable-5", "claude-opus-4-8", "claude-opus-4-7"]52MAX = ["claude-fable-5-1", "claude-opus-5", "claude-sonnet-5", "claude-fable-5", "claude-opus-4-8", "claude-opus-4-7", "claude-sonnet-4-6", "claude-opus-4-6"]53COMPACT = ["claude-fable-5-1", "claude-opus-5", "claude-sonnet-5", "claude-fable-5", "claude-opus-4-8", "claude-opus-4-7", "claude-sonnet-4-6", "claude-opus-4-6"]54ONE_M = COMPACT55FAST = ["claude-opus-5", "claude-opus-4-8"]56TASKB = ["claude-fable-5-1", "claude-opus-5", "claude-fable-5", "claude-opus-4-8", "claude-opus-4-7"]57PER_MSG_EFFORT = ["claude-fable-5-1", "claude-opus-5"]58MSG = "POST /v1/messages"59CT = "POST /v1/messages/count_tokens"606162def P(parameter, type_, description, *, endpoint=MSG, location="body", required=False, default=None, enum=None,63      minimum=None, maximum=None, models=None, beta=None, status=None, source="cache", verification=None):64    return {65        "provider": "anthropic", "endpoint": endpoint, "parameter": parameter, "location": location, "type": type_,66        "required": required, "default": default, "minimum": minimum, "maximum": maximum, "enum": enum,67        "description": description, "compatible_models": models if models is not None else ALL_ACTIVE,68        "beta_header": beta, "status": status or ["DOCUMENTED"], "source": S[source],69        "verification": verification, "last_verified": VER,70    }717273def V(result="success", http=200, note=""):74    return {"method": "live_api", "verified_at": VER, "result": result, "http_status": http, "request_note": note}757677LV = ["DOCUMENTED", "LIVE_VERIFIED"]78LVB = ["DOCUMENTED", "BETA", "LIVE_VERIFIED"]7980params = [81    # ---- prompt caching ----82    P("cache_control", "object (CacheControlEphemeral) | null", "Top-level automatic caching: the API places one cache breakpoint on the last cacheable block and moves it forward as the conversation grows. Uses one of the 4 breakpoint slots. 400 if the last block already carries an explicit cache_control with a different TTL, or if 4 explicit breakpoints exist. Not accepted on legacy Bedrock (Opus 4.6 and earlier).", status=LV, verification=V(note="cache_03_auto_top_level: cache_read 5809 + cache_creation 7 on Haiku")),83    P("cache_control.type", "string", "Cache type. Only 'ephemeral' exists.", enum=["ephemeral"], default=None, status=LV, verification=V()),84    P("cache_control.ttl", "string", "Cache lifetime. 5m (default, 1.25x input price on write) or 1h (2x on write). Longer-TTL breakpoints must precede shorter ones in the prompt.", enum=["5m", "1h"], default="5m", status=LV, verification=V(note="cache_04: ephemeral_1h_input_tokens=5809; ttl '2h' -> 400 \"Input should be '5m' or '1h'\"")),85    P("system[].cache_control", "object (CacheControlEphemeral) | null", "Explicit breakpoint on a system text block. Caches tools + system up to and including this block.", status=LV, verification=V(note="cache_01/02: creation 5809 then read 5809")),86    P("tools[].cache_control", "object (CacheControlEphemeral) | null", "Explicit breakpoint on a tool definition; caches all tools up to and including it.", status=LV, verification=V(note="cache_06/07: creation 7484 then read 7484")),87    P("messages[].content[].cache_control", "object (CacheControlEphemeral) | null", "Explicit breakpoint on a content block (text, image, document, tool_use, tool_result, search_result, compaction). Max 4 breakpoints per request (400 'A maximum of 4 blocks with cache_control may be provided'). Not allowed on thinking blocks, sub-blocks (citations) or empty text blocks. NOT accepted at message level (messages[].cache_control -> 400 'Extra inputs are not permitted').", status=LV, verification=V(result="failure", http=400, note="cache_10 five breakpoints -> 400; cache_11 message-level -> 400")),88    P("max_tokens", "integer", "Set to 0 to pre-warm the cache: prompt is read, cache written at explicit breakpoints, empty content returned with stop_reason max_tokens and 0 output tokens. Rejected with stream:true, thinking enabled, output_config.format, tool_choice any/tool, or inside Message Batches.", minimum=0, status=LV, verification=V(note="cache_08_prewarm: content [], stop_reason max_tokens, cache_read 5809")),89    P("diagnostics", "object (BetaDiagnosticsParam) | null", "Cache diagnostics (beta): pass the previous response id so the API reports where the prompt prefix diverged in response.diagnostics.", beta="cache-diagnosis-2026-04-07", status=LVB, source="cachediag", verification=V(note="cache_12: diagnostics.previous_message_id=null accepted, response diagnostics=null")),90    P("diagnostics.previous_message_id", "string | null", "msg_… id of this client's previous response; null on the first turn to opt in.", maximum=256, beta="cache-diagnosis-2026-04-07", status=["DOCUMENTED", "BETA"], source="cachediag"),91    # ---- thinking ----92    P("thinking", "object (ThinkingConfigParam)", "Thinking configuration. Variants: {type:'enabled', budget_tokens, display}, {type:'adaptive', display}, {type:'disabled'}. Per-model acceptance differs (see compatibility matrix). Omitting it means: on/always-on for 5.x & Fable, off for Opus 4.6-4.8/Sonnet 4.6 and all 4.5 models.", status=LV, source="thinking", verification=V()),93    P("thinking.type", "string", "enabled = manual extended thinking (deprecated on 4.6, 400 on 4.7+ / Sonnet 5 / Opus 5 / Fable); adaptive = model decides (400 on 4.5 models: 'adaptive thinking is not supported on this model'); disabled = off (400 on Fable/Mythos; 400 on Opus 5 with effort xhigh/max).", enum=["enabled", "adaptive", "disabled"], status=LV, source="trouble", verification=V(note="think_07 adaptive on Haiku -> 400; adaptive_03 enabled on Sonnet 5 -> 400")),94    P("thinking.budget_tokens", "integer", "Target (not hard cap) for reasoning tokens in manual mode. Must be >= 1024 and < max_tokens (except with interleaved thinking where it may exceed max_tokens). Rendered into the prompt: changing it invalidates message-level cache breakpoints.", minimum=1024, models=ENABLED, status=LV, source="ext", verification=V(note="think_05 512 -> 400 'greater than or equal to 1024'; think_06 2000 >= max_tokens 1200 -> 400")),95    P("thinking.display", "string", "How thinking text is returned. summarized = summary text (default on <=4.6); omitted = empty thinking field, signature kept (default on 4.7+, 5.x, Fable/Mythos); updates (beta, header thinking-display-updates-2026-08-18) = progress-update blocks carry text, reasoning blocks empty. Invalid with type disabled. Billing identical for all values.", enum=["summarized", "omitted", "updates"], default="model-specific (summarized <=4.6, omitted 4.7+)", status=LVB, source="thinking", verification=V(note="think_08 omitted -> thinking:'' + signature; adaptive_05 'updates' without header -> 400; adaptive_06 with header -> 200")),96    P("thinking.block_binding", "object (BetaThinkingBlockBinding) | null", "Preserved-thinking controls (beta). Accepted with type adaptive or enabled. Without the beta header -> 400 'block_binding: Extra inputs are not permitted'.", beta="thinking-binding-controls-2026-08-01", status=LVB, source="preserved", verification=V(note="adaptive_07: accepted on Sonnet 5, response input_transformations=[]")),97    P("thinking.block_binding.prefix_mismatch_behavior", "string", "What happens when a replayed thinking block fails the conversation (prefix) check: error (default, 400 naming the block) or drop_block (drop it and later thinking blocks, report in input_transformations). Enforced by default only for accounts created on/after 2026-08-31 on Fable 5.1 / Mythos 5.1.", enum=["error", "drop_block"], default="error", beta="thinking-binding-controls-2026-08-01", status=["DOCUMENTED", "BETA"], source="preserved"),98    P("temperature", "number", "Incompatible with thinking on <=4.6 models: 400 '`temperature` may only be set to 1 when thinking is enabled.' On Opus 4.7+, Sonnet 5, Opus 5, Fable/Mythos any non-default value is a 400 on every request ('`temperature` is deprecated for this model.').", status=LV, source="thinking", verification=V(result="failure", http=400, note="think_03 Haiku+thinking -> 400; adaptive_04 Sonnet 5 temperature 0.2 -> 400")),99    P("top_k", "integer", "Must be unset when thinking is enabled (400 '`top_k` must be unset when thinking is enabled'). Non-default values rejected on every request on Opus 4.7+/Sonnet 5/Opus 5/Fable.", status=LV, source="thinking", verification=V(result="failure", http=400, note="think_04")),100    P("top_p", "number", "With thinking on <=4.6 models only values between 0.95 and 1 are allowed; non-default rejected on 4.7+/5.x/Fable.", source="thinking"),101    P("tool_choice", "object", "With manual extended thinking only auto/none are allowed: any/tool -> 400 'Thinking may not be enabled when tool_choice forces tool use.' Adaptive thinking allows forced tool use, except Fable 5.1 / Mythos 5.1 which reject any/tool on every request. Changing tool_choice invalidates the messages cache.", status=LV, source="thinking", verification=V(result="failure", http=400, note="think_09")),102    P("messages[].content[] (assistant prefill)", "string", "Assistant prefill is documented as unsupported while thinking is on (400 on Opus 4.6+, Fable). OBSERVED on Haiku 4.5: prefill + thinking enabled returned 200 with thinking silently disabled (no thinking block, no output_tokens_details).", models=ENABLED, status=["DOCUMENTED", "LIVE_DISCOVERED"], source="thinking", verification=V(note="think_14_prefill_conflict -> 200, no thinking block")),103    # ---- effort ----104    P("output_config", "object (OutputConfig)", "Output configuration container: effort, format (structured outputs), task_budget (beta).", status=LV, source="effort", verification=V()),105    P("output_config.effort", "string", "How much work Claude puts into the whole response (text, tool calls, thinking). Default high (explicit high == omitted, cache-neutral). xhigh/max availability per model. Rendered into the prompt: changing the top-level value invalidates message cache breakpoints (and tool/system on some models). 400 on unsupported models: 'This model does not support the effort parameter.' Invalid value -> 400 \"Input should be 'low', 'medium', 'high', 'xhigh' or 'max'\".", enum=["low", "medium", "high", "xhigh", "max"], default="high", models=EFFORT, status=LV, source="effort", verification=V(note="effort low/xhigh/max on Sonnet 5 -> 200; 'ultra' -> 400; Haiku -> 400")),106    P("messages[].output_config.effort", "string", "Per-message effort (beta): a {role:'system', content:[], output_config:{effort}} entry inside messages changes effort from the next user turn on without invalidating the cache. Only Fable 5.1, Mythos 5.1, Opus 5; others -> 400 'output_config.effort requires a model that supports per-turn effort; this model does not'.", enum=["low", "medium", "high", "xhigh", "max"], models=PER_MSG_EFFORT, beta="mid-conversation-output-config-2026-07-01", status=["DOCUMENTED", "BETA", "LIVE_VERIFIED"], source="effort", verification=V(result="failure", http=400, note="effort_per_message_sonnet5_beta -> 400 (documented rejection)")),107    P("output_config.task_budget", "object (BetaTokenTaskBudget) | null", "Advisory token budget for a whole agentic loop (thinking + tool calls + tool results + output); the model sees a server-injected countdown. Soft hint, not enforced. Doc minimum 20,000 (reference schema says minimum 1024 — discrepancy). Doc says unsupported on Sonnet 5, but a Sonnet 5 request with the header and total 20000 returned 200 (silently accepted?).", models=TASKB, beta="task-budgets-2026-03-13", status=["DOCUMENTED", "BETA", "LIVE_DISCOVERED"], source="taskb", verification=V(note="task_budget_sonnet5_unsupported -> 200 with usage.iterations present")),108    P("output_config.task_budget.type", "string", "Always 'tokens'.", enum=["tokens"], models=TASKB, beta="task-budgets-2026-03-13", status=["DOCUMENTED", "BETA"], source="taskb"),109    P("output_config.task_budget.total", "integer", "Total tokens for the agentic loop. Documented minimum 20,000; schema minimum 1024.", minimum=20000, models=TASKB, beta="task-budgets-2026-03-13", status=["DOCUMENTED", "BETA"], source="taskb"),110    P("output_config.task_budget.remaining", "integer | null", "Budget remainder carried over after client-side compaction. Defaults to total. Not allowed with the compaction parameter or a signed compaction block (400). Changing it invalidates the cache.", minimum=0, models=TASKB, beta="task-budgets-2026-03-13", status=["DOCUMENTED", "BETA"], source="taskb"),111    # ---- fast mode ----112    P("speed", "string | null", "Inference speed. 'fast' = up to 2.5x output tokens/s at 2x pricing ($10/$50 Opus 5 & 4.8), research preview, dedicated rate limit. Requires beta header; without it -> 400 'speed: Extra inputs are not permitted'. Unsupported model -> 400 \"'<model>' does not support the `speed` parameter\". Opus 4.6: silently runs standard. Switching speed invalidates system+messages cache. Not on Batch API, Priority Tier, Bedrock/Vertex/Foundry/Claude Platform on AWS.", enum=["standard", "fast"], default="standard", models=FAST, beta="fast-mode-2026-02-01", status=["DOCUMENTED", "PREVIEW", "BETA", "ACCOUNT_RESTRICTED"], source="fast", verification=V(result="restricted", http=429, note="fast_01 Opus 5 -> 429 rate_limit_error 'rate limit of 0 fast mode input tokens per minute'; speed:'standard' -> 200 usage.speed='standard'")),113    # ---- context ----114    P("anthropic-beta: context-1m-2025-08-07", "header", "Legacy 1M-context beta header. 1M is now the default (no header) on Opus 4.6+/Sonnet 4.6+/Sonnet 5/Opus 5/Fable; retired for Sonnet 4.5/Sonnet 4 (no effect, >200k errors). Observed: accepted and ignored on Sonnet 5 and Haiku 4.5.", location="header", models=ALL_ACTIVE, beta="context-1m-2025-08-07", status=["DOCUMENTED", "LEGACY", "LIVE_VERIFIED"], source="ctxwin", verification=V(note="ctx1m_01/02 -> 200")),115    P("anthropic-beta: model-context-window-exceeded-2025-08-26", "header", "Opt older models into stop_reason model_context_window_exceeded instead of a validation error when input + max_tokens exceeds the window (default behaviour on 4.5+).", location="header", beta="model-context-window-exceeded-2025-08-26", status=["DOCUMENTED", "BETA"], source="ctxwin"),116    P("context_management", "object (BetaContextManagementConfig) | null", "Server-side context editing. Requires beta header (without: 400 'context_management: Extra inputs are not permitted'). Also accepted by count_tokens (returns context_management.original_input_tokens).", beta="context-management-2025-06-27", status=LVB, source="ctxedit", verification=V(note="ctxedit_01 applied_edits clear_tool_uses cleared_tool_uses 2 cleared_input_tokens 174")),117    P("context_management.edits[]", "array of edit objects", "Ordered strategies. clear_thinking_20251015 must be listed first when combined. Types: clear_tool_uses_20250919, clear_thinking_20251015, compact_20260112.", beta="context-management-2025-06-27 (compact_20260112: compact-2026-01-12)", status=LVB, source="ctxedit", verification=V()),118    P("context_management.edits[].type", "string", "Strategy identifier.", enum=["clear_tool_uses_20250919", "clear_thinking_20251015", "compact_20260112"], beta="context-management-2025-06-27", status=LVB, source="ctxedit", verification=V()),119    P("context_management.edits[].trigger", "object", "clear_tool_uses: {type:'input_tokens'|'tool_uses', value>=1} default 100000 input tokens. compact_20260112: {type:'input_tokens', value>=50000} default 150000 (400 'trigger.value must be at least 50000').", default="clear_tool_uses: input_tokens 100000; compact: input_tokens 150000", beta="context-management-2025-06-27", status=LVB, source="ctxedit", verification=V(note="compact_03 value 1000 -> 400")),120    P("context_management.edits[].keep", "object | 'all'", "clear_tool_uses: {type:'tool_uses', value} default 3. clear_thinking: {type:'thinking_turns', value>=1} | {type:'all'} | 'all'; default model-specific (all turns on Opus 4.5+/Sonnet 4.6+/Fable, last turn on Haiku & earlier).", beta="context-management-2025-06-27", status=LVB, source="ctxedit", verification=V()),121    P("context_management.edits[].clear_at_least", "object | null", "{type:'input_tokens', value}: minimum tokens that must be clearable or the strategy is skipped (protects the prompt cache). clear_tool_uses only.", beta="context-management-2025-06-27", status=LVB, source="ctxedit", verification=V()),122    P("context_management.edits[].exclude_tools", "array of string | null", "Tool names whose uses/results are never cleared (clear_tool_uses).", beta="context-management-2025-06-27", status=["DOCUMENTED", "BETA"], source="ctxedit"),123    P("context_management.edits[].clear_tool_inputs", "boolean | array of string | null", "Also clear tool_use inputs (all, or listed tool names). Default false (results only).", default=False, beta="context-management-2025-06-27", status=["DOCUMENTED", "BETA"], source="ctxedit"),124    P("context_management.edits[].pause_after_compaction", "boolean", "compact_20260112: return after writing the compaction block with stop_reason 'compaction' so the client can append content before continuing.", default=False, models=COMPACT, beta="compact-2026-01-12", status=["DOCUMENTED", "BETA"], source="compact"),125    P("context_management.edits[].instructions", "string | null", "compact_20260112: custom summarization prompt; completely replaces the default. On Fable 5.1/Mythos 5.1 custom instructions summarize the visible conversation only (no earlier thinking).", models=COMPACT, beta="compact-2026-01-12", status=["DOCUMENTED", "BETA"], source="compact"),126    P("compaction", "object (BetaCompactionConfig) | null", "On-demand compaction (beta compact-2026-09-04): {type:'summarize', instructions?}. Summarizes every message sent, returns a single signed compaction block, no reply, stop_reason 'compaction', top-level usage 0 with usage.iterations[type=compaction]. Cannot combine with context_management, stop_sequences, output_config.format, tool_choice any/tool, task_budget.remaining. Send the block first in later requests (else 400 compaction_block_misplaced).", models=COMPACT, beta="compact-2026-09-04", status=LVB, source="compact", verification=V(note="compact_04 Sonnet 5 -> compaction block + signature; compact_05 continuation -> 200; compact_06 misplaced -> 400")),127    P("compaction.type", "string", "Only 'summarize'.", enum=["summarize"], models=COMPACT, beta="compact-2026-09-04", status=LVB, source="compact", verification=V()),128    P("compaction.instructions", "string | null", "Replaces the server summarization prompt (max 16,384 chars; blank counts as absent). The summarizer reads earlier thinking too in this mode.", maximum=16384, models=COMPACT, beta="compact-2026-09-04", status=["DOCUMENTED", "BETA"], source="compact"),129    # ---- structured outputs ----130    P("output_config.format", "object (JSONOutputFormat) | null", "JSON outputs: constrain the text response to a JSON Schema via constrained decoding. GA, no beta header. Legacy top-level output_format -> 400 \"output_format: This field is deprecated. Use 'output_config.format' instead\". 400 with citations enabled ('Citations cannot be enabled when output format is set'). Incompatible with prefill and max_tokens:0. Adds a system prompt (more input tokens) and invalidates the cache when changed.", status=LV, source="so", verification=V(note="so_01 -> {\"name\":\"Ada\",\"age\":36,\"city\":\"Lyon\"}; so_07 legacy output_format -> 400")),131    P("output_config.format.type", "string", "Only json_schema.", enum=["json_schema"], status=LV, source="so", verification=V()),132    P("output_config.format.schema", "object (JSON Schema subset)", "Supported: basic types, enum (primitives), const, anyOf/allOf (no allOf+$ref), $ref/$defs/definitions (internal), default, required, additionalProperties:false, formats date-time/time/date/duration/email/hostname/uri/ipv4/ipv6/uuid, minItems 0|1, simple regex pattern. Unsupported -> 400 e.g. \"For 'object' type, property 'patternProperties' is not supported\", \"For 'integer' type, property 'minimum' is not supported\". Limits: 20 strict tools, 24 optional params, 16 union params, 180 s compile timeout.", status=LV, source="so", verification=V(result="failure", http=400, note="so_03 patternProperties; so_04 minimum")),133    P("output_config.format", "object (JSONOutputFormat) | null", "count_tokens accepts output_config.format (no grammar compilation); observed same input_tokens (205) as the real call.", endpoint=CT, status=LV, source="so", verification=V(note="so_05_count_tokens")),134    P("tools[].strict", "boolean", "Strict tool use: grammar-constrained tool inputs matching input_schema (same JSON Schema subset). Combinable with output_config.format. Max 20 strict tools.", default=False, status=LV, source="so", verification=V(note="so_08 strict tool + tool_choice tool -> valid input; tool_use carries caller:{type:'direct'}")),135    # ---- citations / documents / images ----136    P("messages[].content[].citations.enabled", "boolean", "Enable citations on a document or search_result block. All-or-nothing across the request (400 'Citations must be either enabled or disabled on all `document` blocks'). Adds system-prompt tokens; cited_text is not billed as output nor as input when replayed.", default=False, status=LV, source="cite", verification=V(note="cite_01..05; cite_06 mixed -> 400")),137    P("messages[].content[] {type:'document'}", "object (DocumentBlockParam)", "Document block. source variants: base64 (application/pdf), text (text/plain), content (custom content: array of text/image blocks), url, file (file_id). Optional title, context, citations, cache_control.", status=LV, source="pdf", verification=V()),138    P("messages[].content[].source.type (document)", "string", "Document source discriminator.", enum=["base64", "text", "content", "url", "file"], status=LV, source="cite", verification=V(note="base64 PDF, text, content, file verified; url documented")),139    P("messages[].content[].source.media_type (document)", "string", "application/pdf for base64; text/plain for text sources. Files API: PDF or text/plain files only in document blocks.", enum=["application/pdf", "text/plain"], status=LV, source="pdf", verification=V()),140    P("messages[].content[].title (document)", "string | null", "Passed to the model, echoed as document_title in citations, not citable. Limited length (use context for metadata).", status=LV, source="cite", verification=V()),141    P("messages[].content[].context (document)", "string | null", "Free-text metadata shown to the model, not citable.", source="cite"),142    P("messages[].content[] {type:'search_result'}", "object (SearchResultBlockParam)", "RAG result block: source (string), title (string), content (array of non-empty text blocks), citations, cache_control. User messages and tool_result only (all-or-nothing inside a tool_result). Cited as search_result_location with block indices.", status=LV, source="search", verification=V(note="cite_02 search_result_index 0 start_block_index 1 end_block_index 2")),143    P("messages[].content[] {type:'image'}", "object (ImageBlockParam)", "Image block. source: base64 (media_type image/jpeg|png|gif|webp), url, file (file_id). Limits: 8000x8000 px, 10 MB base64 (5 MB Bedrock/Vertex), 100 images/request on 200k models, 600 on 1M models; >20 images => per-image ~2000 px limit. Cost = ceil(w/28)*ceil(h/28) visual tokens, capped by tier (1568 std, 4784 on 4.7+). Invalid bytes -> 400 'Could not process image'; unreachable URL -> 400 'Unable to download the file'.", status=LV, source="vision", verification=V(note="vision_01 1x1 PNG -> 'Red', input_tokens 21; vision_07 httpbin URL -> 200; wikimedia URL -> 400")),144    P("messages[].content[].source.type (image)", "string", "Image source discriminator.", enum=["base64", "url", "file"], status=LV, source="vision", verification=V()),145    P("messages[].content[].source.media_type (image)", "string", "Image MIME type (base64 sources). Animations: first frame only.", enum=["image/jpeg", "image/png", "image/gif", "image/webp"], status=LV, source="vision", verification=V()),146    P("messages[].content[].transformations.oversized_image", "string", "Image block option: downsize (default) or error (400 naming dimensions if the image would be resized).", enum=["downsize", "error"], default="downsize", status=LV, source="coords", verification=V(note="vision_06 transformations accepted on 1x1 image")),147    P("messages[].content[] {type:'container_upload'}", "object", "Reference a Files API file inside the code execution container: {type:'container_upload', file_id}.", status=["DOCUMENTED"], source="files"),148    # ---- files api ----149    P("file", "binary (multipart part)", "File to upload. filename final path component kept; Content-Type on the part optional (detected: an application/octet-stream .txt part was stored as text/plain). Max 500 MB; 1 TB per org (guide) — reference says 100 GB in older text.", endpoint="POST /v1/files", location="body", required=True, status=LV, source="filesapi", verification=V(note="files_01 size_bytes 101 text/plain downloadable false expires_at null")),150    P("expires_in_seconds", "integer", "Seconds until the file expires (3600..7776000). 400 'expires_in_seconds: must be between 3600 and 7776000' otherwise. expires_at = upload time + value.", endpoint="POST /v1/files", location="body", minimum=3600, maximum=7776000, status=LV, source="filesapi", verification=V(note="files_09 3600 -> expires_at +1h; files_14 60 -> 400")),151    P("limit", "integer", "Page size, default 20, 1..1000.", endpoint="GET /v1/files", location="query", default=20, minimum=1, maximum=1000, status=LV, source="filesapi", verification=V()),152    P("page", "string", "Opaque cursor (prefixed page_) from next_page.", endpoint="GET /v1/files", location="query", status=["DOCUMENTED"], source="filesapi"),153    P("ids[]", "array of string", "Up to 100 ids; single page; unknown ids silently omitted; exclusive with page/limit.", endpoint="GET /v1/files", location="query", maximum=100, status=LV, source="filesapi", verification=V(note="files_04")),154    P("before_id / after_id", "string", "Legacy cursors, only with anthropic-beta: files-api-2025-04-14 (response then has has_more/first_id/last_id instead of next_page). 400 without the header.", endpoint="GET /v1/files", location="query", beta="files-api-2025-04-14", status=["DOCUMENTED", "LEGACY", "LIVE_VERIFIED"], source="files", verification=V(note="files_03 legacy header -> {data, has_more, first_id, last_id}, no expires_at")),155    P("anthropic-workspace-id", "string", "Optional header selecting the workspace (files are workspace-scoped).", endpoint="POST /v1/files", location="header", status=["DOCUMENTED"], source="filesapi"),156    P("file_id", "string", "Path parameter for GET/DELETE /v1/files/{file_id} and GET /v1/files/{file_id}/content.", endpoint="GET /v1/files/{file_id}", location="path", required=True, status=LV, source="filesapi", verification=V()),157    P("messages[].content[].source.file_id", "string", "Files API reference inside image/document blocks (GA, no header). Wrong block type -> 400 'PDF files cannot be used in image blocks. Use a document block instead.' Citations from file documents carry file_id and document_title null.", status=LV, source="files", verification=V(note="files_07/10/13; files_11 -> 400")),158]159160(F / "parameters").mkdir(parents=True, exist_ok=True)161(F / "parameters" / "anthropic-advanced.json").write_text(json.dumps({"domain": "anthropic-advanced", "generated_at": VER, "records": params}, indent=1, ensure_ascii=False))162163# ---------------- endpoints: Files API ----------------164def E(method, path, name, desc, **kw):165    e = {"provider": "anthropic", "api_family": "files", "method": method, "path": path, "name": name, "description": desc,166         "status": kw.get("status", LV), "auth": "x-api-key + anthropic-version", "beta_header": kw.get("beta"),167         "request": kw.get("request", {"content_type": "application/json", "body_ref": None}),168         "response": kw.get("response", {}), "streaming": {"supported": False, "events_ref": None},169         "pagination": kw.get("pagination"), "idempotency": kw.get("idempotency", "n/a"),170         "sdk": kw.get("sdk"), "verification": kw.get("verification"), "notes": kw.get("notes"), "sources": src("filesapi", "files"), "last_verified": VER}171    return e172173endpoints = [174    E("POST", "/v1/files", "Upload File", "Upload a file (multipart/form-data: file, expires_in_seconds). Returns FileMetadata with downloadable:false and expires_at. GA since 2026-08-19 (files-api-2025-04-14 header optional, returns legacy shape). Free; ~500 req/min.",175      request={"content_type": "multipart/form-data", "body_ref": "file, expires_in_seconds"}, response={"200": "FileMetadata", "400": "invalid file type / filename / storage limit / expires_in_seconds range", "413": "file too large (>500 MB)"},176      sdk={"python": "client.files.upload(file=...)", "node": "client.files.upload({file})"}, verification=V(note="files_01/09/12/17 -> 200")),177    E("GET", "/v1/files", "List Files", "List workspace files newest first. Query: limit (20, max 1000), page cursor, ids[] (<=100). Response {data, next_page}. Legacy header adds has_more/first_id/last_id and before_id/after_id cursors.",178      request={"content_type": None, "body_ref": None}, response={"200": "{data: FileMetadata[], next_page: string|null}"}, pagination={"style": "cursor", "param": "page", "cursor_field": "next_page", "legacy": "before_id/after_id + has_more with files-api-2025-04-14"},179      sdk={"python": "client.files.list(limit=…) (auto-pagination)", "node": "client.files.list()"}, verification=V(note="files_02 {data:[…], next_page:null}; files_03 legacy shape; files_04 ids[] filter")),180    E("GET", "/v1/files/{file_id}", "Get File Metadata", "Retrieve FileMetadata. After deletion -> 404 'File `…` not found.' Expired files stay readable (metadata) up to 30 days.",181      request={"content_type": None, "body_ref": None}, response={"200": "FileMetadata", "404": "not found"}, sdk={"python": "client.files.retrieve_metadata(file_id)", "node": "client.files.retrieveMetadata(fileId)"}, verification=V(note="files_05 -> 200; files_16 after delete -> 404")),182    E("GET", "/v1/files/{file_id}/content", "Download File", "Download file bytes. Only files created by skills / code execution (downloadable:true). Uploaded files -> 400 'File `…` is not downloadable. Only files generated by a tool (for example, the code execution tool) can be downloaded.' Expired -> 404. Generated media carries C2PA credentials.",183      request={"content_type": None, "body_ref": None}, response={"200": "binary", "400": "not downloadable", "404": "expired/not found"}, sdk={"python": "client.files.download(file_id)", "node": "client.files.download(fileId)"},184      status=["DOCUMENTED", "LIVE_VERIFIED"], verification=V(result="failure", http=400, note="files_06 on an uploaded file -> 400 (documented behaviour)")),185    E("DELETE", "/v1/files/{file_id}", "Delete File", "Delete a file. Returns {id, type:'file_deleted'}. Irreversible; may persist briefly in in-flight Messages calls.",186      request={"content_type": None, "body_ref": None}, response={"200": "DeletedFile {id, type:'file_deleted'}", "404": "not found"}, sdk={"python": "client.files.delete(file_id)", "node": "client.files.delete(fileId)"}, verification=V(note="files_15_delete_* -> 200")),187]188(F / "endpoints").mkdir(parents=True, exist_ok=True)189(F / "endpoints" / "anthropic-files.json").write_text(json.dumps({"domain": "anthropic-advanced", "generated_at": VER, "records": endpoints}, indent=1, ensure_ascii=False))190191# ---------------- objects ----------------192def O(name, kind, desc, schema, *, sdk=None, status=None, source="msgs", example=None, verification=None, notes=None):193    return {"provider": "anthropic", "name": name, "kind": kind, "description": desc, "schema": schema, "sdk_types": sdk or {},194            "status": status or ["DOCUMENTED"], "example": example, "notes": notes, "verification": verification, "sources": src(source), "last_verified": VER}195196objects = [197    O("thinking (content block)", "content_block", "Reasoning block preceding text; thinking text is a summary (or '' when display omitted); signature = encrypted full reasoning, opaque, must be passed back unchanged with tool results.",198      {"type": "thinking", "thinking": "string (summary or empty)", "signature": "string (opaque, long on Claude 4+)"}, sdk={"python": "ThinkingBlock / ThinkingBlockParam / BetaThinkingBlock", "node": "ThinkingBlock"}, status=LV, source="thinking",199      example={"type": "thinking", "thinking": "The user is asking for 2+2, which equals 4…", "signature": "EtQCCpoBCBEYAipAGx2p…"}, verification=V(note="think_01 on Haiku")),200    O("redacted_thinking (content block)", "content_block", "Safety-redacted reasoning: encrypted data, no text. Must be round-tripped unchanged; filtering by type=='thinking' alone breaks tool-use turns.",201      {"type": "redacted_thinking", "data": "string (opaque)"}, sdk={"python": "RedactedThinkingBlock / RedactedThinkingBlockParam", "node": "RedactedThinkingBlock"}, source="thinking"),202    O("ThinkingConfig (request)", "request_object", "thinking parameter variants.",203      {"oneOf": [{"type": "enabled", "budget_tokens": "int >= 1024, < max_tokens", "display": "summarized|omitted|updates(beta)", "block_binding": "beta"},204                 {"type": "adaptive", "display": "summarized|omitted|updates(beta)", "block_binding": "beta"}, {"type": "disabled"}]},205      sdk={"python": "ThinkingConfigEnabled / ThinkingConfigAdaptive / ThinkingConfigDisabled (+Beta*)", "node": "ThinkingConfigParam"}, status=LV, source="thinking", verification=V()),206    O("compaction (content block)", "content_block", "Server-written summary replacing earlier context. Threshold compaction: content string (null if the summarizer called a tool), appears at the start of the assistant response. On-demand (compact-2026-09-04): signed block with signature, returned alone with stop_reason 'compaction'; must be sent first in messages on later requests. encrypted_content is opaque round-trip metadata. cache_control allowed.",207      {"type": "compaction", "content": "string | null", "signature": "string (on-demand beta)", "encrypted_content": "string | null", "cache_control": "CacheControlEphemeral?"},208      sdk={"python": "BetaCompactionBlock / BetaCompactionBlockParam", "node": "BetaCompactionBlock"}, status=LVB, source="compact",209      example={"type": "compaction", "content": "Ada introduced herself and shared that she likes the color teal…", "signature": "CAISzAMKHggRGALyARdjb21wYWN0aW9uX3NpZ25hdHVyZV92MRIM…"}, verification=V(note="compact_04 on Sonnet 5")),210    O("CompactionConfig (request)", "request_object", "Top-level compaction parameter (compact-2026-09-04).", {"type": "summarize", "instructions": "string <= 16384 | null"}, sdk={"python": "BetaCompactionConfig"}, status=LVB, source="compact", verification=V()),211    O("ContextManagementConfig (request)", "request_object", "context_management.edits strategies.",212      {"edits": [{"type": "clear_tool_uses_20250919", "trigger": {"type": "input_tokens|tool_uses", "value": "int>=1"}, "keep": {"type": "tool_uses", "value": "int>=0"}, "clear_at_least": {"type": "input_tokens", "value": "int>=0"}, "exclude_tools": ["string"], "clear_tool_inputs": "bool | string[]"},213                {"type": "clear_thinking_20251015", "keep": "{type:'thinking_turns', value>=1} | {type:'all'} | 'all'"},214                {"type": "compact_20260112", "trigger": {"type": "input_tokens", "value": "int>=50000"}, "pause_after_compaction": "bool", "instructions": "string|null"}]},215      sdk={"python": "BetaContextManagementConfig, BetaClearToolUses20250919Edit, BetaClearThinking20251015Edit, BetaCompact20260112Edit, BetaInputTokensTrigger, BetaToolUsesTrigger, BetaThinkingTurns", "node": "same names"}, status=LVB, source="ctxedit", verification=V()),216    O("context_management (response)", "response_field", "Edits applied during the request (also in the final message_delta when streaming, and in count_tokens as {original_input_tokens}).",217      {"applied_edits": [{"type": "clear_tool_uses_20250919", "cleared_tool_uses": "int", "cleared_input_tokens": "int"}, {"type": "clear_thinking_20251015", "cleared_thinking_turns": "int", "cleared_input_tokens": "int"}]},218      sdk={"python": "BetaContextManagementResponse, BetaClearToolUses20250919EditResponse, BetaClearThinking20251015EditResponse"}, status=LVB, source="ctxedit",219      example={"applied_edits": [{"type": "clear_tool_uses_20250919", "cleared_input_tokens": 174, "cleared_tool_uses": 2}]}, verification=V(note="ctxedit_01; count_tokens -> input_tokens 838, context_management.original_input_tokens 928")),220    O("input_transformations (response)", "response_field", "Beta thinking-binding-controls-2026-08-01: list of thinking blocks the API dropped or tolerated. [] when nothing happened. Streaming: on message_start (and message_delta after a mid-stream fallback).",221      {"input_transformations": [{"type": "thinking_dropped | thinking_mismatch_allowed", "path": "messages.1.content.0", "reason": "prefix_binding_mismatch | model_binding_mismatch"}]},222      sdk={"python": "BetaInputTransformation"}, status=LVB, source="preserved", example={"input_transformations": []}, verification=V(note="adaptive_07 on Sonnet 5 -> []")),223    O("usage (cache & thinking fields)", "response_field", "Token accounting. input_tokens = tokens after the last cache breakpoint only; total input = input + cache_read + cache_creation. cache_creation_input_tokens == sum of cache_creation.*. output_tokens_details.thinking_tokens = billed reasoning tokens (final message_delta when streaming). speed present when the fast-mode beta is active. iterations present with compaction/task-budget betas (sum for billing; compaction entries are excluded from top-level counts). inference_geo ('global' | 'not_available' | region) observed but not documented on these pages.",224      {"input_tokens": "int", "cache_creation_input_tokens": "int|null", "cache_read_input_tokens": "int|null", "cache_creation": {"ephemeral_5m_input_tokens": "int", "ephemeral_1h_input_tokens": "int"},225       "output_tokens": "int", "output_tokens_details": {"thinking_tokens": "int"}, "server_tool_use": {"web_search_requests": "int"}, "service_tier": "standard|priority|batch", "speed": "standard|fast (beta)",226       "iterations": [{"type": "message|compaction", "input_tokens": "int", "output_tokens": "int", "cache_read_input_tokens": "int", "cache_creation_input_tokens": "int", "cache_creation": {}}], "inference_geo": "string (observed)"},227      sdk={"python": "Usage, CacheCreation, OutputTokensDetails, BetaUsage, BetaCompactionIterationUsage", "node": "Usage"}, status=["DOCUMENTED", "LIVE_VERIFIED", "LIVE_DISCOVERED"], source="cache",228      example={"input_tokens": 10, "cache_creation_input_tokens": 5809, "cache_read_input_tokens": 0, "cache_creation": {"ephemeral_5m_input_tokens": 5809, "ephemeral_1h_input_tokens": 0}, "output_tokens": 5, "service_tier": "standard", "inference_geo": "not_available"},229      verification=V(note="cache_01..08, think_01, compact_01/04, fast_04")),230    O("CacheControlEphemeral", "request_object", "Breakpoint marker.", {"type": "ephemeral", "ttl": "5m|1h (optional, default 5m)"}, sdk={"python": "CacheControlEphemeral / BetaCacheControlEphemeral"}, status=LV, source="cache", verification=V()),231    O("OutputConfig", "request_object", "output_config container.", {"effort": "low|medium|high|xhigh|max", "format": {"type": "json_schema", "schema": "object"}, "task_budget": {"type": "tokens", "total": "int", "remaining": "int?"}},232      sdk={"python": "OutputConfig, JSONOutputFormat, BetaOutputConfig, BetaJSONOutputFormat, BetaTokenTaskBudget", "node": "OutputConfig, JSONOutputFormat"}, status=LV, source="so", verification=V()),233    O("citation: char_location", "citation", "Plain-text document citation (0-indexed chars, exclusive end). From Files API text documents the citation also carries file_id and document_title null (undocumented field).",234      {"type": "char_location", "cited_text": "string (not billed)", "document_index": "int", "document_title": "string|null", "start_char_index": "int", "end_char_index": "int (exclusive)", "file_id": "string (observed with file sources)"},235      sdk={"python": "CitationCharLocation / CitationCharLocationParam"}, status=["DOCUMENTED", "LIVE_VERIFIED", "LIVE_DISCOVERED"], source="cite",236      example={"type": "char_location", "cited_text": "Grass is green.", "document_index": 0, "document_title": "Colors", "start_char_index": 17, "end_char_index": 32}, verification=V(note="cite_01; files_07 adds file_id")),237    O("citation: page_location", "citation", "PDF citation, 1-indexed pages, exclusive end.", {"type": "page_location", "cited_text": "string", "document_index": "int", "document_title": "string|null", "start_page_number": "int", "end_page_number": "int (exclusive)"},238      sdk={"python": "CitationPageLocation"}, status=LV, source="cite", example={"type": "page_location", "cited_text": "Grass is green.", "document_index": 0, "document_title": "Colors PDF", "start_page_number": 1, "end_page_number": 2}, verification=V(note="cite_04 1-page generated PDF")),239    O("citation: content_block_location", "citation", "Custom-content document citation, block indices 0-indexed exclusive end.", {"type": "content_block_location", "cited_text": "string", "document_index": "int", "document_title": "string|null", "start_block_index": "int", "end_block_index": "int"},240      sdk={"python": "CitationContentBlockLocation"}, status=LV, source="cite", example={"type": "content_block_location", "cited_text": "Grass is green.", "document_index": 0, "document_title": "Colors", "start_block_index": 1, "end_block_index": 2}, verification=V(note="cite_03")),241    O("citation: search_result_location", "citation", "Citation of a search_result block.", {"type": "search_result_location", "cited_text": "string", "source": "string", "title": "string|null", "search_result_index": "int", "start_block_index": "int", "end_block_index": "int"},242      sdk={"python": "CitationsSearchResultLocation / CitationSearchResultLocationParam"}, status=LV, source="search", example={"type": "search_result_location", "cited_text": "Grass is green.", "source": "kb://colors/1", "title": "Color facts", "search_result_index": 0, "start_block_index": 1, "end_block_index": 2}, verification=V(note="cite_02")),243    O("citation: web_search_result_location", "citation", "Citation of a web search tool result.", {"type": "web_search_result_location", "cited_text": "string", "url": "string", "title": "string|null", "encrypted_index": "string"}, sdk={"python": "CitationsWebSearchResultLocation"}, source="msgs"),244    O("CitationsConfig", "request_object", "citations field on document / search_result blocks.", {"enabled": "boolean"}, sdk={"python": "CitationsConfigParam"}, status=LV, source="cite", verification=V()),245    O("DocumentBlockParam", "content_block", "Document input block.", {"type": "document", "source": {"oneOf": [{"type": "base64", "media_type": "application/pdf", "data": "base64"}, {"type": "text", "media_type": "text/plain", "data": "string"}, {"type": "content", "content": "string | [text|image blocks]"}, {"type": "url", "url": "string"}, {"type": "file", "file_id": "string"}]}, "title": "string?", "context": "string?", "citations": {"enabled": "bool"}, "cache_control": "?"},246      sdk={"python": "DocumentBlockParam, Base64PDFSource, PlainTextSource, ContentBlockSource, URLPDFSource, FileDocumentSource"}, status=LV, source="pdf", verification=V()),247    O("ImageBlockParam", "content_block", "Image input block.", {"type": "image", "source": {"oneOf": [{"type": "base64", "media_type": "image/jpeg|image/png|image/gif|image/webp", "data": "base64"}, {"type": "url", "url": "string"}, {"type": "file", "file_id": "string"}]}, "transformations": {"oversized_image": "downsize|error"}, "cache_control": "?"},248      sdk={"python": "ImageBlockParam, Base64ImageSource, URLImageSource, FileImageSource"}, status=LV, source="vision", verification=V()),249    O("SearchResultBlockParam", "content_block", "RAG search result block.", {"type": "search_result", "source": "string", "title": "string", "content": [{"type": "text", "text": "non-empty"}], "citations": {"enabled": "bool"}, "cache_control": "?"}, sdk={"python": "SearchResultBlockParam"}, status=LV, source="search", verification=V()),250    O("FileMetadata", "object", "Files API object. downloadable false for uploads; expires_at null unless expires_in_seconds given (absent under the legacy beta header).",251      {"type": "file", "id": "file_…", "created_at": "RFC3339", "filename": "string 1..500", "mime_type": "string", "size_bytes": "int", "downloadable": "bool", "expires_at": "RFC3339|null"},252      sdk={"python": "FileMetadata / BetaFileMetadata", "node": "FileMetadata"}, status=LV, source="filesapi",253      example={"type": "file", "id": "file_01EfVkMNzn7Yw7nQk38Rz6H2", "size_bytes": 607, "created_at": "2026-09-19T01:50:34.679190Z", "expires_at": "2026-09-19T02:50:34.679190Z", "filename": "atlas.pdf", "mime_type": "application/pdf", "downloadable": False}, verification=V(note="files_09")),254    O("DeletedFile", "object", "DELETE response.", {"id": "string", "type": "file_deleted"}, sdk={"python": "DeletedFile"}, status=LV, source="filesapi", example={"id": "file_01TqegiQ7gLB7VNsPZaqHczC", "type": "file_deleted"}, verification=V()),255    O("FileList", "object", "GET /v1/files response.", {"data": ["FileMetadata"], "next_page": "string|null", "(legacy header)": {"has_more": "bool", "first_id": "string", "last_id": "string"}}, status=LV, source="filesapi", verification=V()),256    O("tool_use.caller (response)", "response_field", "Observed on tool_use blocks: caller {type:'direct'} (direct call vs code_execution_20250825 / code_execution_20260120 programmatic callers per the reference).", {"caller": {"type": "direct | code_execution_20250825 | code_execution_20260120"}}, status=["DOCUMENTED", "LIVE_VERIFIED"], source="msgs", example={"caller": {"type": "direct"}}, verification=V(note="so_08")),257    O("diagnostics (response)", "response_field", "Cache diagnostics beta: null when there is nothing to compare; otherwise cache_miss_reason etc.", {"diagnostics": "object | null"}, status=LVB, source="cachediag", verification=V(note="cache_12 -> null on first turn")),258]259(F / "objects").mkdir(parents=True, exist_ok=True)260(F / "objects" / "anthropic-advanced-objects.json").write_text(json.dumps({"domain": "anthropic-advanced", "generated_at": VER, "records": objects}, indent=1, ensure_ascii=False))261262# ---------------- compatibility matrix ----------------263MODELS = {264    "claude-fable-5-1": {"ctx": 1_000_000, "max_out": 128000, "cache_min": 512, "thinking": "adaptive-always-on", "display_default": "omitted", "keep_thinking": "all", "sampling": "fixed"},265    "claude-mythos-5-1": {"ctx": 1_000_000, "max_out": 128000, "cache_min": 512, "thinking": "adaptive-always-on", "display_default": "omitted", "keep_thinking": "all", "sampling": "fixed", "availability": "limited (Glasswing)"},266    "claude-opus-5": {"ctx": 1_000_000, "max_out": 128000, "cache_min": 512, "thinking": "adaptive-default-on", "display_default": "omitted", "keep_thinking": "all", "sampling": "fixed"},267    "claude-sonnet-5": {"ctx": 1_000_000, "max_out": 128000, "cache_min": 1024, "thinking": "adaptive-default-on", "display_default": "omitted", "keep_thinking": "all", "sampling": "fixed"},268    "claude-fable-5": {"ctx": 1_000_000, "max_out": 128000, "cache_min": 512, "thinking": "adaptive-always-on", "display_default": "omitted", "keep_thinking": "all", "sampling": "fixed"},269    "claude-mythos-5": {"ctx": 1_000_000, "max_out": 128000, "cache_min": 512, "thinking": "adaptive-always-on", "display_default": "omitted", "keep_thinking": "all", "sampling": "fixed", "availability": "limited (Glasswing)"},270    "claude-opus-4-8": {"ctx": 1_000_000, "max_out": 128000, "cache_min": 1024, "thinking": "adaptive-default-off", "display_default": "omitted", "keep_thinking": "all", "sampling": "fixed"},271    "claude-opus-4-7": {"ctx": 1_000_000, "max_out": 128000, "cache_min": 2048, "thinking": "adaptive-default-off", "display_default": "omitted", "keep_thinking": "all", "sampling": "fixed"},272    "claude-sonnet-4-6": {"ctx": 1_000_000, "max_out": 128000, "cache_min": 1024, "thinking": "adaptive|extended(deprecated)-default-off", "display_default": "summarized", "keep_thinking": "all", "sampling": "restricted-with-thinking"},273    "claude-opus-4-6": {"ctx": 1_000_000, "max_out": 128000, "cache_min": 4096, "thinking": "adaptive|extended(deprecated)-default-off", "display_default": "summarized", "keep_thinking": "all", "sampling": "restricted-with-thinking"},274    "claude-opus-4-5-20251101": {"ctx": 200_000, "max_out": 64000, "cache_min": 4096, "thinking": "extended-only", "display_default": "summarized", "keep_thinking": "all", "sampling": "restricted-with-thinking"},275    "claude-haiku-4-5-20251001": {"ctx": 200_000, "max_out": 64000, "cache_min": 4096, "thinking": "extended-only", "display_default": "summarized", "keep_thinking": "last-turn", "sampling": "restricted-with-thinking"},276    "claude-sonnet-4-5-20250929": {"ctx": 200_000, "max_out": 64000, "cache_min": 1024, "thinking": "extended-only", "display_default": "summarized", "keep_thinking": "last-turn", "sampling": "restricted-with-thinking"},277}278def feat(m):279    d = MODELS[m]280    adaptive = m in ADAPTIVE or m.startswith("claude-mythos")281    enabled = m in ENABLED282    fable = m.startswith(("claude-fable", "claude-mythos"))283    live = {"claude-haiku-4-5-20251001": "Haiku", "claude-sonnet-5": "Sonnet5", "claude-sonnet-4-6": "Sonnet46", "claude-opus-5": "Opus5"}.get(m)284    return {285        "provider": "anthropic", "model": m, "context_window": d["ctx"], "max_output_tokens": d["max_out"], "availability": d.get("availability", "general"),286        "prompt_caching": {"supported": True, "min_cacheable_tokens": d["cache_min"], "ttl_1h": True, "automatic_top_level_cache_control": True, "beta_header": None,287                            "cache_read_multiplier": 0.025 if m in ("claude-fable-5-1", "claude-mythos-5-1") else 0.1,288                            "status": LV if live == "Haiku" else ["DOCUMENTED"], "live_note": "Haiku: 5809-token system cached (write 5809 / read 5809 / 1h write 5809); 750 tokens not cached" if live == "Haiku" else None},289        "extended_thinking_enabled": {"supported": enabled or m.startswith("claude-mythos-preview"), "deprecated": m in ("claude-sonnet-4-6", "claude-opus-4-6"), "rejected_400": not enabled, "budget_tokens_min": 1024 if enabled else None,290                                       "status": LV if live in ("Haiku", "Sonnet46", "Sonnet5") else ["DOCUMENTED"]},291        "adaptive_thinking": {"supported": adaptive, "default": d["thinking"], "can_disable": (not fable) and adaptive, "disable_restriction": "400 with effort xhigh/max" if m == "claude-opus-5" else None,292                              "status": LV if live in ("Sonnet5", "Haiku") else ["DOCUMENTED"]},293        "interleaved_thinking": {"supported": m != "claude-haiku-4-5-20251001", "mode": "automatic (adaptive)" if adaptive else ("beta header interleaved-thinking-2025-05-14" if m != "claude-haiku-4-5-20251001" else "not supported (header accepted, ignored)"),294                                 "beta_header": None if adaptive else "interleaved-thinking-2025-05-14", "note": "Opus 4.6 manual mode does not interleave; Sonnet 4.6 manual+header deprecated" if m in ("claude-opus-4-6", "claude-sonnet-4-6") else None},295        "thinking_display_default": d["display_default"], "thinking_display_updates_beta": fable and "5-1" in m or m == "claude-fable-5",296        "prior_thinking_blocks_kept": d["keep_thinking"],297        "effort": {"supported": m in EFFORT or m.startswith("claude-mythos"), "levels": (["low", "medium", "high", "xhigh", "max"] if (m in XHIGH or m.startswith("claude-mythos")) else (["low", "medium", "high", "max"] if m in MAX else (["low", "medium", "high"] if m in EFFORT else []))),298                   "default": "high" if (m in EFFORT or m.startswith("claude-mythos")) else None, "per_message_effort_beta": m in PER_MSG_EFFORT or m == "claude-mythos-5-1", "beta_header": None,299                   "status": LV if live in ("Sonnet5", "Haiku") else ["DOCUMENTED"]},300        "task_budgets": {"supported": m in TASKB or m.startswith("claude-mythos-5"), "beta_header": "task-budgets-2026-03-13", "min_total": 20000, "live_note": "Sonnet 5 accepted the parameter (documented as unsupported)" if live == "Sonnet5" else None},301        "fast_mode": {"supported": m in FAST, "beta_header": "fast-mode-2026-02-01", "pricing_usd_per_mtok": {"input": 10, "output": 50} if m in FAST else None,302                       "status": ["DOCUMENTED", "PREVIEW", "ACCOUNT_RESTRICTED"] if m == "claude-opus-5" else (["DOCUMENTED", "PREVIEW"] if m in FAST else ["DOCUMENTED"]),303                       "note": "Opus 4.6: speed fast silently runs standard; Opus 4.7: error; others: 400 does not support the `speed` parameter"},304        "context_1m": {"supported": d["ctx"] == 1_000_000, "beta_header": None, "note": "default, standard pricing" if d["ctx"] == 1_000_000 else "200k; context-1m-2025-08-07 has no effect"},305        "context_editing": {"clear_tool_uses_20250919": True, "clear_thinking_20251015": True, "compact_20260112": m in COMPACT or m.startswith("claude-mythos"), "beta_headers": {"clear_*": "context-management-2025-06-27", "compact_20260112": "compact-2026-01-12", "on_demand_compaction": "compact-2026-09-04" if (m in COMPACT or m.startswith("claude-mythos")) else None},306                            "status": LV if live in ("Haiku", "Sonnet5") else ["DOCUMENTED"]},307        "structured_outputs": {"json_outputs": True, "strict_tools": True, "beta_header": None, "status": LV if live == "Haiku" else ["DOCUMENTED"]},308        "citations": {"supported": True, "types": ["char_location", "page_location", "content_block_location", "search_result_location", "web_search_result_location"], "status": LV if live == "Haiku" else ["DOCUMENTED"]},309        "pdf": {"supported": True, "max_pages_per_request": 600 if d["ctx"] == 1_000_000 else 100, "max_request_mb": 32, "status": LV if live == "Haiku" else ["DOCUMENTED"]},310        "vision": {"supported": True, "tier": "high-resolution (2576 px / 4784 tokens)" if m in ("claude-fable-5-1", "claude-mythos-5-1", "claude-opus-5", "claude-sonnet-5", "claude-fable-5", "claude-mythos-5", "claude-opus-4-8", "claude-opus-4-7") else "standard (1568 px / 1568 tokens)",311                   "max_images_per_request": 600 if d["ctx"] == 1_000_000 else 100, "status": LV if live == "Haiku" else ["DOCUMENTED"]},312        "files_api": {"supported": True, "beta_header": None, "status": LV if live == "Haiku" else ["DOCUMENTED"]},313        "sampling_params": d["sampling"], "context_awareness_injected": m in ("claude-sonnet-5", "claude-sonnet-4-6", "claude-sonnet-4-5-20250929", "claude-haiku-4-5-20251001"),314        "sources": src("models", "cache", "trouble", "effort", "fast", "ctxwin", "compact", "so", "cite", "vision", "files"), "last_verified": VER,315    }316matrix = [feat(m) for m in MODELS]317(F / "compatibility").mkdir(parents=True, exist_ok=True)318(F / "compatibility" / "anthropic-feature-model-matrix.json").write_text(json.dumps({"domain": "anthropic-advanced", "generated_at": VER, "models_api_capabilities_source": "sources/anthropic/models-api-raw.json (capabilities.thinking/effort/context_management/structured_outputs/citations/pdf_input)", "records": matrix}, indent=1, ensure_ascii=False))319320# ---------------- streaming events ----------------321def SE(event, desc, schema, example=None, status=None, source="thinking", verification=None):322    return {"provider": "anthropic", "api": "messages", "direction": "server→client", "event": event, "description": desc, "schema": schema, "example": example,323            "status": status or ["DOCUMENTED"], "verification": verification, "source": S[source], "last_verified": VER}324events = [325    SE("content_block_start (thinking)", "Opens a thinking block (index i). With display omitted the block starts and only deltas with empty thinking follow.", {"type": "content_block_start", "index": "int", "content_block": {"type": "thinking", "thinking": "", "signature": ""}},326       example={"type": "content_block_start", "index": 0, "content_block": {"type": "thinking", "thinking": "", "signature": ""}}, status=LV, verification=V(note="think_02_enabled_stream")),327    SE("content_block_delta: thinking_delta", "Incremental summarized thinking text (empty string under display omitted; progress-update text under display updates).", {"type": "content_block_delta", "index": "int", "delta": {"type": "thinking_delta", "thinking": "string"}},328       example={"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": "The user is asking"}}, status=LV, verification=V(note="10 thinking_delta events observed on Haiku")),329    SE("content_block_delta: signature_delta", "Single event carrying the encrypted signature, sent just before the thinking block's content_block_stop.", {"type": "content_block_delta", "index": "int", "delta": {"type": "signature_delta", "signature": "string"}},330       example={"type": "content_block_delta", "index": 0, "delta": {"type": "signature_delta", "signature": "EuUCCpoBCBEYAipABXfZ…"}}, status=LV, verification=V()),331    SE("content_block_start (redacted_thinking)", "Safety-redacted thinking block; data arrives complete in content_block_start (no readable deltas).", {"type": "content_block_start", "index": "int", "content_block": {"type": "redacted_thinking", "data": "string"}}),332    SE("content_block_delta: citations_delta", "One citation to append to the current text block's citations list.", {"type": "content_block_delta", "index": "int", "delta": {"type": "citations_delta", "citation": "char_location | page_location | content_block_location | search_result_location | web_search_result_location"}},333       example={"type": "content_block_delta", "index": 0, "delta": {"type": "citations_delta", "citation": {"type": "char_location", "cited_text": "Grass is green.", "document_index": 0, "document_title": "Colors", "start_char_index": 17, "end_char_index": 32}}}, status=LV, source="cite", verification=V(note="cite_05_stream_citations_delta")),334    SE("content_block_start/delta/stop (compaction, threshold)", "Threshold compaction block streams as content_block_start, then ONE content_block_delta carrying the whole summary, then content_block_stop.", {"content_block_start": {"content_block": {"type": "compaction"}}, "content_block_delta": {"delta": {"type": "compaction_delta (BetaCompactionContentBlockDelta)", "content": "full summary"}}, "content_block_stop": {}}, source="compact", status=["DOCUMENTED", "BETA"]),335    SE("content_block_start (compaction, on-demand)", "With compact-2026-09-04 the signed block arrives whole in content_block_start followed by content_block_stop; no deltas; ping events may interleave.", {"type": "content_block_start", "content_block": {"type": "compaction", "content": "string", "signature": "string"}}, source="compact", status=["DOCUMENTED", "BETA"]),336    SE("message_delta (usage.output_tokens_details / context_management)", "Final message_delta carries output_tokens_details.thinking_tokens, and context_management.applied_edits when context editing ran; input_transformations only after a mid-stream fallback.", {"type": "message_delta", "delta": {"stop_reason": "end_turn|max_tokens|compaction|model_context_window_exceeded|…", "stop_sequence": None, "stop_details": None, "container": None}, "usage": {"input_tokens": "int", "cache_creation_input_tokens": "int", "cache_read_input_tokens": "int", "output_tokens": "int", "output_tokens_details": {"thinking_tokens": "int"}}, "context_management": {"applied_edits": []}},337       example={"type": "message_delta", "delta": {"stop_reason": "end_turn", "stop_sequence": None, "stop_details": None, "container": None}, "usage": {"input_tokens": 48, "cache_creation_input_tokens": 0, "cache_read_input_tokens": 0, "output_tokens": 40, "output_tokens_details": {"thinking_tokens": 33}}}, status=LV, verification=V()),338    SE("message_start (usage cache fields / input_transformations)", "message_start.message.usage carries cache_creation_input_tokens, cache_read_input_tokens and cache_creation.{ephemeral_5m,1h}_input_tokens; under thinking-binding-controls the message carries input_transformations.", {"type": "message_start", "message": {"usage": {"cache_creation_input_tokens": "int", "cache_read_input_tokens": "int", "cache_creation": {}}, "input_transformations": "[] (beta)"}}, status=LV, source="cache", verification=V()),339    SE("content_block_delta: text_delta (structured outputs)", "JSON outputs stream as ordinary text_delta chunks of the JSON string; accumulate before parsing.", {"type": "content_block_delta", "delta": {"type": "text_delta", "text": "{\"name\":\""}}, example={"type": "content_block_delta", "index": 0, "delta": {"type": "text_delta", "text": "{\""}}, status=LV, source="so", verification=V(note="so_02_json_schema_stream")),340]341(F / "streaming-events").mkdir(parents=True, exist_ok=True)342(F / "streaming-events" / "anthropic-advanced.json").write_text(json.dumps({"domain": "anthropic-advanced", "generated_at": VER, "records": events}, indent=1, ensure_ascii=False))343print("params", len(params), "endpoints", len(endpoints), "objects", len(objects), "matrix", len(matrix), "events", len(events))344