BerriAI/litellm · error · CometAPIException

CometAPI Error: {}

Error message

CometAPI Error: {}

What it means

Error "CometAPI Error: {}" thrown in BerriAI/litellm.

Source

Thrown at litellm/llms/cometapi/chat/transformation.py:166

            json_mode=json_mode,
        )


class CometAPIChatCompletionStreamingHandler(BaseModelResponseIterator):
    """
    Handler for CometAPI streaming chat completion responses
    """

    def chunk_parser(self, chunk: dict) -> ModelResponseStream:
        """
        Parse individual chunks from streaming response
        """
        try:
            # Handle error in chunk
            if "error" in chunk:
                error_chunk: Final = chunk["error"]
                error_message: Final = "CometAPI Error: {}".format(error_chunk.get("message", "Unknown error"))
                raise CometAPIException(
                    message=error_message,
                    status_code=error_chunk.get("code", 400),
                    headers={"Content-Type": "application/json"},
                )

            # Process choices
            new_choices: Final = []
            for choice in chunk["choices"]:
                # Handle reasoning content if present
                if "delta" in choice and "reasoning" in choice["delta"]:
                    choice["delta"]["reasoning_content"] = choice["delta"].get("reasoning")
                new_choices.append(choice)

            return ModelResponseStream(
                id=chunk["id"],
                object="chat.completion.chunk",
                created=chunk["created"],
                usage=chunk.get("usage"),

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Inspect the CometAPI error message for details.

When it happens

Trigger: Thrown at litellm/llms/cometapi/chat/transformation.py:166 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/281ada5c60b552bd. Report an issue: GitHub.