Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: restore public OpenAPI descriptions on four routes and schemas (#16223)

Daniel Han24ce8727a681
diff --git a/studio/backend/main.py b/studio/backend/main.py
index b5f22b97141..28157aea2e3 100644
--- a/studio/backend/main.py
+++ b/studio/backend/main.py
@@ -2160,7 +2160,13 @@ async def _desktop_shell_subject(request: Request) -> Optional[str]:
@app.get("/api/health")
async def health_check(request: Request):
- """Waits for detection so a GPU host does not grey out Train/Export, but only up to a budget; the snapshot below decides the reply."""
+ """Liveness plus launcher capability bits; host fingerprint gated on authentication.
+
+ Unauthenticated callers get non-sensitive fields (service, studio_root_id,
+ chat_only, desktop_*, native_path_leases_supported) to re-adopt a sibling
+ backend and gate UI before a token exists. version / studio_version /
+ device_type require authentication, including a valid desktop secret.
+ """
await _await_hardware_detection(_HEALTH_DETECT_BUDGET_S)
# Snapshot, not a bare global read: a forced re-detect can start at any moment.
snapshot = _hardware_snapshot()
diff --git a/studio/backend/models/inference.py b/studio/backend/models/inference.py
index b90f0b169cc..e9530d9d508 100644
--- a/studio/backend/models/inference.py
+++ b/studio/backend/models/inference.py
@@ -2841,7 +2841,9 @@ class SandboxAttachment(BaseModel):
class ChatCompletionRequest(BaseModel):
- """Accept unknown fields so future OpenAI fields are not dropped before route code runs. Mirrors AnthropicMessagesRequest and ResponsesRequest."""
+ """OpenAI-compatible chat completion request.
+
+ Non-OpenAI extension fields are marked with 'x-unsloth'."""
model_config = {"extra": "allow"}
# "off" with the client's own confirm_tool_calls=false: no prompt at all, even without OS isolation.
diff --git a/studio/backend/routes/auth.py b/studio/backend/routes/auth.py
index 6cd4de06dcf..8a6bc036849 100644
--- a/studio/backend/routes/auth.py
+++ b/studio/backend/routes/auth.py
@@ -521,7 +521,12 @@ async def logout(
# Sync def: PBKDF2 + SQLite would block the event loop.
@router.post("/desktop-login", response_model = Token)
def desktop_login(payload: DesktopLoginRequest, request: Request) -> Token | Response:
- """Before reading the bucket: the shell probes with an invalid secret every tick and needs 401, since any other status reads as unmanageable."""
+ """Exchange a local desktop secret for desktop-marked owner tokens.
+
+ Multi-user installations return ``login_required`` instead of tokens.
+ Failed attempts are rate-limited per IP independently of /login.
+ """
+ # Shell ownership probes need 401 for malformed secrets even when throttled.
if not storage.desktop_secret_is_well_formed(payload.secret):
raise HTTPException(
status_code = status.HTTP_401_UNAUTHORIZED,
diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.py
index 411076cdebb..3b3327c90e6 100644
--- a/studio/backend/routes/inference.py
+++ b/studio/backend/routes/inference.py
@@ -51025,7 +51025,15 @@ async def openai_image_generations(
current_subject: str = Depends(get_current_subject),
hf_token: Optional[str] = Depends(get_hf_token),
):
- """Refused before the row opens, as on /audio/speech: a request rejected before work gets no error row"""
+ """OpenAI-compatible text-to-image (POST /v1/images/generations).
+
+ Generates ``n`` images from ``prompt`` on the loaded diffusion model and
+ returns them as URLs (default) or base64 PNGs per ``response_format``. Steps
+ and guidance have no OpenAI knob: the x-unsloth fields set them (and width, height,
+ seed, negative_prompt), else they default per loaded model.
+
+ With media auto-switch on, ``model`` names the image model to serve on and is loaded
+ when it is not the resident one; with it off ``model`` stays informational."""
if body.stream:
raise HTTPException(
status_code = 400,
diff --git a/studio/backend/tests/test_openapi_descriptions.py b/studio/backend/tests/test_openapi_descriptions.py
new file mode 100644
index 00000000000..7c5ddade450
--- /dev/null
+++ b/studio/backend/tests/test_openapi_descriptions.py
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import pytest
+
+
[email protected](scope = "module")
+def openapi():
+ import main
+ return main.app.openapi()
+
+
+ "path, method, phrase",
+ [
+ ("/api/auth/desktop-login", "post", "Exchange a local desktop secret"),
+ ("/v1/images/generations", "post", "OpenAI-compatible text-to-image"),
+ ("/api/inference/images/generations", "post", "OpenAI-compatible text-to-image"),
+ ("/api/health", "get", "Liveness plus launcher capability bits"),
+ ],
+)
+def test_route_description_states_the_contract(openapi, path, method, phrase):
+ assert phrase in openapi["paths"][path][method]["description"]
+
+
+def test_chat_completion_schema_description(openapi):
+ schema = openapi["components"]["schemas"]["ChatCompletionRequest"]
+ assert schema["description"].startswith("OpenAI-compatible chat completion request.")