feat: Add OpenAI GPT adapter for multi-provider LLM support#19
Draft
feat: Add OpenAI GPT adapter for multi-provider LLM support#19
Conversation
Copilot
AI
changed the title
[WIP] Add OpenAI GPT adapter for multi-provider support
feat: Add OpenAI GPT adapter for multi-provider LLM support
Apr 6, 2026
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.
CAIMS was hardcoded to Anthropic Claude. This adds an OpenAI adapter and a provider factory so deployments can switch between providers via environment variable.
New files
lib/adapters/openai.ts—OpenAIAdapterimplementing the sameLLMAdapterinterface (chat()+judge()). Uses nativefetchagainst the OpenAI chat completions API with exponential backoff retries. SupportsOPENAI_BASE_URLfor OpenAI-compatible endpoints.lib/adapters/index.ts—getAdapter()factory readsCAIMS_LLM_PROVIDERenv var, returns the appropriate singleton. Defaults toanthropic.Provider selection
The existing chat route already calls
getAdapter()— no route changes needed.Tests
__tests__/openai.test.ts— 11 tests: response mapping, request shape, custom base URL, missing key, empty content, API errors__tests__/adapter-factory.test.ts— 8 tests: default provider, env var parsing (case/whitespace insensitive), explicit override, unknown provider error