Skip to content

Remove OPENAI_CHATGPT_API_KEY fallback and simplify to OPENAI_API_KEY#786

Merged
jamespepper81 merged 2 commits into
devfrom
claude/great-sagan-89aowg
Jun 23, 2026
Merged

Remove OPENAI_CHATGPT_API_KEY fallback and simplify to OPENAI_API_KEY#786
jamespepper81 merged 2 commits into
devfrom
claude/great-sagan-89aowg

Conversation

@jamespepper81

Copy link
Copy Markdown
Contributor

Summary

Removes backward compatibility support for the OPENAI_CHATGPT_API_KEY environment variable and simplifies the codebase to use only OPENAI_API_KEY. This change streamlines configuration by eliminating the fallback mechanism that was previously maintained for deployments using the ChatGPT-specific key name.

Type of Change

  • Bug fix
  • Refactor / cleanup
  • Breaking change
  • New feature
  • Documentation update

Changes Made

  1. src/ai/genkit.ts: Removed fallback to OPENAI_CHATGPT_API_KEY and updated warning message to reference only OPENAI_API_KEY
  2. apphosting.dev.yaml & apphosting.prd.yaml: Removed environment variable mapping for OPENAI_CHATGPT_API_KEY
  3. src/ai/flows/wallet-insights-chat.ts:
    • Removed OPENAI_CHATGPT_API_KEY from API key error detection
    • Updated user-facing error message to reference only OPENAI_API_KEY

Test Plan

No testing needed. This is a configuration cleanup that removes unused fallback logic. The primary API key (OPENAI_API_KEY) continues to work as before. Existing error handling for missing API keys remains intact.

Checklist

  • npm run typecheck passes
  • npm run lint passes
  • No breaking changes to API contracts
  • Documentation updated (error messages simplified)

https://claude.ai/code/session_014fbd2ZstdjJNhn3UQGjU5i

The OpenAI credential was referenced via two env vars: OPENAI_API_KEY and
the OPENAI_CHATGPT_API_KEY backward-compat fallback. The latter only existed
as an alias and, in both apphosting configs, mapped to the same OPENAI_API_KEY
secret. Consolidate on OPENAI_API_KEY (the documented standard and SDK
convention) so only one variable is referenced.

- src/ai/genkit.ts: drop the fallback, update warning and comment
- src/ai/flows/wallet-insights-chat.ts: drop the alias from error detection
  and the user-facing config message
- apphosting.dev.yaml / apphosting.prd.yaml: remove the alias env mapping

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014fbd2ZstdjJNhn3UQGjU5i
@jamespepper81

Copy link
Copy Markdown
Contributor Author

@claude can you code review the pr 786 and make any changes required

The comment claimed the code fails fast on a missing key, but it warns and
continues. Drop the misleading line and keep the accurate one.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014fbd2ZstdjJNhn3UQGjU5i

Copy link
Copy Markdown
Contributor Author

Reviewed PR #786. The change is correct and complete:

  • ✅ Zero remaining OPENAI_CHATGPT_API_KEY references anywhere in the repo (source, configs, docs, CI).
  • ✅ The removed fallback was safe — in both apphosting.*.yaml files the alias mapped to the same OPENAI_API_KEY secret, so nothing real is lost.
  • npm run typecheck and npm run lint both pass.

I found and fixed one minor issue while reviewing: src/ai/genkit.ts had two contradictory comments above the key check — a stale // ...fail fast if missing line, even though the code warns and continues. Removed the misleading line (commit 5ce4b15).

⚠️ One operational reminder (not a code issue): any deployment environment that was relying only on the OPENAI_CHATGPT_API_KEY variable name must now have OPENAI_API_KEY set. The underlying secret is unchanged, so this is just confirming the variable mapping.


Generated by Claude Code

@jamespepper81 jamespepper81 merged commit 560f239 into dev Jun 23, 2026
5 checks passed
@jamespepper81 jamespepper81 deleted the claude/great-sagan-89aowg branch June 23, 2026 16:15
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.

2 participants