{"record":{"id":"fb39f08f339a0cce","repo":"BerriAI/litellm","slug":"unknown-anthropic-content-type-content-type","errorCode":null,"errorMessage":"Unknown Anthropic content type: '{content_type}'","messagePattern":"Unknown Anthropic content type: '(.+?)'","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/litellm_core_utils/token_counter.py","lineNumber":627,"sourceCode":"\ndef _validate_anthropic_content(content: Mapping[str, Any]) -> type:\n    \"\"\"\n    Validate and determine which Anthropic TypedDict applies.\n\n    Returns the corresponding TypedDict class if recognized, otherwise raises.\n    \"\"\"\n    content_type: Final = content.get(\"type\")\n    if not content_type:\n        raise ValueError(\"Anthropic content missing required field: 'type'\")\n\n    mapping: Final = {\n        \"tool_use\": AnthropicMessagesToolUseParam,\n        \"tool_result\": AnthropicMessagesToolResultParam,\n    }\n\n    expected_cls: Final = mapping.get(content_type)\n    if expected_cls is None:\n        raise ValueError(f\"Unknown Anthropic content type: '{content_type}'\")\n\n    missing: Final = [k for k in getattr(expected_cls, \"__required_keys__\", set()) if k not in content]\n    if missing:\n        raise ValueError(f\"Missing required fields in {content_type} block: {', '.join(missing)}\")\n\n    return expected_cls\n\n\ndef _count_anthropic_content(\n    content: Mapping[str, Any],\n    count_function: TokenCounterFunction,\n    use_default_image_token_count: bool,\n    default_token_count: int | None,\n) -> int:\n    \"\"\"\n    Count tokens in Anthropic-specific content blocks (tool_use, tool_result, etc.).\n\n    Uses TypedDict definitions from litellm.types.llms.anthropic to determine","sourceCodeStart":609,"sourceCodeEnd":645,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/litellm_core_utils/token_counter.py#L609-L645","documentation":"Anthropic content validation guard: the content block's 'type' is not one of the recognized Anthropic types (tool_use, tool_result), so no TypedDict applies. Fires on unsupported content types passed through Anthropic message counting.","triggerScenarios":"Thrown at litellm/litellm_core_utils/token_counter.py:627 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a supported Anthropic content type (text, image, tool_use, tool_result, etc.).","Fix or remove the unknown content block type."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}