Skip to content

feat(providers): OpenAI + Gemini detection and OpenAI-compatible call path#61

Merged
CodeWithJuber merged 3 commits into
masterfrom
claude/provider-openai-gemini
Jul 15, 2026
Merged

feat(providers): OpenAI + Gemini detection and OpenAI-compatible call path#61
CodeWithJuber merged 3 commits into
masterfrom
claude/provider-openai-gemini

Conversation

@CodeWithJuber

Copy link
Copy Markdown
Owner

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_KEY and GEMINI_API_KEY (or GOOGLE_API_KEY) are picked up as the zero-config fallback when they're the only key set.

Detection alone would be hollow — src/llm.js only spoke the Anthropic Messages wire format, so a detected OpenAI key had nothing to call. Both OpenAI and Gemini expose an OpenAI-compatible chat/completions surface, so this adds that wire format alongside the Anthropic one, making a native key genuinely callable.

  • src/providers.jsopenai and gemini built-in providers (tier→model maps, format: "openai"); new detection branches, listDetectedProviders() entries, and providerStatus() envScan keys.
  • src/llm.js — OpenAI-compatible child runner beside the Anthropic Messages one; resolveHttpProvider() now returns a format field and resolves OpenAI/Gemini keys. FORGE_MODEL is honored on the direct-HTTP path too.
  • Docs — GUIDE detection chain + env-var table, CHANGELOG.md [Unreleased], ROADMAP.

Checklist

  • npm test passes (Node 18/20/22) — 678 tests, 676 pass, 0 fail (2 pre-existing skips); 12 new cases
  • npm run check passes (Biome lint + format) — exit 0
  • New public functions have a test
  • Conventional commit message (feat:)
  • CHANGELOG.md updated under ## [Unreleased]
  • No new runtime dependency (dev deps ok) — zero deps, stdlib only
  • Substrate/docs updated — GUIDE env contract + detection order reconciled (forge docs check green)

Risk & rollback

  • Risk level: low — additive; Anthropic path and precedence unchanged (Anthropic still wins when its creds are present), covered by hermetic env tests.
  • Rollback plan: revert the commit; no data/schema/config migrations, no persisted state touched.

Extra checks

  • npm run typecheck passes (tsc checkJs)
  • Input validated at boundaries; errors handled — no-credentials returns null; HTTP non-2xx surfaces an error, no swallowing
  • Logs contain no secrets/PII — the key still travels only via the child's _FORGE_LLM_KEY env, never argv/stdout
  • If AI-assisted: verified the OpenAI-compatible chat/completions shape for both vendors; behavior is unit-tested (network calls excluded)

🤖 Generated with Claude Code


Generated by Claude Code

claude and others added 3 commits July 12, 2026 20:36
… 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
@CodeWithJuber CodeWithJuber marked this pull request as ready for review July 15, 2026 11:15
@CodeWithJuber CodeWithJuber merged commit edbbaa8 into master Jul 15, 2026
10 checks passed
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