mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-17 13:55:50 +00:00
refactor: 将 codex provider 重命名为 openai-responses
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,8 @@ import { openaiAdapter } from 'src/services/providerUsage/adapters/openai.js'
|
||||
import { updateProviderBuckets } from 'src/services/providerUsage/store.js'
|
||||
import { getProxyFetchOptions } from 'src/utils/proxy.js'
|
||||
|
||||
export const DEFAULT_CODEX_BASE_URL = 'https://api.openai.com/v1'
|
||||
|
||||
let cachedClient: OpenAI | null = null
|
||||
|
||||
function wrapFetchForUsage(base: typeof fetch): typeof fetch {
|
||||
@@ -11,7 +13,7 @@ function wrapFetchForUsage(base: typeof fetch): typeof fetch {
|
||||
): Promise<Response> => {
|
||||
const res = await base(...args)
|
||||
try {
|
||||
updateProviderBuckets('codex', openaiAdapter.parseHeaders(res.headers))
|
||||
updateProviderBuckets('openai-responses', openaiAdapter.parseHeaders(res.headers))
|
||||
} catch {
|
||||
// Usage tracking must not affect the request path.
|
||||
}
|
||||
@@ -29,13 +31,13 @@ export function getCodexClient(options?: {
|
||||
}
|
||||
|
||||
const apiKey = process.env.CODEX_API_KEY || ''
|
||||
const baseURL = process.env.CODEX_BASE_URL
|
||||
const baseURL = process.env.CODEX_BASE_URL || DEFAULT_CODEX_BASE_URL
|
||||
const baseFetch = options?.fetchOverride ?? (globalThis.fetch as typeof fetch)
|
||||
const wrappedFetch = wrapFetchForUsage(baseFetch)
|
||||
|
||||
const client = new OpenAI({
|
||||
apiKey,
|
||||
...(baseURL && { baseURL }),
|
||||
baseURL,
|
||||
maxRetries: options?.maxRetries ?? 0,
|
||||
timeout: parseInt(process.env.API_TIMEOUT_MS || String(600 * 1000), 10),
|
||||
dangerouslyAllowBrowser: true,
|
||||
|
||||
Reference in New Issue
Block a user