From d388807ccb5eada78c6f6429359e4e8ccb72018c Mon Sep 17 00:00:00 2001 From: Roland Tannous Date: Mon, 13 Apr 2026 14:02:55 +0400 Subject: [PATCH] Expand unsloth studio run banner with SDK base URL and more curl examples Add an explicit "OpenAI / Anthropic SDK base URL" line inside the info box so SDK users don't accidentally copy the bare server URL (without /v1) into their OpenAI/Anthropic SDK constructors and hit 404s. Replace the single /v1/chat/completions curl example with three labeled blocks: chat/completions, Anthropic /messages, and OpenAI Responses. The Anthropic example includes max_tokens (Anthropic SDKs require it even though Studio accepts None). All examples derived from a computed sdk_base_url so the /v1 prefix stays in sync if the public path ever changes. --- unsloth_cli/commands/studio.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/unsloth_cli/commands/studio.py b/unsloth_cli/commands/studio.py index 3c01a21941..a3c0840be1 100644 --- a/unsloth_cli/commands/studio.py +++ b/unsloth_cli/commands/studio.py @@ -357,6 +357,7 @@ def run( # ── 6. Print banner ─────────────────────────────────────────────── display_host = _resolve_external_ip() if host == "0.0.0.0" else host base_url = f"http://{display_host}:{actual_port}" + sdk_base_url = f"{base_url}/v1" if not silent: typer.echo("") @@ -364,16 +365,33 @@ def run( typer.echo(f" Unsloth Studio running at {base_url}") typer.echo(f" Model loaded: {loaded_model}{display_variant}") typer.echo(f" API Key: {api_key}") + typer.echo("") + typer.echo(" OpenAI / Anthropic SDK base URL:") + typer.echo(f" {sdk_base_url}") typer.echo("=" * 56) typer.echo("") - typer.echo("Usage:") - typer.echo(f" curl {base_url}/v1/chat/completions \\") + typer.echo("OpenAI Chat Completions:") + typer.echo(f" curl {sdk_base_url}/chat/completions \\") typer.echo(f' -H "Authorization: Bearer {api_key}" \\') - typer.echo(f' -H "Content-Type: application/json" \\') + typer.echo(' -H "Content-Type: application/json" \\') typer.echo( """ -d '{"messages": [{"role": "user", "content": "Hello"}], "stream": true}'""" ) typer.echo("") + typer.echo("Anthropic Messages:") + typer.echo(f" curl {sdk_base_url}/messages \\") + typer.echo(f' -H "Authorization: Bearer {api_key}" \\') + typer.echo(' -H "Content-Type: application/json" \\') + typer.echo( + """ -d '{"max_tokens": 256, "messages": [{"role": "user", "content": "Hello"}], "stream": true}'""" + ) + typer.echo("") + typer.echo("OpenAI Responses:") + typer.echo(f" curl {sdk_base_url}/responses \\") + typer.echo(f' -H "Authorization: Bearer {api_key}" \\') + typer.echo(' -H "Content-Type: application/json" \\') + typer.echo(""" -d '{"input": "Hello", "stream": true}'""") + typer.echo("") # ── 7. Wait for Ctrl+C ──────────────────────────────────────────── from studio.backend.run import _shutdown_event, _graceful_shutdown, _server