Skip to content

feat: relay account support with multi-format direct proxy#109

Open
icebear0828 wants to merge 1 commit intomasterfrom
feat/relay-accounts
Open

feat: relay account support with multi-format direct proxy#109
icebear0828 wants to merge 1 commit intomasterfrom
feat/relay-accounts

Conversation

@icebear0828
Copy link
Owner

Summary

Closes #105

  • Relay accounts: support third-party relay services via API Key + Base URL, with type: "native" | "relay" discriminator on AccountEntry
  • Format-aware direct proxy: relay accounts can specify format (codex/openai/anthropic/gemini). Non-codex formats bypass Codex translation — requests forward directly to the relay, responses pipe back as-is
  • Account pool integration: relay accounts participate in the same rotation pool, with allowedModels filtering and format-preference in acquire()
  • Dashboard UI: Relay button in header, AddRelayAccount form (label, baseUrl, apiKey, format dropdown, allowedModels), grouped account list (ChatGPT / Relay sections), format badge on AccountCard

Key changes

Area Files What
Data model src/auth/types.ts AccountType, RelayFormat, new fields on Entry/Info/Acquired
Account pool src/auth/account-pool.ts addRelayAccount(), format-aware acquire(), JWT/quota skip, backfill
Codex API client src/proxy/codex-api.ts baseUrlOverride, relay mode (simple Bearer, no fingerprint)
Direct proxy src/routes/shared/direct-proxy.ts New — stream pipe / simplePost for non-codex relays
Route handlers chat.ts, messages.ts, gemini.ts Try format-matching relay before Codex translation
Schedulers refresh-scheduler.ts, usage-refresher.ts Skip relay accounts
Frontend AddRelayAccount.tsx, AccountCard.tsx, AccountList.tsx, Header.tsx Relay form, grouped list, format display

Test plan

  • 45 new unit tests across 5 files (903 total, all passing)
  • E2E: add openai-format relay → /v1/chat/completions routes to relay (verified via httpbin echo)
  • E2E: delete relay → same request falls back to native Codex translation
  • E2E: codex-format relay does NOT intercept OpenAI route (stays on Codex path)
  • E2E: backfill — existing accounts get type=native, format=null after restart

Support third-party relay services via API Key + Base URL, with format-aware
direct proxy that bypasses Codex translation for OpenAI/Anthropic/Gemini
compatible relays.

- AccountEntry: type (native|relay), baseUrl, label, allowedModels, format
- AccountPool: addRelayAccount(), format-aware acquire(), JWT skip for relay
- CodexApi: baseUrlOverride for relay mode (simple Bearer auth, no fingerprint)
- handleDirectProxy: stream pipe / simplePost for non-codex format relays
- Route handlers: try format-matching relay before Codex translation
- Dashboard: relay form with format dropdown, grouped account list
- 45 new tests (903 total)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

功能请求: 支持API KEY的方式添加中转站的codex

1 participant