Repository navigation
Chief: run DeepInfra models with your own API key - #21280
austinywang wants to merge 24 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Chief gains a DeepInfra harness: Claude Code against DeepInfra's Anthropic-compatible API, with DeepSeek V4 Pro (default), Kimi K3, GLM-5.3 and DeepSeek V4 Flash in the model picker. The key is saved from Chief Settings or Settings > Automation into its own 0600 secret file (chief.deepInfraAPIKey, never cmux.json), falling back to DEEPINFRA_API_KEY. Saving or removing it installs a new brain for the next turn. The app's Anthropic credentials, custom headers and Bedrock/Vertex switches are stripped before claude starts, so they never reach DeepInfra. A missing or rejected key fails the turn with a pointer to Chief Settings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This comment has been minimized.
This comment has been minimized.
|
Passes: CI passes on CI passes on Written by |
|
|
Dogfood tours of
|
… env Review found that Chief's `claude` reads ~/.claude/settings.json as project settings (cwd is the home folder), and a settings `env` block replaces the process environment: a local repro sent the settings' Anthropic key and token to the settings' URL instead of the endpoint. The endpoint now reaches Claude Code through `--settings`, which outranks project settings: base URL, model slots, and blanked Anthropic credentials and provider switches. The JSON carries no secret; an apiKeyHelper reads the saved 0600 key file (else DEEPINFRA_API_KEY), so the key is never in argv, in this process's configuration, or in the environment the model's tools inherit. The key is read when claude starts, which also removes the race where a turn right after launch missed a saved key. Anthropic variables are stripped by prefix (ANTHROPIC_*, CLAUDE_CODE_USE_*, CLAUDE_CODE_*_TOKEN/_FILE_DESCRIPTOR). Also: a failed removal says so, the Settings subtitle mentions the DEEPINFRA_API_KEY fallback, and the key rows keep their spacing when Remove Key is hidden. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Correctness review (subagent), findings and resolution
Pre-existing failures on base #21063 (same on its own CI run 38845456157), not from this PR: |
The schema guard assumed every SecretFileKey id is a cmux.json path. The DeepInfra key is entered only in Settings and never read from cmux.json, so it is listed as an explicit exception instead of being advertised in the schema. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
CI on ca4ac5f: every DeepInfra and catalog test passed in the |
The ternary between a closure literal and a function reference did not type-check in CI's Swift toolchain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
CI on 8f27031: on ca4ac5f/e93fc7c, |
…to chief-deepinfra-byok
…to chief-deepinfra-byok
…to chief-deepinfra-byok
…to chief-deepinfra-byok
Claude Code retries a 401 up to ten times with growing delays, so a Chief turn with a bad key spins for minutes before it fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude Code reports each 401 retry as a system api_retry line. For a model endpoint, stop claude there and show the invalid-key message. Claude Code's own sign-in keeps its retries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…to chief-deepinfra-byok
A 403 can mean balance or model access, not a bad key. The turn test now ignores the session event that precedes the failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
A rejected key failed slowly; fixed and reviewed A dry run of the real
A correctness-first review subagent made three findings, all fixed in 2cbc644:
The reviewer also confirmed: subagent retry lines are ignored, The live check against DeepInfra with a fake key reached the endpoint and got |
|
Dogfood: tagged build Fleet job ca0bf24b2aa4aba5626232a6 built and published the app. I drove Chief through the tagged app's own socket (
Not verified yet: a turn with a real key, which is waiting on a key. Settings UI automation also didn't run, because computer use isn't set up on this Mac, so the Settings key field hasn't been driven by automation. |
…to chief-deepinfra-byok
Diagnostic only, to find the CmuxHomeCore signal 11 on CI virtual Macs. Drop before merge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This reverts commit f2f98b2.
…to chief-deepinfra-byok
Diagnostic only, for the signal 11 on CI's macOS 15 VMs. Drop before merge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…to chief-deepinfra-byok # Conflicts: # Packages/Shared/CmuxHomeCore/Tests/CmuxHomeCoreTests/AttachmentTests.swift
…to chief-deepinfra-byok
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…to chief-deepinfra-byok
…to chief-deepinfra-byok
…to chief-deepinfra-byok
|
For awareness: #27058 (NEXT app) offers "Add API Key…" and "Add Credits…" when a model can't be used. Add API Key… opens Settings > Accounts at the provider's key field, which stores the key in the Mac Keychain; Add Credits… uses the existing paid-plan Checkout. It touches none of this PR's files (classic Chief, DeepInfra key). If NEXT later gets a DeepInfra provider in Accounts, the same Add API Key… row can open it. |
Stacked on #21063 (Chief). This targets that branch, not
main.Summary
Chief could only run Anthropic models through Claude Code or OpenAI models through Codex. This PR adds a DeepInfra harness, so you can pick open models from Chief Settings and pay DeepInfra with your own key:
How it works: DeepInfra serves an Anthropic-compatible Messages API at
https://api.deepinfra.com/anthropic. The DeepInfra harness is the existingClaudeCodeBrainwith a newChiefModelEndpoint:--settings. Flag settings outrank the project settings that Chief'sclaudeloads from its working directory, which is~/.claude/settings.jsonwhen Chief runs from the home folder. The JSON:apiKeyHelperreads the saved key file, falling back toDEEPINFRA_API_KEY, so the key is never in argv, in the app's configuration, or in the environment the model's tools inherit.ANTHROPIC_*,CLAUDE_CODE_USE_*and Claude Code token/descriptor variables are removed fromclaude's environment.chief.deepInfraAPIKeySecretFileKey, the same 0600 secret-file store as the socket password, never cmux.json. You can enter it in two places:authentication_error, DeepInfra's 401) and an unknown model both name DeepInfra.This is milestone 1, bring-your-own-key. Milestone 2 is usage credits included with cmux plans, with paid top-ups, through coderouter. It only changes the endpoint's base URL and token, so this harness and UI carry over.
Testing
ChiefDeepInfraTestsand DeepInfra rows inChiefModelCatalogTests. They cover:descriptionordebugDescription;1995a0c) comes before the fix. The red run was not executed: the build hostcmux-lawrence-2does not resolve from this Mac (REPAIR.md row fornx-remote), and localswift testis off-limits by policy. Red holds by construction, since the tests referenceChiefModelEndpoint,.deepInfraandmissingCredential, which do not exist before the fix. Green is theCmuxChiefpackage-test lane on this PR.python3 scripts/verify-local.py --affected <base> --swift-changed <base>passed 10/10. That covers Swift syntax, xcstrings, localization parity and defaults, pbxproj, the embedded config schema, app-source wiring, test wiring, package groups and feature flags.claude2.1.302 binary, with local listeners and project settings that set a different base URL, an Anthropic key, a token and anapiKeyHelper. With this PR's--settingsshape, only the endpoint is contacted, and both auth headers carry only the key from the file (whose path contains a space). Without it, the settings' URL and credentials win. See the review comment.401 {"type":"error","error":{"type":"authentication_error",…}}, which the rejected-key mapping matches.Localization audit: 15 new keys, each translated into all 9 macOS locales. The two interpolated
chief.brain.*strings were added by hand with%@.DeepInfra, the harness name, has an identity-locale record like the Claude Code and Codex names.localization_catalog.py checkreports 0 parity errors.Changelog
Added: Chief can run DeepInfra models (DeepSeek, Kimi, GLM) with your own DeepInfra API key, set in Chief Settings
Proof
No screenshot yet. It will be attached after the tagged-build dogfood with a real key.
Checklist
🤖 Generated with Claude Code