Skip to content

[Bug] Unsloth Studio: Claude Code fails with 401 despite following docs and having a valid key #8663

Closed

Description

@hippalectryon-0

Claude Code (Anthropic's official CLI) sends its API key via the x-api-key header, following the standard Anthropic API convention. Unsloth's API endpoint appears to only accept Authorization: Bearer sk-unsloth-…, causing every request to fail with 401 Not authenticated.

The API key and servers are working fine:

❯ curl http://localhost:9090/v1/messages \
  -H "Authorization: Bearer sk-unsloth-..." \
  -H "Content-Type: application/json" \
  -d '{"model":"unsloth/Ornith-1.0-35B-GGUF:UD-Q4_K_M","max_tokens":16,"messages":[{"role":"user","content":"hi"}]}'
{"id":"msg_60b2d66b5c054e0c85580578","type":"message","role":"assistant","content":[{"type":"text","text":"<think>Here's a thinking process:\n\n1.  **Analyze User Input:**</think>"}],"model":"unsloth/Ornith-1.0-35B-GGUF","stop_reason":"max_tokens","stop_sequence":null,"usage":{"input_tokens":11,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":16}}    

However, as per the docs:

❯ ANTHROPIC_BASE_URL="http://localhost:9090" ANTHROPIC_API_KEY="sk-unsloth-xxx" ANTHROPIC_MODEL="unsloth/Ornith-1.0-35B-GGUF:UD-Q4_K_M" claude
# 401
# {"timestamp": "2026-08-13T09:10:47.062433Z", "level": "info", "event": "request_completed", "method": "POST", "path": "/v1/messages", "status_code": 401, "process_time_ms": 4.32}

Note: the docs do mention Copy your key from Unsloth Studio → Settings → API (or from the console when you start it with) unsloth run, where it is printed as sk-unsloth-...), then set it up. but never actually describe what "set it up" means. Is there a missing step ?

Activity

  1. Lyxot commented on Aug 13, 2026

    @Lyxot
    Collaborator

    Sorry this is a mistake in our docs. You should set your API key with ANTHROPIC_AUTH_TOKEN, and leave ANTHROPIC_API_KEY empty.

    Also, we have a automatic command to launch Claude Code with local models. You can try it. See docs

  2. hippalectryon-0 commented on Aug 13, 2026

    @hippalectryon-0
    Author

    Also, we have a automatic command to launch Claude Code with local models. You can try it. See docs

    Afaik this will only work if unsloth studio is running on the same machine as claude code. It will not work in my case, where it's on machine A but is being used by machine B over the network.

    You should set your API key with ANTHROPIC_AUTH_TOKEN

    Thank you, I can confirm this works fine. Keeping the issue open since the docs are still incomplete.

  3. Lyxot commented on Aug 13, 2026

    @Lyxot
    Collaborator

    where it's on machine A but is being used by machine B over the network.

    Actually you can. See docs

  4. Lyxot commented on Aug 13, 2026

    @Lyxot
    Collaborator

    Docs are updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions