claude-code-openai 0.1.13 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +42 -17
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -186435,13 +186435,27 @@ async function getOpenAIClient({
186435
186435
  apiKey
186436
186436
  }) {
186437
186437
  let resolvedKey = apiKey || process.env.OPENAI_API_KEY || "";
186438
+ let isOAuthChatgpt = false;
186439
+ let chatgptAccountId;
186438
186440
  if (!resolvedKey) {
186439
186441
  try {
186440
- const { getOpenAIAccessToken: getOpenAIAccessToken2 } = await Promise.resolve().then(() => (init_openai_oauth(), exports_openai_oauth));
186442
+ const { getOpenAIAccessToken: getOpenAIAccessToken2, loadOpenAITokens: loadOpenAITokens2 } = await Promise.resolve().then(() => (init_openai_oauth(), exports_openai_oauth));
186441
186443
  resolvedKey = await getOpenAIAccessToken2() || "";
186444
+ if (resolvedKey) {
186445
+ isOAuthChatgpt = true;
186446
+ try {
186447
+ const tokens = loadOpenAITokens2();
186448
+ const token = tokens?.access_token || resolvedKey;
186449
+ const parts = token.split(".");
186450
+ if (parts.length === 3) {
186451
+ const payload = JSON.parse(Buffer.from(parts[1].replace(/-/g, "+").replace(/_/g, "/"), "base64").toString());
186452
+ chatgptAccountId = payload?.["https://api.openai.com/auth"]?.chatgpt_account_id;
186453
+ }
186454
+ } catch {}
186455
+ }
186442
186456
  } catch {}
186443
186457
  }
186444
- const baseURL = process.env.OPENAI_BASE_URL || "https://api.openai.com/v1";
186458
+ const baseURL = process.env.OPENAI_BASE_URL || (isOAuthChatgpt ? "https://chatgpt.com/backend-api/codex" : "https://api.openai.com/v1");
186445
186459
  const timeout = parseInt(process.env.API_TIMEOUT_MS || String(600000), 10);
186446
186460
  if (_cachedOpenAIClient && _cachedOpenAIClient.apiKey === resolvedKey) {
186447
186461
  return _cachedOpenAIClient;
@@ -186450,9 +186464,11 @@ async function getOpenAIClient({
186450
186464
  apiKey: resolvedKey,
186451
186465
  baseURL,
186452
186466
  timeout,
186467
+ isOAuthChatgpt,
186468
+ chatgptAccountId,
186453
186469
  fetch: globalThis.fetch
186454
186470
  };
186455
- logForDebugging(`[API:openai] Client created, baseURL=${baseURL}, auth=${resolvedKey ? process.env.OPENAI_API_KEY ? "api-key" : "oauth" : "none"}`);
186471
+ logForDebugging(`[API:openai] Client created, baseURL=${baseURL}, auth=${resolvedKey ? isOAuthChatgpt ? "oauth-chatgpt" : "api-key" : "none"}${chatgptAccountId ? ", account=" + chatgptAccountId : ""}`);
186456
186472
  return _cachedOpenAIClient;
186457
186473
  }
186458
186474
  function buildFetch(fetchOverride, source) {
@@ -204645,7 +204661,7 @@ var init_metadata = __esm(() => {
204645
204661
  isClaudeAiAuth: isClaudeAISubscriber(),
204646
204662
  version: "2.1.88-rebuild",
204647
204663
  versionBase: getVersionBase(),
204648
- buildTime: "2026-04-01T19:37:24.393Z",
204664
+ buildTime: "2026-04-01T19:55:20.831Z",
204649
204665
  deploymentEnvironment: env4.detectDeploymentEnvironment(),
204650
204666
  ...isEnvTruthy(process.env.GITHUB_ACTIONS) && {
204651
204667
  githubEventName: process.env.GITHUB_EVENT_NAME,
@@ -592931,7 +592947,7 @@ function getAnthropicEnvMetadata() {
592931
592947
  function getBuildAgeMinutes() {
592932
592948
  if (false)
592933
592949
  ;
592934
- const buildTime = new Date("2026-04-01T19:37:24.393Z").getTime();
592950
+ const buildTime = new Date("2026-04-01T19:55:20.831Z").getTime();
592935
592951
  if (isNaN(buildTime))
592936
592952
  return;
592937
592953
  return Math.floor((Date.now() - buildTime) / 60000);
@@ -595254,7 +595270,7 @@ async function* queryModelOpenAI(messages, systemPrompt, thinkingConfig, tools,
595254
595270
  temperature: options.temperatureOverride ?? 1,
595255
595271
  reasoning,
595256
595272
  previous_response_id: usePreviousResponseId ? _lastResponseId : undefined,
595257
- store: true
595273
+ store: !client3.isOAuthChatgpt
595258
595274
  };
595259
595275
  logForDebugging(`[OpenAI] Request: model=${openaiModel} input=${input.length} items (${usePreviousResponseId ? "incremental, chain=" + _lastResponseId : "full"}) tools=${oaiTools.length}`);
595260
595276
  const start = Date.now();
@@ -595276,12 +595292,16 @@ async function* queryModelOpenAI(messages, systemPrompt, thinkingConfig, tools,
595276
595292
  for (let attempt = 0;attempt <= MAX_RETRIES4; attempt++) {
595277
595293
  if (signal.aborted)
595278
595294
  return;
595295
+ const headers = {
595296
+ "Content-Type": "application/json",
595297
+ Authorization: `Bearer ${client3.apiKey}`
595298
+ };
595299
+ if (client3.isOAuthChatgpt && client3.chatgptAccountId) {
595300
+ headers["chatgpt-account-id"] = client3.chatgptAccountId;
595301
+ }
595279
595302
  response = await client3.fetch(`${client3.baseURL}/responses`, {
595280
595303
  method: "POST",
595281
- headers: {
595282
- "Content-Type": "application/json",
595283
- Authorization: `Bearer ${client3.apiKey}`
595284
- },
595304
+ headers,
595285
595305
  body: JSON.stringify(params),
595286
595306
  signal
595287
595307
  });
@@ -679502,7 +679522,7 @@ var init_bridge_kick = __esm(() => {
679502
679522
  var call56 = async () => {
679503
679523
  return {
679504
679524
  type: "text",
679505
- value: `${"2.1.88-rebuild"} (built ${"2026-04-01T19:37:24.393Z"})`
679525
+ value: `${"2.1.88-rebuild"} (built ${"2026-04-01T19:55:20.831Z"})`
679506
679526
  };
679507
679527
  }, version6, version_default;
679508
679528
  var init_version = __esm(() => {
@@ -699282,16 +699302,21 @@ async function verifyApiKey(apiKey, isNonInteractiveSession) {
699282
699302
  const client3 = await getOpenAIClient({ apiKey: apiKey || undefined, maxRetries: 0 });
699283
699303
  if (!client3.apiKey)
699284
699304
  return false;
699305
+ const verifyHeaders = {
699306
+ "Content-Type": "application/json",
699307
+ Authorization: `Bearer ${client3.apiKey}`
699308
+ };
699309
+ if (client3.isOAuthChatgpt && client3.chatgptAccountId) {
699310
+ verifyHeaders["chatgpt-account-id"] = client3.chatgptAccountId;
699311
+ }
699285
699312
  const resp = await client3.fetch(`${client3.baseURL}/responses`, {
699286
699313
  method: "POST",
699287
- headers: {
699288
- "Content-Type": "application/json",
699289
- Authorization: `Bearer ${client3.apiKey}`
699290
- },
699314
+ headers: verifyHeaders,
699291
699315
  body: JSON.stringify({
699292
699316
  model: resolveOpenAIModel2(getSmallFastModel()),
699293
699317
  input: "test",
699294
- max_output_tokens: 1
699318
+ max_output_tokens: 1,
699319
+ store: !client3.isOAuthChatgpt
699295
699320
  })
699296
699321
  });
699297
699322
  if (resp.status === 401 || resp.status === 403) {
@@ -777508,4 +777533,4 @@ async function main2() {
777508
777533
  }
777509
777534
  main2();
777510
777535
 
777511
- //# debugId=9DF84E6A3A50E43864756E2164756E21
777536
+ //# debugId=63B92EFA731D53E864756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-openai",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "Claude Code CLI with OpenAI GPT-5.4 backend support",
5
5
  "type": "module",
6
6
  "bin": {