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%
23.3 KB · 703 lines json
Raw Blame History
1[2  {3    "provider": "anthropic",4    "object": "Message",5    "kind": "response",6    "description": "Response of POST /v1/messages (and message_start payload).",7    "fields": {8      "id": "string (msg_…)",9      "type": "'message'",10      "role": "'assistant'",11      "model": "string (resolved id)",12      "content": "ContentBlock[]",13      "stop_reason": "StopReason|null (null only in message_start)",14      "stop_sequence": "string|null",15      "stop_details": "RefusalStopDetails|null (null unless refusal)",16      "container": "Container|null {id, expires_at, skills[]}",17      "usage": "Usage",18      "context_management (beta)": "{applied_edits: []}",19      "diagnostics (beta)": "cache-miss reasons",20      "input_transformations (beta)": "thinking_dropped|thinking_mismatch_allowed[]"21    },22    "status": [23      "DOCUMENTED",24      "LIVE_VERIFIED"25    ],26    "example": {27      "model": "claude-haiku-4-5-20251001",28      "id": "msg_011CfBxdcZj7KMHsf2wSPauQ",29      "type": "message",30      "role": "assistant",31      "content": [32        {33          "type": "text",34          "text": "OK."35        }36      ],37      "container": null,38      "stop_reason": "end_turn",39      "stop_sequence": null,40      "stop_details": null,41      "usage": {42        "input_tokens": 11,43        "cache_creation_input_tokens": 0,44        "cache_read_input_tokens": 0,45        "cache_creation": {46          "ephemeral_5m_input_tokens": 0,47          "ephemeral_1h_input_tokens": 048        },49        "output_tokens": 5,50        "service_tier": "standard",51        "inference_geo": "not_available"52      }53    },54    "source": "https://platform.claude.com/docs/en/api/messages"55  },56  {57    "provider": "anthropic",58    "object": "Usage",59    "kind": "response",60    "description": "Billing/rate-limit usage. Total input = input_tokens + cache_creation_input_tokens + cache_read_input_tokens. output_tokens is non-zero even for empty text (except max_tokens=0 pre-warm: 0).",61    "fields": {62      "input_tokens": "int",63      "output_tokens": "int",64      "cache_creation_input_tokens": "int|null",65      "cache_read_input_tokens": "int|null",66      "cache_creation": "{ephemeral_5m_input_tokens, ephemeral_1h_input_tokens}|null",67      "output_tokens_details": "{thinking_tokens}|null (present when thinking ran)",68      "server_tool_use": "{web_search_requests, web_fetch_requests}|null",69      "service_tier": "'standard'|'priority'|'batch'|null",70      "inference_geo": "string|null — live value 'not_available' on Haiku 4.5 (value not enumerated in docs)",71      "iterations (beta)": "per-iteration usage entries type message|compaction|advisor_message|fallback_message",72      "speed (beta)": "'standard'|'fast'|null",73      "fallback_credit (beta)": "{token, status}"74    },75    "status": [76      "DOCUMENTED",77      "LIVE_VERIFIED"78    ],79    "example": null,80    "source": "https://platform.claude.com/docs/en/api/messages"81  },82  {83    "provider": "anthropic",84    "object": "MessageDeltaUsage",85    "kind": "streaming",86    "description": "Cumulative usage in message_delta.",87    "fields": {88      "input_tokens": "int|null",89      "output_tokens": "int",90      "cache_creation_input_tokens": "int|null",91      "cache_read_input_tokens": "int|null",92      "output_tokens_details": "{thinking_tokens}|null",93      "server_tool_use": "ServerToolUsage|null"94    },95    "status": [96      "DOCUMENTED",97      "LIVE_VERIFIED"98    ],99    "example": null,100    "source": "https://platform.claude.com/docs/en/api/messages"101  },102  {103    "provider": "anthropic",104    "object": "StopReason",105    "kind": "enum",106    "description": "Why generation stopped. In streaming: null in message_start, set in message_delta.",107    "fields": {108      "end_turn": "natural end — use the response (empty 2–3-token end_turn responses can follow tool results)",109      "max_tokens": "hit max_tokens or model max — raise max_tokens / continue; truncated tool_use blocks must be regenerated",110      "stop_sequence": "one of stop_sequences emitted — read `stop_sequence`; matched text excluded from content",111      "tool_use": "model calls client tool(s) — run them, return tool_result blocks (only) in the next user message; a server_tool_use without result finishes later",112      "pause_turn": "server-tool loop hit its iteration limit (default 10) — resend the assistant content as-is to continue",113      "refusal": "safety classifier stopped the response (HTTP 200) — read stop_details.category, retry on a fallback model",114      "model_context_window_exceeded": "output filled the context window — treat as truncated (Sonnet 4.5+ without beta; older models need model-context-window-exceeded-2025-08-26)",115      "compaction (beta)": "stopped after producing a compaction block (compact_20260112 with pause_after_compaction / compaction param)"116    },117    "status": [118      "DOCUMENTED",119      "LIVE_VERIFIED"120    ],121    "example": null,122    "source": "https://platform.claude.com/docs/en/build-with-claude/handling-stop-reasons",123    "live_observed": [124      "end_turn",125      "max_tokens",126      "stop_sequence",127      "tool_use"128    ]129  },130  {131    "provider": "anthropic",132    "object": "RefusalStopDetails",133    "kind": "response",134    "description": "stop_details when stop_reason=refusal.",135    "fields": {136      "type": "'refusal'",137      "category": "'cyber'|'bio'|'frontier_llm'|'reasoning_extraction'|'general_harms'|null",138      "explanation": "string|null (unstable text)"139    },140    "status": [141      "DOCUMENTED"142    ],143    "example": null,144    "source": "https://platform.claude.com/docs/en/api/messages"145  },146  {147    "provider": "anthropic",148    "object": "Container",149    "kind": "response",150    "description": "Code-execution container info.",151    "fields": {152      "id": "string",153      "expires_at": "date-time",154      "skills": "[{type: anthropic|custom, skill_id, version}]|null"155    },156    "status": [157      "DOCUMENTED"158    ],159    "example": null,160    "source": "https://platform.claude.com/docs/en/api/messages",161    "live_note": "null on every plain request"162  },163  {164    "provider": "anthropic",165    "object": "ModelInfo",166    "kind": "response",167    "description": "GET /v1/models item.",168    "fields": {169      "type": "'model'",170      "id": "string",171      "display_name": "string",172      "created_at": "RFC3339",173      "max_input_tokens": "int|null",174      "max_tokens": "int|null",175      "capabilities": "{batch, citations, code_execution, context_management{clear_tool_uses_20250919, clear_thinking_20251015, compact_20260112}, effort{low..max}, image_input, pdf_input, structured_outputs, thinking{types{enabled, adaptive}}} each {supported: bool}"176    },177    "status": [178      "DOCUMENTED",179      "LIVE_VERIFIED"180    ],181    "example": {182      "type": "model",183      "id": "claude-haiku-4-5-20251001",184      "display_name": "Claude Haiku 4.5",185      "created_at": "2025-10-15T00:00:00Z",186      "max_input_tokens": 200000,187      "max_tokens": 64000188    },189    "source": "https://platform.claude.com/docs/en/api/models/list"190  },191  {192    "provider": "anthropic",193    "object": "Completion (legacy)",194    "kind": "response",195    "description": "POST /v1/complete response.",196    "fields": {197      "type": "'completion'",198      "id": "compl_…",199      "completion": "string (up to, excluding, the stop sequence)",200      "model": "string",201      "stop_reason": "'stop_sequence'|'max_tokens'|null"202    },203    "status": [204      "DOCUMENTED",205      "LEGACY",206      "DEPRECATED"207    ],208    "example": null,209    "source": "https://platform.claude.com/docs/en/api/completions"210  },211  {212    "provider": "anthropic",213    "object": "ErrorResponse",214    "kind": "error",215    "description": "All errors: JSON with top-level error{type,message} and request_id (mirrors the request-id header). Streaming errors omit request_id.",216    "fields": {217      "type": "'error'",218      "error.type": "invalid_request_error|authentication_error|billing_error|permission_error|not_found_error|conflict_error|request_too_large|rate_limit_error|api_error|timeout_error|overloaded_error",219      "error.message": "string",220      "request_id": "req_…"221    },222    "status": [223      "DOCUMENTED",224      "LIVE_VERIFIED"225    ],226    "example": {227      "type": "error",228      "error": {229        "type": "not_found_error",230        "message": "model: claude-does-not-exist"231      },232      "request_id": "req_011CfBxeBpDojVzndwYnobEw"233    },234    "source": "https://platform.claude.com/docs/en/api/errors"235  },236  {237    "provider": "anthropic",238    "object": "MessageTokensCount",239    "kind": "response",240    "description": "POST /v1/messages/count_tokens response.",241    "fields": {242      "input_tokens": "int (estimate; system-added tokens included but not billed)"243    },244    "status": [245      "DOCUMENTED",246      "LIVE_VERIFIED"247    ],248    "example": {249      "input_tokens": 11250    },251    "source": "https://platform.claude.com/docs/en/api/messages/count_tokens"252  },253  {254    "provider": "anthropic",255    "object": "ContentBlock:text",256    "kind": "content_block (request+response)",257    "description": "Plain text; response may carry citations[].",258    "fields": {259      "type": "'text'",260      "text": "string",261      "citations": "TextCitation[]|null",262      "cache_control (request)": "CacheControlEphemeral|null"263    },264    "status": [265      "DOCUMENTED",266      "LIVE_VERIFIED"267    ],268    "example": {269      "type": "text",270      "text": "OK."271    },272    "source": "https://platform.claude.com/docs/en/api/messages"273  },274  {275    "provider": "anthropic",276    "object": "ContentBlock:image",277    "kind": "content_block (request)",278    "description": "Image input: base64 (jpeg/png/gif/webp), url, or Files API file. Optional transformations.oversized_image downsize|error.",279    "fields": {280      "type": "'image'",281      "source": "{type: base64, media_type, data} | {type: url, url} | {type: file, file_id}",282      "transformations": "{oversized_image}|null",283      "cache_control": "…"284    },285    "status": [286      "DOCUMENTED",287      "LIVE_VERIFIED"288    ],289    "example": null,290    "source": "https://platform.claude.com/docs/en/api/messages",291    "live_note": "1x1 PNG counted 5 extra tokens via count_tokens"292  },293  {294    "provider": "anthropic",295    "object": "ContentBlock:document",296    "kind": "content_block (request)",297    "description": "Document input: base64 PDF, plain text, custom content blocks, url, or file; optional title/context/citations.enabled.",298    "fields": {299      "type": "'document'",300      "source": "{type: base64, media_type: application/pdf, data} | {type: text, media_type: text/plain, data} | {type: content, content} | {type: url, url} | {type: file, file_id}",301      "title": "string|null",302      "context": "string|null",303      "citations": "{enabled: bool}|null",304      "cache_control": "…"305    },306    "status": [307      "DOCUMENTED",308      "LIVE_VERIFIED"309    ],310    "example": null,311    "source": "https://platform.claude.com/docs/en/api/messages",312    "live_note": "text document + citations.enabled counted 562 tokens via count_tokens (11 without) — citations add fixed overhead"313  },314  {315    "provider": "anthropic",316    "object": "ContentBlock:search_result",317    "kind": "content_block (request)",318    "description": "Your own search results with citations support.",319    "fields": {320      "type": "'search_result'",321      "source": "string",322      "title": "string",323      "content": "TextBlockParam[]",324      "citations": "{enabled}|null",325      "cache_control": "…"326    },327    "status": [328      "DOCUMENTED"329    ],330    "example": null,331    "source": "https://platform.claude.com/docs/en/api/messages"332  },333  {334    "provider": "anthropic",335    "object": "ContentBlock:thinking",336    "kind": "content_block (request+response)",337    "description": "Reasoning block; replay unchanged (signature verified).",338    "fields": {339      "type": "'thinking'",340      "thinking": "string",341      "signature": "string"342    },343    "status": [344      "DOCUMENTED",345      "LIVE_VERIFIED"346    ],347    "example": null,348    "source": "https://platform.claude.com/docs/en/api/messages"349  },350  {351    "provider": "anthropic",352    "object": "ContentBlock:redacted_thinking",353    "kind": "content_block (request+response)",354    "description": "Encrypted reasoning; replay `data` unchanged.",355    "fields": {356      "type": "'redacted_thinking'",357      "data": "string"358    },359    "status": [360      "DOCUMENTED"361    ],362    "example": null,363    "source": "https://platform.claude.com/docs/en/api/messages"364  },365  {366    "provider": "anthropic",367    "object": "ContentBlock:tool_use",368    "kind": "content_block (request+response)",369    "description": "Client tool call.",370    "fields": {371      "type": "'tool_use'",372      "id": "toolu_…",373      "name": "string",374      "input": "object",375      "caller": "{type: direct}|{type: code_execution_2025…, tool_id}",376      "toolset_name": "string|null"377    },378    "status": [379      "DOCUMENTED",380      "LIVE_VERIFIED"381    ],382    "example": {383      "type": "tool_use",384      "id": "toolu_01S85RZWHSCzo537XxQrQw9e",385      "name": "get_weather",386      "input": {387        "city": "Paris"388      },389      "caller": {390        "type": "direct"391      }392    },393    "source": "https://platform.claude.com/docs/en/api/messages"394  },395  {396    "provider": "anthropic",397    "object": "ContentBlock:tool_result",398    "kind": "content_block (request)",399    "description": "Result for a tool_use; content string or blocks (text, image, search_result, document, tool_reference, browser_state).",400    "fields": {401      "type": "'tool_result'",402      "tool_use_id": "string",403      "content": "string|Block[]",404      "is_error": "bool",405      "toolset_name": "string|null",406      "cache_control": "…"407    },408    "status": [409      "DOCUMENTED",410      "LIVE_VERIFIED"411    ],412    "example": null,413    "source": "https://platform.claude.com/docs/en/api/messages",414    "live_note": "missing tool_result → 400 'tool_use ids were found without tool_result blocks immediately after'"415  },416  {417    "provider": "anthropic",418    "object": "ContentBlock:server_tool_use",419    "kind": "content_block (request+response)",420    "description": "Server tool call (web_search, web_fetch, code_execution, bash_code_execution, text_editor_code_execution, tool_search_tool_regex, tool_search_tool_bm25; beta adds advisor).",421    "fields": {422      "type": "'server_tool_use'",423      "id": "srvtoolu_…",424      "name": "enum",425      "input": "object",426      "caller": "…"427    },428    "status": [429      "DOCUMENTED"430    ],431    "example": null,432    "source": "https://platform.claude.com/docs/en/api/messages"433  },434  {435    "provider": "anthropic",436    "object": "ContentBlock:web_search_tool_result",437    "kind": "content_block (request+response)",438    "description": "Server web search result.",439    "fields": {440      "type": "'web_search_tool_result'",441      "tool_use_id": "srvtoolu_…",442      "content": "web_search_result[] {type, url, title, encrypted_content, page_age} | {type: web_search_tool_result_error, error_code}",443      "error_code enum": "invalid_tool_input|unavailable|max_uses_exceeded|too_many_requests|query_too_long|request_too_large"444    },445    "status": [446      "DOCUMENTED"447    ],448    "example": null,449    "source": "https://platform.claude.com/docs/en/api/messages"450  },451  {452    "provider": "anthropic",453    "object": "ContentBlock:web_fetch_tool_result",454    "kind": "content_block (request+response)",455    "description": "Server web fetch result.",456    "fields": {457      "type": "'web_fetch_tool_result'",458      "tool_use_id": "srvtoolu_…",459      "content": "{type: web_fetch_result, url, content: document, retrieved_at} | {type: web_fetch_tool_result_error, error_code}",460      "error_code enum": "invalid_tool_input|url_too_long|url_not_allowed|url_not_in_prior_context|url_not_accessible|unsupported_content_type|too_many_requests|max_uses_exceeded|unavailable|content_too_large"461    },462    "status": [463      "DOCUMENTED"464    ],465    "example": null,466    "source": "https://platform.claude.com/docs/en/api/messages"467  },468  {469    "provider": "anthropic",470    "object": "ContentBlock:code_execution_tool_result",471    "kind": "content_block (request+response)",472    "description": "Code execution result.",473    "fields": {474      "type": "'code_execution_tool_result'",475      "tool_use_id": "srvtoolu_…",476      "content": "{type: code_execution_result, stdout, stderr, return_code, content: code_execution_output[] {file_id}} | {type: code_execution_tool_result_error, error_code}",477      "error_code enum": "invalid_tool_input|unavailable|too_many_requests|execution_time_exceeded"478    },479    "status": [480      "DOCUMENTED"481    ],482    "example": null,483    "source": "https://platform.claude.com/docs/en/api/messages"484  },485  {486    "provider": "anthropic",487    "object": "ContentBlock:bash_code_execution_tool_result",488    "kind": "content_block (request+response)",489    "description": "Bash execution result (code_execution_20250825+).",490    "fields": {491      "type": "'bash_code_execution_tool_result'",492      "content": "{type: bash_code_execution_result, stdout, stderr, return_code, content[]} | error",493      "error_code enum": "invalid_tool_input|unavailable|too_many_requests|execution_time_exceeded|output_file_too_large"494    },495    "status": [496      "DOCUMENTED"497    ],498    "example": null,499    "source": "https://platform.claude.com/docs/en/api/messages"500  },501  {502    "provider": "anthropic",503    "object": "ContentBlock:text_editor_code_execution_tool_result",504    "kind": "content_block (request+response)",505    "description": "Text editor in container result.",506    "fields": {507      "type": "'text_editor_code_execution_tool_result'",508      "content": "view_result {content, file_type, num_lines, start_line, total_lines} | create_result {is_file_update} | str_replace_result {lines, new_lines, new_start, old_lines, old_start} | error",509      "error_code enum": "invalid_tool_input|unavailable|too_many_requests|execution_time_exceeded|file_not_found"510    },511    "status": [512      "DOCUMENTED"513    ],514    "example": null,515    "source": "https://platform.claude.com/docs/en/api/messages"516  },517  {518    "provider": "anthropic",519    "object": "ContentBlock:tool_search_tool_result",520    "kind": "content_block (request+response)",521    "description": "Tool search result.",522    "fields": {523      "type": "'tool_search_tool_result'",524      "content": "{type: tool_search_tool_search_result, tool_references: tool_reference[]} | {type: tool_search_tool_result_error, error_code}",525      "error_code enum": "invalid_tool_input|unavailable|too_many_requests|execution_time_exceeded"526    },527    "status": [528      "DOCUMENTED"529    ],530    "example": null,531    "source": "https://platform.claude.com/docs/en/api/messages"532  },533  {534    "provider": "anthropic",535    "object": "ContentBlock:container_upload",536    "kind": "content_block (request+response)",537    "description": "File placed into the code-execution container.",538    "fields": {539      "type": "'container_upload'",540      "file_id": "string"541    },542    "status": [543      "DOCUMENTED"544    ],545    "example": null,546    "source": "https://platform.claude.com/docs/en/api/messages"547  },548  {549    "provider": "anthropic",550    "object": "ContentBlock:tool_reference",551    "kind": "content_block (request (inside tool_result))",552    "description": "Reference to a deferred tool (tool search).",553    "fields": {554      "type": "'tool_reference'",555      "tool_name": "string"556    },557    "status": [558      "DOCUMENTED"559    ],560    "example": null,561    "source": "https://platform.claude.com/docs/en/api/messages"562  },563  {564    "provider": "anthropic",565    "object": "ContentBlock:browser_state",566    "kind": "content_block (request (inside tool_result))",567    "description": "Browser toolset state (browser_toolset_20260801).",568    "fields": {569      "type": "'browser_state'",570      "…": "tabs, changes, screenshot"571    },572    "status": [573      "DOCUMENTED"574    ],575    "example": null,576    "source": "https://platform.claude.com/docs/en/api/messages"577  },578  {579    "provider": "anthropic",580    "object": "ContentBlock:mcp_tool_use",581    "kind": "content_block (response (beta))",582    "description": "Call to a remote MCP server tool.",583    "fields": {584      "type": "'mcp_tool_use'",585      "id": "string",586      "name": "string",587      "server_name": "string",588      "input": "object"589    },590    "status": [591      "DOCUMENTED",592      "BETA"593    ],594    "example": null,595    "source": "https://platform.claude.com/docs/en/api/beta/messages"596  },597  {598    "provider": "anthropic",599    "object": "ContentBlock:mcp_tool_result",600    "kind": "content_block (response (beta))",601    "description": "Result from a remote MCP tool.",602    "fields": {603      "type": "'mcp_tool_result'",604      "tool_use_id": "string",605      "is_error": "bool",606      "content": "string|TextBlock[]"607    },608    "status": [609      "DOCUMENTED",610      "BETA"611    ],612    "example": null,613    "source": "https://platform.claude.com/docs/en/api/beta/messages"614  },615  {616    "provider": "anthropic",617    "object": "ContentBlock:advisor_tool_result",618    "kind": "content_block (response (beta))",619    "description": "Advisor tool result (advisor-tool-2026-03-01).",620    "fields": {621      "type": "'advisor_tool_result'",622      "tool_use_id": "string",623      "content": "advisor_result | advisor_redacted_result | error"624    },625    "status": [626      "DOCUMENTED",627      "BETA"628    ],629    "example": null,630    "source": "https://platform.claude.com/docs/en/api/beta/messages"631  },632  {633    "provider": "anthropic",634    "object": "ContentBlock:compaction",635    "kind": "content_block (request+response (beta))",636    "description": "Signed summary replacing earlier messages; round-trip verbatim (null content = failed compaction, treated as no-op).",637    "fields": {638      "type": "'compaction'",639      "content": "string|null",640      "encrypted_content": "string|null",641      "signature": "string|null"642    },643    "status": [644      "DOCUMENTED",645      "BETA"646    ],647    "example": null,648    "source": "https://platform.claude.com/docs/en/api/beta/messages"649  },650  {651    "provider": "anthropic",652    "object": "ContentBlock:fallback",653    "kind": "content_block (response (beta))",654    "description": "Boundary where one model's output gives way to a fallback model (streams as start/stop pair without deltas).",655    "fields": {656      "type": "'fallback'",657      "from": "{model}",658      "to": "{model}",659      "trigger": "{type: refusal, …}"660    },661    "status": [662      "DOCUMENTED",663      "BETA"664    ],665    "example": null,666    "source": "https://platform.claude.com/docs/en/api/beta/messages"667  },668  {669    "provider": "anthropic",670    "object": "TextCitation",671    "kind": "response",672    "description": "Citation variants inside text.citations[] / citations_delta.",673    "fields": {674      "char_location": "{cited_text, document_index, document_title, start_char_index, end_char_index, file_id}",675      "page_location": "{…, start_page_number, end_page_number}",676      "content_block_location": "{…, start_block_index, end_block_index}",677      "web_search_result_location": "{cited_text, url, title, encrypted_index}",678      "search_result_location": "{cited_text, source, title, search_result_index, start_block_index, end_block_index}"679    },680    "status": [681      "DOCUMENTED"682    ],683    "example": null,684    "source": "https://platform.claude.com/docs/en/api/messages"685  },686  {687    "provider": "anthropic",688    "object": "CacheControlEphemeral",689    "kind": "request",690    "description": "Cache breakpoint marker.",691    "fields": {692      "type": "'ephemeral'",693      "ttl": "'5m' (default) | '1h'"694    },695    "status": [696      "DOCUMENTED",697      "LIVE_VERIFIED"698    ],699    "example": null,700    "source": "https://platform.claude.com/docs/en/api/messages"701  }702]703