Skip to content

[codex] Fix bearer auth for remote Anthropic proxies#122

Draft
zangqing828-ux wants to merge 1 commit intoOpenCoworkAI:mainfrom
zangqing828-ux:codex/fix-anthropic-proxy-bearer-auth
Draft

[codex] Fix bearer auth for remote Anthropic proxies#122
zangqing828-ux wants to merge 1 commit intoOpenCoworkAI:mainfrom
zangqing828-ux:codex/fix-anthropic-proxy-bearer-auth

Conversation

@zangqing828-ux
Copy link
Copy Markdown

What changed

This fixes Claude/Anthropic-compatible remote gateways that require Authorization: Bearer <token> even though they still speak the Anthropic API shape.

The patch adds a shared auth-header helper and uses it in:

  • desktop connection testing
  • provider validation
  • runtime generation calls

For Anthropic wire requests against non-local, non-official hosts, Open CoDesign now sends both:

  • x-api-key: <token>
  • Authorization: Bearer <token>

Local Anthropic proxies and the official Anthropic endpoint stay on the existing behavior.

Root cause

Claude Code import preserved the Anthropic wire and remote base URL correctly, but runtime/auth header construction only emitted x-api-key for Anthropic requests. Some remote gateways accept Anthropic request/response shape while authenticating with Bearer tokens, which caused generation to fail with errors like 401 token not found.

Validation

  • corepack pnpm --filter @open-codesign/providers test
  • corepack pnpm --filter @open-codesign/desktop test -- --run src/main/connection-ipc.test.ts
  • corepack pnpm typecheck
  • corepack pnpm lint
  • repo pre-commit hook: turbo run test
  • repo pre-push hook: typecheck + lint

Signed-off-by: zangqing828-ux <zangqing828@gmail.com>
@hqhq1025 hqhq1025 closed this Apr 23, 2026
@hqhq1025 hqhq1025 reopened this Apr 23, 2026
@github-actions github-actions Bot added area:desktop apps/desktop (Electron shell, renderer) area:providers packages/providers (pi-ai adapter, model calls) labels Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:desktop apps/desktop (Electron shell, renderer) area:providers packages/providers (pi-ai adapter, model calls)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants