Skip to content

Fix: retry without temperature for models that only accept the default - #7

Merged
LubergAlexander merged 1 commit into
masterfrom
fix/temperature-unsupported-models
Jul 21, 2026
Merged

Fix: retry without temperature for models that only accept the default#7
LubergAlexander merged 1 commit into
masterfrom
fix/temperature-unsupported-models

Conversation

@LubergAlexander

Copy link
Copy Markdown
Owner

Problem

Newer models (e.g. OpenAI's o1 / gpt-5 series, such as gpt-5.6-sol) only accept the default temperature and reject any explicit value:

litellm.BadRequestError: OpenAIException - Unsupported value: 'temperature' does not support 0.7 with this model. Only the default (1) value is supported.

Our _complete() helper always passes temperature=0.7/0.8, so playlist generation fails outright with these models.

Fix

_complete() now catches a temperature-related BadRequestError and retries once without the temperature parameter, letting the model use its own default. Any other BadRequestError (e.g. context-length) is re-raised unchanged, so we don't mask real failures.

This keeps the tuned temperatures for models that support them (most of them) while degrading gracefully for those that don't — no per-model allowlist to maintain.

Testing

  • New test: a model that raises the temperature error is transparently retried without temperature and succeeds.
  • New test: an unrelated BadRequestError still propagates.
  • Full suite: 34 passing; pylint 10.00/10; flake8/black/isort clean.

🤖 Generated with Claude Code

Some models (e.g. OpenAI's o1 / gpt-5 series such as gpt-5.6-sol) only
accept the default temperature and return a BadRequestError for any
explicit value:

    OpenAIException - Unsupported value: 'temperature' does not support
    0.7 with this model. Only the default (1) value is supported.

_complete() now catches a temperature-related BadRequestError and retries
once without the temperature parameter, letting the model use its default,
instead of failing the whole request. Unrelated BadRequestErrors are
re-raised unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@LubergAlexander
LubergAlexander merged commit 1333af8 into master Jul 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant