BerriAI/litellm · error · HTTPException

{e.message}

Error message

{e.message}

What it means

Re-raise site in the Bedrock CountTokens except-block: a BedrockError raised by handle_count_tokens_request is converted into a FastAPI HTTPException carrying the upstream status code and the provider's original error message in the detail body.

Source

Thrown at litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py:863

                    if key != "user_api_key_dict":  # Don't overwrite user_api_key_dict
                        litellm_params[key] = value

        verbose_proxy_logger.debug("Count tokens litellm_params: %s", litellm_params)
        verbose_proxy_logger.debug("Resolved model: %s", resolved_model)

        # Handle the count tokens request
        result: Final = await handler.handle_count_tokens_request(
            request_data=request_body,
            litellm_params=litellm_params,
            resolved_model=resolved_model,
        )

        return result

    except BedrockError as e:
        # Convert BedrockError to HTTPException for FastAPI
        verbose_proxy_logger.error("BedrockError in handle_bedrock_count_tokens: %s", e)
        raise HTTPException(status_code=e.status_code, detail={"error": e.message})
    except HTTPException:
        # Re-raise HTTP exceptions as-is
        raise
    except Exception as e:
        verbose_proxy_logger.error("Error in handle_bedrock_count_tokens: %s", e)
        raise HTTPException(status_code=500, detail={"error": f"CountTokens processing error: {e}"})


async def bedrock_llm_proxy_route(
    endpoint: str,
    request: Request,
    fastapi_response: Response,
    user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),
):
    """
    Handles Bedrock LLM API calls.

    Supports both direct Bedrock models and router models from config.yaml.

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. This surfaces an AWS BedrockError; check the embedded message and status code for the specific Bedrock failure (auth, throttling, model access).
  2. Verify AWS credentials/region and that the requested Bedrock model is enabled in your account.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py:863 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/b2209f397c3d2261. Report an issue: GitHub.