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.
This commit is contained in:
parent
5cedd9a5b2
commit
d388807ccb
1 changed files with 21 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue