AudioMuse-AI icon indicating copy to clipboard operation
AudioMuse-AI copied to clipboard

[BUG] OpenAI non-reasoning models (gpt-4o-mini) fail: reasoning_effort rejected with code:null, recovery fallback misses it

Open Kyrunner opened this issue 5 months ago • 4 comments

Summary

With AI_MODEL_PROVIDER=OPENAI and a non-reasoning model (e.g. gpt-4o-mini), every chat/AI playlist and "Brainstorm AI" call fails with "AI service is currently unavailable." The request is rejected by the OpenAI API and the existing reasoning_effort fallback does not recover it.

Environment

  • AudioMuse-AI :latest (image created 2026-06-25)
  • Provider: OpenAI (https://api.openai.com/v1/chat/completions)
  • OPENAI_MODEL_NAME=gpt-4o-mini

Symptom (logs)

[ERROR] Error calling OpenAI-compatible API: 400 Client Error: Bad Request ...
Response body: { "error": { "message": "Unrecognized request argument supplied: reasoning_effort",
                "type": "invalid_request_error", "param": null, "code": null } }
  File "/app/tasks/ai/providers/openai.py", line 121, in generate_text
[WARNING] Brainstorm AI call failed: Error: AI service is currently unavailable.

Root cause

In tasks/ai/providers/openai.py, the streaming payload is built with:

"reasoning_effort": "low" if is_deepseek else "none",

Non-reasoning OpenAI chat models (gpt-4o-mini, gpt-4o, gpt-4.1*, etc.) reject the reasoning_effort argument outright. Critically, OpenAI returns this as:

  • error.type = "invalid_request_error"
  • error.code = null
  • error.message = "Unrecognized request argument supplied: reasoning_effort"

The 400-recovery block only treats the error as recoverable when:

error_code = error_body.get("error", {}).get("code", "")
if error_code in ("unsupported_parameter", "unsupported_value"):
    ...
    payload.pop("reasoning_effort", None)

Because code is null here (the signal is in error.message, not error.code), the fallback never fires, so reasoning_effort is never stripped and the call is re-raised as a hard failure. The same gap exists in call_with_tools().

This affects every OpenAI non-reasoning model, which is the most common/cheapest config.

Suggested fix

Broaden the 400 recovery to also match on the message text, e.g.:

err = error_body.get("error", {})
code = err.get("code") or ""
msg  = (err.get("message") or "").lower()
if code in ("unsupported_parameter", "unsupported_value") or "reasoning_effort" in msg or "unrecognized request argument" in msg:
    payload.pop("reasoning_effort", None)
    ... retry

(Alternatively: only include reasoning_effort for known reasoning models.)

Repro

  1. OPENAI_MODEL_PROVIDER=OPENAI, OPENAI_MODEL_NAME=gpt-4o-mini
  2. Generate an AI/chat playlist → "AI service is currently unavailable".

Kyrunner avatar Jun 26 '26 12:06 Kyrunner

Hi and thanks for the feedback. The message come from the fact thart you're using a not supported model. Is not possible for AudioMuse-AI to support all the existing model because each one have his list of param and the effort of support all is huge and totally out of the core of AudioMuse-AI.

We highly suggest you to pick one of the supported model as per documentations:

  • qwen3.5:9b
  • qwen3.5:4b
  • qwen3.5:0.8b

Anyway I add a small fix that should solve this specifc scenario, the new image should be ready in this PR in around 60 minute https://github.com/NeptuneHub/AudioMuse-AI/pull/704

Please let me know if this enable your use case scenario.

NeptuneHub avatar Jun 29 '26 07:06 NeptuneHub

Feature released in v2.3.3, please install directly this verison and let me know.

NeptuneHub avatar Jun 29 '26 10:06 NeptuneHub

All fixed thanks

Kyrunner avatar Jun 29 '26 10:06 Kyrunner

We've closed the issue now, thanks for having starred AudioMuse-AI and supporting self-hosted music here on GitHub! It really helps the project grow!

github-actions[bot] avatar Jun 29 '26 10:06 github-actions[bot]