headroomlabs-ai/headroom · error · ValueError
Unsupported api_style: {api_style}
Error message
Unsupported api_style: {api_style} What it means
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.
Source
Thrown at headroom/providers/registry.py:282
return f"{provider_config.display_name} via LiteLLM (region={bedrock_region})"
return f"{provider_config.display_name} via LiteLLM"
def call_client_transport(
api_style: str,
client: Any,
*,
model: str,
messages: list[dict[str, Any]],
stream: bool,
metrics: Any,
**kwargs: Any,
) -> Any:
"""Dispatch the SDK request to the provider-specific transport handler."""
try:
transport = _CLIENT_TRANSPORTS[api_style]
except KeyError as exc:
raise ValueError(f"Unsupported api_style: {api_style}") from exc
return transport(
client,
model=model,
messages=messages,
stream=stream,
metrics=metrics,
**kwargs,
)
def _load_anyllm_backend() -> Any:
global AnyLLMBackendType
if AnyLLMBackendType is None:
from headroom.backends.anyllm import AnyLLMBackend
AnyLLMBackendType = AnyLLMBackend
return AnyLLMBackendTypeView on GitHub (pinned to 322425c43b)
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.
Example fix
# before client = build_client(provider_cfg) # api_style="gemini" response = dispatch_client_call(client, api_style="gemini", ...) # ValueError # after response = dispatch_client_call(client, api_style="openai", ...) # gemini via openai-compatible endpoint
Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED_API_STYLES = frozenset({"anthropic", "openai"})
def api_style_ok(style: str) -> bool:
return style in SUPPORTED_API_STYLES Type guard
from typing import Literal
ApiStyle = Literal["anthropic", "openai"]
def is_api_style(value: str) -> TypeGuard[ApiStyle]:
return value in ("anthropic", "openai") Try / catch
try:
result = dispatch_client_call(client, api_style=style, ...)
except ValueError as exc:
if "Unsupported api_style" in str(exc):
raise ConfigError(f"{style!r} not supported here; use anthropic|openai") from exc
raise Prevention
- 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.
When it happens
Trigger: 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().
Common situations: 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.
Related errors
- Unknown provider: {provider}
- Unknown provider: {self.llm_config.provider}
- recommendations IO error at {path}: {source}
- bedrock_eventstream_parse_failed
- bedrock_eventstream_crc_mismatch
AI-assisted analysis of headroomlabs-ai/headroom@322425c43b (2026-08-15).
Data as JSON: /api/errors/e0d8a2871da3ac60.
Report an issue: GitHub.