Skip to content

Studio: hint at Model auto-switch in the OpenAI "No model loaded" 400 - #7006

Merged
oobabooga merged 3 commits into
unslothai:mainfrom
oobabooga:studio-api-auto-load-hint
Jul 10, 2026
Merged

oobabooga merged 3 commits into
unslothai:mainfrom
oobabooga:studio-api-auto-load-hint

Conversation

@oobabooga

Copy link
Copy Markdown
Member

Studio can already auto-load a requested model over the API before serving it, but it's opt-in and off by default (Model auto-switch, shipped in #6392/#6430). With it off, calling /v1/chat/completions with a model that /v1/models lists returns a bare 400 No model loaded. Call POST /inference/load first., and nothing tells you the toggle that fixes it exists. Users keep hitting this and reporting it (Discord).

Fix

When auto-switch is off, the "no model loaded" error now adds a pointer to the toggle:

No model loaded. Call POST /inference/load first. Or enable Model auto-switch (Settings > API) to load a requested model automatically.

Turn the toggle on and the same request loads the model and serves it. The hint only shows when it would actually help. With auto-switch already on, hitting the error means the requested name just didn't match a downloaded model, so the pointer would be misleading and is left off.

The same hint now covers the other endpoints where auto-switch applies too, not just chat: /v1/completions, /v1/embeddings, and the Anthropic /v1/messages and /v1/messages/count_tokens. Streaming /v1/responses gets it only when nothing is loaded at all, since that error also fires when a non-GGUF model is already up (where enabling auto-switch wouldn't change anything). The in-app UI routes are unchanged.

Verification

Ran Studio and hit each endpoint live. With auto-switch off the hint shows up; with it on and an unrecognized model name it stays off. Added regression tests for both cases, including the streaming /v1/responses behavior. test_openai_auto_switch.py passes (150).

@oobabooga
oobabooga requested a review from danielhanchen as a code owner July 9, 2026 02:07

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a helper function _no_model_loaded_detail in inference.py to append a helpful hint about enabling the 'Model auto-switch' toggle to 'no model loaded' error messages when the feature is disabled. This helper is integrated into several endpoints, including audio generation, OpenAI completions/embeddings, Anthropic messages, and responses streaming. Additionally, corresponding unit tests have been added to verify this behavior under different configuration states. There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e118319017

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread studio/backend/routes/inference.py Outdated
Comment on lines +9013 to +9014
if not get_inference_backend().active_model_name:
detail = _no_model_loaded_detail(detail)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Show the auto-switch hint when a non-GGUF model is active

This suppresses the new hint for every streaming /v1/responses request while a Transformers/non-GGUF model is active, but that includes a fixable case: openai_responses already calls _maybe_auto_switch_model before _responses_stream, and with auto-switch enabled a request whose model resolves to a downloaded GGUF will load it even over an active non-GGUF backend. With the toggle off, the same request still hits this GGUF-only 400 without the hint, so users naming a listed local GGUF get the bare error this change is meant to clarify.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 42cd52f: dropped the active_model_name gate, so the hint attaches whenever the toggle is off, matching the other no-model-loaded call sites (auto-switch's resolver branch does evict an active non-GGUF model to load a resolved GGUF).

@oobabooga

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 42cd52f6a6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@oobabooga
oobabooga merged commit 7bfa209 into unslothai:main Jul 10, 2026
43 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