{"record":{"id":"e0d8a2871da3ac60","repo":"headroomlabs-ai/headroom","slug":"unsupported-api-style-api-style","errorCode":null,"errorMessage":"Unsupported api_style: {api_style}","messagePattern":"Unsupported api_style: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"headroom/providers/registry.py","lineNumber":282,"sourceCode":"        return f\"{provider_config.display_name} via LiteLLM (region={bedrock_region})\"\n    return f\"{provider_config.display_name} via LiteLLM\"\n\n\ndef call_client_transport(\n    api_style: str,\n    client: Any,\n    *,\n    model: str,\n    messages: list[dict[str, Any]],\n    stream: bool,\n    metrics: Any,\n    **kwargs: Any,\n) -> Any:\n    \"\"\"Dispatch the SDK request to the provider-specific transport handler.\"\"\"\n    try:\n        transport = _CLIENT_TRANSPORTS[api_style]\n    except KeyError as exc:\n        raise ValueError(f\"Unsupported api_style: {api_style}\") from exc\n\n    return transport(\n        client,\n        model=model,\n        messages=messages,\n        stream=stream,\n        metrics=metrics,\n        **kwargs,\n    )\n\n\ndef _load_anyllm_backend() -> Any:\n    global AnyLLMBackendType\n    if AnyLLMBackendType is None:\n        from headroom.backends.anyllm import AnyLLMBackend\n\n        AnyLLMBackendType = AnyLLMBackend\n    return AnyLLMBackendType","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/headroomlabs-ai/headroom/blob/322425c43bffde1ed0b64fecf3cf5951565dd82b/headroom/providers/registry.py#L264-L300","documentation":"Provider requests are dispatched through _CLIENT_TRANSPORTS, which currently maps exactly two api_style keys: \"anthropic\" and \"openai\". dispatch_client_call() looks up the style and re-raises KeyError as ValueError('Unsupported api_style: ...') when a client was built with any other style string. This indicates a provider/client configuration mismatch rather than a network problem.","triggerScenarios":"Creating a provider client with an api_style outside {\"anthropic\", \"openai\"} — e.g. \"gemini\", \"litellm\", \"generic\", a typo like \"openAi\", or a style added by a newer/older headroom version — and then issuing a request that goes through dispatch_client_call().","commonSituations":"Copy-pasting a provider config from docs for a version that supported a different style set; hand-rolling a provider registration with an invented style name; version skew between the config file and the installed headroom package.","solutions":["Set the provider's api_style to \"anthropic\" or \"openai\" — the only styles _CLIENT_TRANSPORTS registers in this version.","Check for case/whitespace issues: the lookup is an exact dict key match, so \"OpenAI\" or \" anthropic\" fail.","If you expected a newer style (e.g. for Gemini pass-through), upgrade headroom or route Gemini traffic through its dedicated handler instead of the generic client dispatch."],"exampleFix":"# before\nclient = build_client(provider_cfg)  # api_style=\"gemini\"\nresponse = dispatch_client_call(client, api_style=\"gemini\", ...)  # ValueError\n\n# after\nresponse = dispatch_client_call(client, api_style=\"openai\", ...)  # gemini via openai-compatible endpoint","handlingStrategy":"validation","validationCode":"SUPPORTED_API_STYLES = frozenset({\"anthropic\", \"openai\"})\n\ndef api_style_ok(style: str) -> bool:\n    return style in SUPPORTED_API_STYLES","typeGuard":"from typing import Literal\n\nApiStyle = Literal[\"anthropic\", \"openai\"]\n\ndef is_api_style(value: str) -> TypeGuard[ApiStyle]:\n    return value in (\"anthropic\", \"openai\")","tryCatchPattern":"try:\n    result = dispatch_client_call(client, api_style=style, ...)\nexcept ValueError as exc:\n    if \"Unsupported api_style\" in str(exc):\n        raise ConfigError(f\"{style!r} not supported here; use anthropic|openai\") from exc\n    raise","preventionTips":["Validate provider configs against the installed version's supported style set at load time.","Type the field as Literal[\"anthropic\", \"openai\"] in typed configs so mistakes fail at typecheck.","After upgrading headroom, re-check which styles _CLIENT_TRANSPORTS registers before using new names."],"tags":["configuration","provider","dispatch","python"],"backgroundTag":null,"analyzedSha":"322425c43bffde1ed0b64fecf3cf5951565dd82b","analyzedAt":"2026-08-15T01:03:05.481Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}