[GH-ISSUE #5056] [TUI] Tuning fails with 401 "missing or wrong API key" when STRATA_API_KEY is set (env var overrides the key tuning generates) #2346

Closed
opened 2026-11-04 01:58:35 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @k-ichiro09 on GitHub (Nov 3, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5056

Area

Launch / Tuning

Desktop app, Terminal or source?

Terminal (Windows, installed with strata update)

Strata version

Engine 0.1.56 (windows-x86_64-cuda-cuda13), Control 0.1.56
(updated with strata update on 2026-11-03)

Graphics card, memory and system

  • GPU: 2x NVIDIA RTX PRO 4500 Blackwell (32 GB each, no NVLink), layer split (helper/main)
  • System RAM: 128 GB
  • OS: Windows 11 26H2
  • NVIDIA driver: 597.30 (CUDA driver 13.2)

Reproduction status

Always. It fails on every strata launch --preset "NVFP4 256K" --retune
while STRATA_API_KEY is set, and succeeds once the variable is removed.

What happened

strata launch --preset "NVFP4 256K" starts and serves normally, but the
tuning step always fails:

Tuning result: failed. Your current settings could not be measured: the
worker refused the request (401): {"error": {"type": "authentication_error",
"message": "missing or wrong API key"}} The standard settings run.

Only tuning is affected; normal serving works.

The cause was a Windows user environment variable STRATA_API_KEY that I
had set as the shared client key for several presets. After removing it,
tuning ran normally.

Setup

  • host 0.0.0.0, port 8081, preset JSON with an api_key
  • Windows environment variable STRATA_API_KEY set to my shared key

What did not help

  • Making the key in the preset (strata launch --show-key --preset ...) equal
    to the api_key in the preset JSON
  • --no-api-key and "api_key": "none"
  • strata update to 0.1.56

Cause (from reading serve/server.py in 0.1.56)

  • L9545: ap.add_argument("--api-key", default=os.environ.get("STRATA_API_KEY", ""), ...)
  • L9666: raw_key = a.api_key or cfg.get("api_key", "")

When STRATA_API_KEY is set, it is used instead of the api_key in the
config. Tuning generates a new random key for its temporary worker, but the
worker ends up using the environment key, so the key tuning sends does not
match and the worker answers 401. This explains why --no-api-key and
"api_key": "none" (both config-level values) had no effect either.

This is my reading of the code. I did not trace how tuning hands the
generated key to the worker, so that part may differ.

Why this is easy to hit

The docs use STRATA_API_KEY on both sides: the server reads it as the
environment form of --api-key, and the Terminal docs and the Codex CLI
example use it as the variable that holds the client's key (e.g.
env_key = "STRATA_API_KEY"). Setting it once for client use therefore
also changes what the server accepts.

  • #3851: reports that an inherited STRATA_API_KEY must not override the key
    in the run config, and that the packaged Control path deletes the variable
    from the server's environment. Tuning seems not to do the same.
  • #3198: the environment variable is described as one way to pick the key.

Suggested fix

  1. Remove STRATA_API_KEY from the environment of the worker that tuning
    starts (as Control already does), or pass the generated key explicitly
    as --api-key, which wins over the environment.
  2. When tuning gets a 401 and STRATA_API_KEY is set, say so in the
Originally created by @k-ichiro09 on GitHub (Nov 3, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/5056 ### Area Launch / Tuning ### Desktop app, Terminal or source? Terminal (Windows, installed with `strata update`) ### Strata version Engine 0.1.56 (windows-x86_64-cuda-cuda13), Control 0.1.56 (updated with `strata update` on 2026-11-03) ### Graphics card, memory and system - GPU: 2x NVIDIA RTX PRO 4500 Blackwell (32 GB each, no NVLink), layer split (helper/main) - System RAM: 128 GB - OS: Windows 11 26H2 - NVIDIA driver: 597.30 (CUDA driver 13.2) ### Reproduction status Always. It fails on every `strata launch --preset "NVFP4 256K" --retune` while `STRATA_API_KEY` is set, and succeeds once the variable is removed. ### What happened `strata launch --preset "NVFP4 256K"` starts and serves normally, but the tuning step always fails: Tuning result: failed. Your current settings could not be measured: the worker refused the request (401): {"error": {"type": "authentication_error", "message": "missing or wrong API key"}} The standard settings run. Only tuning is affected; normal serving works. The cause was a Windows user environment variable `STRATA_API_KEY` that I had set as the shared client key for several presets. After removing it, tuning ran normally. ### Setup - host 0.0.0.0, port 8081, preset JSON with an `api_key` - Windows environment variable `STRATA_API_KEY` set to my shared key ### What did not help - Making the key in the preset (`strata launch --show-key --preset ...`) equal to the `api_key` in the preset JSON - `--no-api-key` and `"api_key": "none"` - `strata update` to 0.1.56 ### Cause (from reading serve/server.py in 0.1.56) - L9545: `ap.add_argument("--api-key", default=os.environ.get("STRATA_API_KEY", ""), ...)` - L9666: `raw_key = a.api_key or cfg.get("api_key", "")` When `STRATA_API_KEY` is set, it is used instead of the `api_key` in the config. Tuning generates a new random key for its temporary worker, but the worker ends up using the environment key, so the key tuning sends does not match and the worker answers 401. This explains why `--no-api-key` and `"api_key": "none"` (both config-level values) had no effect either. This is my reading of the code. I did not trace how tuning hands the generated key to the worker, so that part may differ. ### Why this is easy to hit The docs use `STRATA_API_KEY` on both sides: the server reads it as the environment form of `--api-key`, and the Terminal docs and the Codex CLI example use it as the variable that holds the client's key (e.g. `env_key = "STRATA_API_KEY"`). Setting it once for client use therefore also changes what the server accepts. ### Related - #3851: reports that an inherited `STRATA_API_KEY` must not override the key in the run config, and that the packaged Control path deletes the variable from the server's environment. Tuning seems not to do the same. - #3198: the environment variable is described as one way to pick the key. ### Suggested fix 1. Remove `STRATA_API_KEY` from the environment of the worker that tuning starts (as Control already does), or pass the generated key explicitly as `--api-key`, which wins over the environment. 2. When tuning gets a 401 and `STRATA_API_KEY` is set, say so in the
Author
Owner

@github-actions[bot] commented on GitHub (Nov 3, 2026):

Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:

  • Fill in "Reproduction status".
  • Fill in "Strata version".
  • Fill in "Graphics card, memory and system".

Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment /reopen.

Details: CONTRIBUTING.md

<!-- gh-comment-id:6595752850 --> @github-actions[bot] commented on GitHub (Nov 3, 2026): Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing: - [ ] Fill in "Reproduction status". - [ ] Fill in "Strata version". - [ ] Fill in "Graphics card, memory and system". Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment `/reopen`. Details: [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md)
Author
Owner

@github-actions[bot] commented on GitHub (Nov 3, 2026):

Thanks, this follows the format now.

<!-- gh-comment-id:6595827568 --> @github-actions[bot] commented on GitHub (Nov 3, 2026): Thanks, this follows the format now.
Author
Owner

@Niko1221 commented on GitHub (Nov 5, 2026):

Hello k-ichiro09,

Thank you. In Strata 0.2.11 the tuning worker is started without STRATA_API_KEY, so the key tuning generates is the one the server uses, and the 401 is gone. The key is not put on the command line. A quick tune with a different key set in the environment ran without the 401 in our test. If tuning still answers 401 on 0.2.11, please tell us where the variable is set (system, shell or a profile).

The Strata project

<!-- gh-comment-id:6658442620 --> @Niko1221 commented on GitHub (Nov 5, 2026): Hello k-ichiro09, Thank you. In Strata 0.2.11 the tuning worker is started without `STRATA_API_KEY`, so the key tuning generates is the one the server uses, and the 401 is gone. The key is not put on the command line. A quick tune with a different key set in the environment ran without the 401 in our test. If tuning still answers 401 on 0.2.11, please tell us where the variable is set (system, shell or a profile). The Strata project
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2346
No description provided.