Repository navigation
Fix Claude Code gateway config helper - #1745
diegosouzapw merged 2 commits into
Conversation
…nference#1726) Integrated into release/v3.7.4
There was a problem hiding this comment.
Code Review
This pull request updates the configuration for Claude Code and Anthropic tools to use a unified root endpoint (removing the forced /v1 suffix) and transitions from ANTHROPIC_API_KEY to ANTHROPIC_AUTH_TOKEN. It introduces helper functions for URL normalization and credential retrieval, along with corresponding unit tests. Feedback focuses on improving TypeScript type safety by replacing any and implicit types with Record<string, string> and using bracket notation for dynamic property access.
| ? "sk_omniroute" | ||
| : "<API_KEY_FROM_DASHBOARD>"; | ||
| const env = { ANTHROPIC_BASE_URL: getEffectiveBaseUrl(), ANTHROPIC_AUTH_TOKEN: keyToUse }; | ||
| const env = { ANTHROPIC_BASE_URL: getEffectiveBaseUrl() }; |
There was a problem hiding this comment.
The env object is implicitly typed as { ANTHROPIC_BASE_URL: string }, which will cause TypeScript errors when attempting to add the ANTHROPIC_AUTH_TOKEN property or other dynamic keys from tool.defaultModels. Explicitly typing it as Record<string, string> resolves this.
| const env = { ANTHROPIC_BASE_URL: getEffectiveBaseUrl() }; | |
| const env: Record<string, string> = { ANTHROPIC_BASE_URL: getEffectiveBaseUrl() }; |
| ): string | null { | ||
| if (!env || typeof env !== "object") return null; | ||
|
|
||
| const authValue = env.ANTHROPIC_AUTH_TOKEN ?? env.ANTHROPIC_API_KEY; |
There was a problem hiding this comment.
TypeScript does not allow property access via dot notation on types with a string index signature like Record<string, unknown>. Use bracket notation to access these properties.
| const authValue = env.ANTHROPIC_AUTH_TOKEN ?? env.ANTHROPIC_API_KEY; | |
| const authValue = env['ANTHROPIC_AUTH_TOKEN'] ?? env['ANTHROPIC_API_KEY']; |
| @@ -139,13 +143,9 @@ export default function ClaudeToolCard({ | |||
| const env: any = { ANTHROPIC_BASE_URL: getEffectiveBaseUrl() }; | |||
There was a problem hiding this comment.
Using any bypasses TypeScript's type checking. Since this object is intended to store environment variable mappings (strings), it should be typed as Record<string, string>.
| const env: any = { ANTHROPIC_BASE_URL: getEffectiveBaseUrl() }; | |
| const env: Record<string, string> = { ANTHROPIC_BASE_URL: getEffectiveBaseUrl() }; |
99513fd
into
cheaper-inference:release/v3.7.4
|
Thanks for this great contribution! 🎉 It's now officially merged into the release/v3.7.4 branch and will be part of the next release. We appreciate your effort! |
* chore(release): v3.7.4 — version bump, openapi and changelog sync * fix: preserve previous_response_id and conversation_id fields on empty input array (#1729) * fix: bypass UI validation block for optional API keys and fix string fallback typing (#1721) * fix(proxy): disable HTTP keep-alive and pipelining in Undici proxy dispatcher to prevent socket hang up * feat(proxy): implement bulk proxy import via pipe-delimited parser with update-or-create logic * docs: update changelog for v3.7.4 fixes and proxy features * test: update responses store expectations for empty input arrays * feat(pwa): add fullscreen installable PWA with manifest, service worker, and cross-platform app icons. (#1728) Integrated into release/v3.7.4 * Fix image provider validation and Stability image requests (#1726) Integrated into release/v3.7.4 * docs: add PR 1726 and PR 1728 to v3.7.4 changelog * fix(security): replace insecure Math.random with crypto.getRandomValues for fallback UUID generation * fix(migrations): intercept 007 migration to use IF NOT EXISTS logic on fresh installs Fixes #1733 * test: fix typescript compilation errors in unit tests * fix(db): reconcile legacy reasoning cache migration * chore(release): bump to v3.7.4 — changelog, docs, version sync * fix(cc-compatible): preserve Claude Code system skeleton (#1740) Integrated into release/v3.7.4 * docs(changelog): update for PR #1740 merge * docs(changelog): include workflow updates * fix(db): reconcile legacy reasoning cache migration (#1734) Integrated into release/v3.7.4 * Add endpoint tunnel visibility settings (#1743) Integrated into release/v3.7.4 * Normalize max reasoning effort for Codex routing (#1744) Integrated into release/v3.7.4 * Fix Claude Code gateway config helper (#1745) Integrated into release/v3.7.4 * Refresh CLI fingerprint provider profiles (#1746) Integrated into release/v3.7.4 * Integrated into release/v3.7.4 (PR #1742) * docs(changelog): update for PRs 1742-1746 --------- Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com> Co-authored-by: Yash Ghule <y.ghule77@gmail.com> Co-authored-by: backryun <bakryun0718@proton.me> Co-authored-by: dhaern <manker_lol@hotmail.com> Co-authored-by: Randi <55005611+rdself@users.noreply.github.com> Co-authored-by: Duncan L <leungd@gmail.com>
* chore(release): v3.7.4 — version bump, openapi and changelog sync * fix: preserve previous_response_id and conversation_id fields on empty input array (cheaper-inference#1729) * fix: bypass UI validation block for optional API keys and fix string fallback typing (cheaper-inference#1721) * fix(proxy): disable HTTP keep-alive and pipelining in Undici proxy dispatcher to prevent socket hang up * feat(proxy): implement bulk proxy import via pipe-delimited parser with update-or-create logic * docs: update changelog for v3.7.4 fixes and proxy features * test: update responses store expectations for empty input arrays * feat(pwa): add fullscreen installable PWA with manifest, service worker, and cross-platform app icons. (cheaper-inference#1728) Integrated into release/v3.7.4 * Fix image provider validation and Stability image requests (cheaper-inference#1726) Integrated into release/v3.7.4 * docs: add PR 1726 and PR 1728 to v3.7.4 changelog * fix(security): replace insecure Math.random with crypto.getRandomValues for fallback UUID generation * fix(migrations): intercept 007 migration to use IF NOT EXISTS logic on fresh installs Fixes cheaper-inference#1733 * test: fix typescript compilation errors in unit tests * fix(db): reconcile legacy reasoning cache migration * chore(release): bump to v3.7.4 — changelog, docs, version sync * fix(cc-compatible): preserve Claude Code system skeleton (cheaper-inference#1740) Integrated into release/v3.7.4 * docs(changelog): update for PR cheaper-inference#1740 merge * docs(changelog): include workflow updates * fix(db): reconcile legacy reasoning cache migration (cheaper-inference#1734) Integrated into release/v3.7.4 * Add endpoint tunnel visibility settings (cheaper-inference#1743) Integrated into release/v3.7.4 * Normalize max reasoning effort for Codex routing (cheaper-inference#1744) Integrated into release/v3.7.4 * Fix Claude Code gateway config helper (cheaper-inference#1745) Integrated into release/v3.7.4 * Refresh CLI fingerprint provider profiles (cheaper-inference#1746) Integrated into release/v3.7.4 * Integrated into release/v3.7.4 (PR cheaper-inference#1742) * docs(changelog): update for PRs 1742-1746 --------- Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com> Co-authored-by: Yash Ghule <y.ghule77@gmail.com> Co-authored-by: backryun <bakryun0718@proton.me> Co-authored-by: dhaern <manker_lol@hotmail.com> Co-authored-by: Randi <55005611+rdself@users.noreply.github.com> Co-authored-by: Duncan L <leungd@gmail.com>
* chore(release): v3.7.4 — version bump, openapi and changelog sync * fix: preserve previous_response_id and conversation_id fields on empty input array (cheaper-inference#1729) * fix: bypass UI validation block for optional API keys and fix string fallback typing (cheaper-inference#1721) * fix(proxy): disable HTTP keep-alive and pipelining in Undici proxy dispatcher to prevent socket hang up * feat(proxy): implement bulk proxy import via pipe-delimited parser with update-or-create logic * docs: update changelog for v3.7.4 fixes and proxy features * test: update responses store expectations for empty input arrays * feat(pwa): add fullscreen installable PWA with manifest, service worker, and cross-platform app icons. (cheaper-inference#1728) Integrated into release/v3.7.4 * Fix image provider validation and Stability image requests (cheaper-inference#1726) Integrated into release/v3.7.4 * docs: add PR 1726 and PR 1728 to v3.7.4 changelog * fix(security): replace insecure Math.random with crypto.getRandomValues for fallback UUID generation * fix(migrations): intercept 007 migration to use IF NOT EXISTS logic on fresh installs Fixes cheaper-inference#1733 * test: fix typescript compilation errors in unit tests * fix(db): reconcile legacy reasoning cache migration * chore(release): bump to v3.7.4 — changelog, docs, version sync * fix(cc-compatible): preserve Claude Code system skeleton (cheaper-inference#1740) Integrated into release/v3.7.4 * docs(changelog): update for PR cheaper-inference#1740 merge * docs(changelog): include workflow updates * fix(db): reconcile legacy reasoning cache migration (cheaper-inference#1734) Integrated into release/v3.7.4 * Add endpoint tunnel visibility settings (cheaper-inference#1743) Integrated into release/v3.7.4 * Normalize max reasoning effort for Codex routing (cheaper-inference#1744) Integrated into release/v3.7.4 * Fix Claude Code gateway config helper (cheaper-inference#1745) Integrated into release/v3.7.4 * Refresh CLI fingerprint provider profiles (cheaper-inference#1746) Integrated into release/v3.7.4 * Integrated into release/v3.7.4 (PR cheaper-inference#1742) * docs(changelog): update for PRs 1742-1746 --------- Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com> Co-authored-by: Yash Ghule <y.ghule77@gmail.com> Co-authored-by: backryun <bakryun0718@proton.me> Co-authored-by: dhaern <manker_lol@hotmail.com> Co-authored-by: Randi <55005611+rdself@users.noreply.github.com> Co-authored-by: Duncan L <leungd@gmail.com>
Integrated into release/v3.7.4
* chore(release): v3.7.4 — version bump, openapi and changelog sync * fix: preserve previous_response_id and conversation_id fields on empty input array (cheaper-inference#1729) * fix: bypass UI validation block for optional API keys and fix string fallback typing (cheaper-inference#1721) * fix(proxy): disable HTTP keep-alive and pipelining in Undici proxy dispatcher to prevent socket hang up * feat(proxy): implement bulk proxy import via pipe-delimited parser with update-or-create logic * docs: update changelog for v3.7.4 fixes and proxy features * test: update responses store expectations for empty input arrays * feat(pwa): add fullscreen installable PWA with manifest, service worker, and cross-platform app icons. (cheaper-inference#1728) Integrated into release/v3.7.4 * Fix image provider validation and Stability image requests (cheaper-inference#1726) Integrated into release/v3.7.4 * docs: add PR 1726 and PR 1728 to v3.7.4 changelog * fix(security): replace insecure Math.random with crypto.getRandomValues for fallback UUID generation * fix(migrations): intercept 007 migration to use IF NOT EXISTS logic on fresh installs Fixes cheaper-inference#1733 * test: fix typescript compilation errors in unit tests * fix(db): reconcile legacy reasoning cache migration * chore(release): bump to v3.7.4 — changelog, docs, version sync * fix(cc-compatible): preserve Claude Code system skeleton (cheaper-inference#1740) Integrated into release/v3.7.4 * docs(changelog): update for PR cheaper-inference#1740 merge * docs(changelog): include workflow updates * fix(db): reconcile legacy reasoning cache migration (cheaper-inference#1734) Integrated into release/v3.7.4 * Add endpoint tunnel visibility settings (cheaper-inference#1743) Integrated into release/v3.7.4 * Normalize max reasoning effort for Codex routing (cheaper-inference#1744) Integrated into release/v3.7.4 * Fix Claude Code gateway config helper (cheaper-inference#1745) Integrated into release/v3.7.4 * Refresh CLI fingerprint provider profiles (cheaper-inference#1746) Integrated into release/v3.7.4 * Integrated into release/v3.7.4 (PR cheaper-inference#1742) * docs(changelog): update for PRs 1742-1746 --------- Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com> Co-authored-by: Yash Ghule <y.ghule77@gmail.com> Co-authored-by: backryun <bakryun0718@proton.me> Co-authored-by: dhaern <manker_lol@hotmail.com> Co-authored-by: Randi <55005611+rdself@users.noreply.github.com> Co-authored-by: Duncan L <leungd@gmail.com>
Summary
/v1onto Claude Code gateway base URLssk_omnirouteas a fake Claude auth token fallbackWhy
Claude Code gateway mode expects the unified Anthropic-compatible root URL, while OmniRoute's dashboard helper and docs were still generating
/v1Claude base URLs. The helper was also persistingsk_omnirouteintoANTHROPIC_AUTH_TOKENfor local installs without a selected key, which produces an invalid bearer token instead of allowing anonymous local access.This is a follow-up to #1744. That PR fixes the Codex runtime routing bug (
max->xhigh). This PR fixes the Claude Code setup path so the dashboard/docs generate a working gateway config in the first place.Testing
npx --yes tsx --test tests/unit/claude-cli-config.test.ts