feat(providers): OpenAI + Gemini detection and OpenAI-compatible call path#61
Merged
Merged
Conversation
… path Implements the ROADMAP "Next" item: extend autoDetectProvider() beyond Anthropic/OpenRouter/LiteLLM to OpenAI and Gemini, with the same zero-config contract. Anthropic credentials still win when present; OPENAI_API_KEY and GEMINI_API_KEY (or GOOGLE_API_KEY) are picked up as the sole configured provider. Both are reached over their OpenAI-compatible chat/completions surface, so a native key is genuinely callable — not just detected: - src/providers.js: add `openai` and `gemini` built-in providers (tier->model maps, format:"openai"); detection + listDetectedProviders + status envScan. - src/llm.js: add an OpenAI-compatible wire runner alongside the Anthropic Messages path; resolveHttpProvider() now returns a `format` field and resolves OpenAI/Gemini keys. FORGE_MODEL is honored on the direct-HTTP path too. - Tests: 12 new cases across test/providers.test.js and test/llm.test.js; CLEAR env sets made hermetic. - Docs: GUIDE detection chain + env table, CHANGELOG [Unreleased], ROADMAP. Verified: npm test (676 pass), npm run check, npm run typecheck, forge docs check. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WTc41NYip9GZLu4n9a5vLs
The `claude` CLI fallback now resolves OpenAI/Gemini keys too (llm.js), so the doctor hint should name them alongside the Anthropic credentials. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WTc41NYip9GZLu4n9a5vLs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Implements the ROADMAP "Next" item "OpenAI + Gemini provider detection": extend
autoDetectProvider()beyond Anthropic/OpenRouter/LiteLLM to OpenAI and Gemini, with the same zero-config contract. Anthropic credentials still win when present;OPENAI_API_KEYandGEMINI_API_KEY(orGOOGLE_API_KEY) are picked up as the zero-config fallback when they're the only key set.Detection alone would be hollow —
src/llm.jsonly spoke the Anthropic Messages wire format, so a detected OpenAI key had nothing to call. Both OpenAI and Gemini expose an OpenAI-compatiblechat/completionssurface, so this adds that wire format alongside the Anthropic one, making a native key genuinely callable.src/providers.js—openaiandgeminibuilt-in providers (tier→model maps,format: "openai"); new detection branches,listDetectedProviders()entries, andproviderStatus()envScan keys.src/llm.js— OpenAI-compatible child runner beside the Anthropic Messages one;resolveHttpProvider()now returns aformatfield and resolves OpenAI/Gemini keys.FORGE_MODELis honored on the direct-HTTP path too.CHANGELOG.md[Unreleased], ROADMAP.Checklist
npm testpasses (Node 18/20/22) — 678 tests, 676 pass, 0 fail (2 pre-existing skips); 12 new casesnpm run checkpasses (Biome lint + format) — exit 0feat:)CHANGELOG.mdupdated under## [Unreleased]forge docs checkgreen)Risk & rollback
Extra checks
npm run typecheckpasses (tsccheckJs)null; HTTP non-2xx surfaces an error, no swallowing_FORGE_LLM_KEYenv, never argv/stdoutchat/completionsshape for both vendors; behavior is unit-tested (network calls excluded)🤖 Generated with Claude Code
Generated by Claude Code