Support multiple AI providers (OpenAI-compatible API)#4
Open
aliciapaz wants to merge 2 commits into
Open
Conversation
Switch from OpenAI's proprietary Responses API to the standard Chat Completions API so any OpenAI-compatible provider (Minimax, Ollama, Groq, Together AI, etc.) can be used as the AI backend. - Replace client.responses.create() with client.chat.completions.create() - Add AI_API_KEY env var (with OPENAI_API_KEY fallback for existing users) - Add AI_BASE_URL env var to point at any compatible endpoint - Guard against null response content with a clear error message - Update README, gemspec, and generator instructions Closes #3 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Context
The gem was hardcoded to OpenAI's proprietary Responses API (
client.responses.create()), making it impossible to use with other AI providers like Minimax, Ollama, Groq, or any OpenAI-compatible service. Users who don't use OpenAI were locked out entirely.Closes #3
What Changed
Switched the AI layer from OpenAI's Responses API to the standard Chat Completions API, which is the universal interface that all OpenAI-compatible providers implement.
Key files modified:
templates/config.js— Provider-agnostic config: readsAI_API_KEY(falls back toOPENAI_API_KEY), supportsAI_BASE_URLfor custom endpoints, default model changed togpt-4otemplates/ai.js— Replacedclient.responses.create()→client.chat.completions.create(), updated response parsing (resp.choices[0].message.contentinstead ofresp.output_text), added null-content guard for truncated/refused responsesinstall_generator.rb— Updated post-install instructions to referenceAI_API_KEYandAI_BASE_URLREADME.md— Updated requirements, setup steps, config table, and "How it works" sectionagent_e2e.gemspec— Updated summary and descriptionNotable decisions:
openainpm package as the SDK — it natively supports custombaseURL, so no new dependencies neededOPENAI_API_KEYis still supported as a fallback so existing users don't breakAI_API_KEYis missing (previously the OpenAI SDK would throw an opaque error)How to Test
AI_API_KEY=sk-...in.env, runbin/e2e— should work identically to beforeOPENAI_API_KEY=sk-...(old var name) — should still work via fallbackAI_API_KEY,AI_BASE_URL, andAI_MODELfor a compatible provider (e.g., Ollama athttp://localhost:11434/v1)content: null(e.g., token limit hit), should get"AI returned empty response"error instead of a crashDeployment Tasks
None
🤖 Generated with Claude Code