Multi-provider support via OpenAI-compatible API + defensive markdown-fence stripping#7
Merged
robisim74 merged 2 commits intoApr 27, 2026
Conversation
Introduce a provider registry so the package can target different AI backends (OpenAI, Gemini) through their OpenAI-compatible endpoints. New providers can be added by extending the registry in src/providers.ts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Some providers (e.g. Gemini via OpenAI-compatible endpoints) wrap JSON responses in ```json ... ``` markers despite the prompt instruction, causing JSON.parse to fail. Strip these defensively at the parse site. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Owner
|
@raphaelarias Thanks for this pr! I like the idea of being able to use other providers. But I don't understand one thing: in the description you say (Claude says?) that the new option is |
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.
Summary
Two small, independent improvements we've been running on a fork:
Multi-provider support — adds an optional
baseURLoption (also--baseURLon the CLI) that gets passed through to the OpenAI client constructor. Lets users point the tool at any OpenAI-compatible endpoint (Gemini, OpenRouter, local Ollama, Azure OpenAI, etc.) without code changes. No behavior change whenbaseURLis omitted — defaults to OpenAI as before.Defensive markdown-fence stripping — some providers (notably Gemini via its OpenAI-compatible endpoint) wrap JSON responses in
```json ... ```markers despite the prompt instruction added in Error when using 4o but works with 4? #5, causingJSON.parseto fail. This adds a defensive strip at the parse site so the existing prompt-level fix still wins on OpenAI but other providers don't break.Why these together
The md-fence fix isn't strictly required for OpenAI — it surfaced once we started using non-OpenAI providers via the new
baseURLoption, which is why they're bundled. Happy to split into two PRs if preferred.Test plan
npm run lintpassesnpm run buildpassesnpm test— all 3 existing tests passbaseURL