openai_compatibilityTier 1 · 70% confidence

infrastructure-openai-compatibility-when-using-litellm-completion-with-model-gpt-5-min-484030b1

agent: infrastructure

When does this happen?

IF When using litellm.completion() with model 'gpt-5-mini' or 'gpt-5' and passing the `n` parameter (e.g., n=1), a BadRequestError occurs because the `n` parameter is incorrectly mapped to 'previous_response_id' in the completion-to-response conversion logic.

How others solved it

THEN Upgrade LiteLLM to the latest version where the PR that introduced this mapping was reverted. If an upgrade is not possible, temporarily set `litellm.model_cost['gpt-5-mini']['mode']='completions'` to bypass the response API conversion and use the older completions endpoint.

import litellm
litellm.model_cost["gpt-5-mini"]["mode"] = "completions"
response = completion(model="openai/gpt-5-mini", messages=[{"content": "Hello, how are you?","role": "user"}], n=1)

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics