Skip to content

Claude Code ​

MUSCLE Flex by Adhibita serves the Anthropic Messages shape that Claude Code sends. Claude Code still runs its tools, file edits and approvals on your machine. Flex receives the model requests and routes each one.

Before you start ​

You need:

  • an accepted MUSCLE Flex invitation and a funded service balance;
  • a Flex API key, created on the API keys page of the portal;
  • the Flex base URL from your invitation. This page writes it as <FLEX_BASE_URL>: the scheme and host only, without a trailing /v1.

The key check below reads both values from your shell:

bash
export FLEX_BASE_URL="<FLEX_BASE_URL>"
export MUSCLE_FLEX_API_KEY="<FLEX_API_KEY>"

Configure muscle/auto as the model id; auto is accepted as a short form of it. Flex chooses the route for each request, so the model field does not select a model. The model names that compatible clients send on their own are routed the same way. See The model id.

Check that Claude Code is installed with claude --version.

Configure ​

Set these in the shell that launches Claude Code:

bash
unset ANTHROPIC_API_KEY
export ANTHROPIC_BASE_URL="$FLEX_BASE_URL"
export ANTHROPIC_AUTH_TOKEN="$MUSCLE_FLEX_API_KEY"
export ANTHROPIC_MODEL="muscle/auto"
export ANTHROPIC_SMALL_FAST_MODEL="muscle/auto"
claude

What each line does:

  • ANTHROPIC_BASE_URL takes the host only. Claude Code appends /v1/messages itself, so a trailing /v1 would double the path.
  • ANTHROPIC_AUTH_TOKEN sends the Flex key as a bearer token. Flex accepts bearer auth on Messages.
  • unset ANTHROPIC_API_KEY stops Claude Code from sending a second, conflicting credential.
  • ANTHROPIC_MODEL sets muscle/auto for the main loop. ANTHROPIC_SMALL_FAST_MODEL does the same for the short background requests Claude Code makes. Some releases read a different variable for those requests. They still go to Flex and are routed and charged like any other request.

Do not turn on Claude Code's gateway model discovery. Its picker only lists model ids in Claude Code's own naming scheme, so muscle/auto would not appear there. ANTHROPIC_MODEL sets it directly.

Choose a profile ​

muscle/auto uses your workspace's default profile (balanced unless it was set otherwise). To pick the cost/quality trade-off for a session, set the model to a profile id instead:

bash
export ANTHROPIC_MODEL="muscle/max"        # favour quality
# export ANTHROPIC_MODEL="muscle/budget"   # favour cost
# export ANTHROPIC_MODEL="muscle/balanced"

You can switch inside a session with /model muscle/max. Keep ANTHROPIC_SMALL_FAST_MODEL on muscle/auto or muscle/budget so background requests stay cheap. To set the profile without changing the model name, add a request header through Claude Code's ANTHROPIC_CUSTOM_HEADERS setting, for example x-flex-profile: max. The header wins over the model id when both are set. The verified setup above uses muscle/auto; the profile ids and the header route the same way but are not part of that verification run. See Routing profile.

Keep the setting for one project ​

To avoid exporting variables in every shell, put the same values in the env block of .claude/settings.local.json in the project:

json
{
  "env": {
    "ANTHROPIC_BASE_URL": "<FLEX_BASE_URL>",
    "ANTHROPIC_AUTH_TOKEN": "<FLEX_API_KEY>",
    "ANTHROPIC_MODEL": "muscle/auto",
    "ANTHROPIC_SMALL_FAST_MODEL": "muscle/auto"
  }
}

That file now holds your key. Keep it out of version control, and still unset ANTHROPIC_API_KEY in your shell.

Verify ​

1. Check the key ​

This read-only call confirms the base URL and the key before you change the agent:

bash
curl -i "$FLEX_BASE_URL/v1/account" \
  -H "Authorization: Bearer $MUSCLE_FLEX_API_KEY"

A 200 response returns your account summary, including available credits. A 401 means the key is missing, mistyped or revoked.

Every Flex response carries an X-Request-Id header. Keep it when you contact support: it is how a single request is found.

2. Run one tool call ​

Open a small project, start claude and ask:

text
List the files in this folder, then read the README and summarize it in one sentence.

Claude Code should ask to use its file tools, run them, and answer from the file. That exercises authentication, streaming, one tool call and its result on the way back.

Troubleshooting ​

  • Requests go somewhere else. The variables were set in a different shell, or a settings file overrides them. Restart Claude Code after any change.
  • An authentication conflict or 401. Make sure ANTHROPIC_API_KEY is unset and ANTHROPIC_AUTH_TOKEN holds the Flex key.
  • Your release rejects muscle/auto as a model name. Note the output of claude --version and contact support. Do not substitute another model name.
  • A web search step fails. Hosted web search is not part of the beta. Deny the tool for the session with claude --disallowedTools WebSearch.
  • A request fails with 400 unsupported_content. Flex does not support image input yet. Any image in the conversation fails the request: one pasted into the prompt, or one a tool returns, such as a screenshot or a PNG file Claude Code reads. Every later request in that conversation fails too, because it still carries the image, until you start a new one, for example with /clear. Avoid asking Claude Code to read image files. See Images and audio.

Responses you may see ​

StatusMeaningWhat to do
401The key is missing, mistyped or revoked.Check where the agent reads the key from. Create a new key in the portal if needed.
402Your balance or spend cap does not cover the request.Add credits, then retry.
403The account is suspended, or the request is not allowed.Contact support with the X-Request-Id.
404 model_not_foundThe agent sent a model id that Flex does not accept.Set the agent's model to muscle/auto. Retrying unchanged fails again.
429A rate limit was reached.Wait for the number of seconds in Retry-After (a few seconds when it is absent), then retry.
400 unsupported_fieldThe agent sent a field or tool that Flex does not offer yet.Find the field in the compatibility matrix and turn that option off.
400 unsupported_contentThe conversation carries an image or audio part, which Flex does not support yet.Start a new conversation without the image, and turn off the agent's image input.
502, 503 or 504No eligible route could serve the request at that moment, or it timed out.Retry later. If it persists, contact support with the X-Request-Id.
503 feature_unavailableNo route offers what the request needs, or the conversation is too long for every route.Start a new conversation or lower the agent's output limit. Retrying unchanged fails again.

The API reference describes each error code and what to do about it.

Agents rarely show response headers. When a request fails inside an agent, note the time, the agent version and the error text for support.

The model frontier, through one adaptive API.