diff --git a/litellm/llms/oci/chat/cohere.py b/litellm/llms/oci/chat/cohere.py index ce3560cd2bb..39caebba03a 100644 --- a/litellm/llms/oci/chat/cohere.py +++ b/litellm/llms/oci/chat/cohere.py @@ -294,6 +294,12 @@ def handle_cohere_stream_chunk(dict_chunk: dict) -> ModelResponseStream: finish_reason = "length" elif finish_reason == "TOOL_CALL": finish_reason = "tool_calls" + elif finish_reason is not None: + # OCI Cohere can emit error/cancel finish reasons (e.g. ``ERROR``, + # ``ERROR_TOXIC``, ``ERROR_LIMIT``, ``USER_CANCEL``) that aren't part + # of OpenAI's standard set. Normalize them to ``"stop"`` so downstream + # consumers switching on ``finish_reason`` keep working. + finish_reason = "stop" return ModelResponseStream( choices=[ diff --git a/litellm/llms/oci/chat/transformation.py b/litellm/llms/oci/chat/transformation.py index f8ecc479cae..1bf960e5efc 100644 --- a/litellm/llms/oci/chat/transformation.py +++ b/litellm/llms/oci/chat/transformation.py @@ -209,6 +209,12 @@ class OCIChatConfig(BaseConfig): # the param dropped under drop_params, rather than silently passing # through and tripping Pydantic validation on CohereChatRequest. self.openai_to_oci_cohere_param_map["reasoning_effort"] = False + # CohereChatRequest has no logProbs/logitBias fields, so passing these + # through would be silently dropped by Pydantic. Mark them unsupported + # so get_supported_openai_params doesn't advertise them and callers + # get a clear error (or drop_params behaviour) instead. + self.openai_to_oci_cohere_param_map["logprobs"] = False + self.openai_to_oci_cohere_param_map["logit_bias"] = False def get_supported_openai_params(self, model: str) -> List[str]: param_map = (