Skip to content

🤖 feat: custom providers can choose their LLM API format - #3938

Merged
ibetitsmike merged 14 commits into
mainfrom
mike/fix-3934-custom-provider-api-format
Aug 24, 2026
Merged

🤖 feat: custom providers can choose their LLM API format#3938
ibetitsmike merged 14 commits into
mainfrom
mike/fix-3934-custom-provider-api-format

Conversation

@ibetitsmike

Copy link
Copy Markdown
Contributor

Summary

Custom providers can now choose their LLM API format. The custom-provider providerType field, previously locked to "openai-compatible", accepts three values that select the SDK adapter and wire format: openai-compatible (Chat Completions via @ai-sdk/openai-compatible, still the default), openai-responses (OpenAI Responses API via @ai-sdk/openai), and anthropic-messages (Anthropic Messages via @ai-sdk/anthropic). The Settings UI gains an "API format" selector in the add form and on each custom provider card.

Fixes#3934

Background

LLM gateways expose different models behind different API formats (e.g. OpenCode Zen serves some models over Chat Completions and others over Anthropic Messages). Built-in openai/anthropic providers already accept a custom baseUrl, but custom-named provider entries were hardcoded to the OpenAI-compatible Chat Completions path at every layer (schema, guards, ProviderService, model factory).

Implementation

  • CUSTOM_PROVIDER_TYPES in customProviders.ts is the single source of truth; the config schema, oRPC schemas, guards, and UI labels derive from it. The isCustomOpenAICompatible* helper family is renamed to format-agnostic isCustomProviderConfig/getCustomProviderIds/etc. since membership/shadowing semantics are identical for all custom types.
  • The model factory's custom branch switches on providerType: the existing createOpenAICompatible path is unchanged; the two new paths reuse the lazy PROVIDER_REGISTRY loaders and the format-appropriate base URL normalization (/v1 handling differs between the OpenAI-shaped and Anthropic adapters). Custom adapters always receive an explicit apiKey so the official SDKs cannot silently fall back to OPENAI_API_KEY/ANTHROPIC_API_KEY env vars and leak real credentials to a third-party gateway. The anthropic-messages path reuses the prompt-cache cache_control fetch wrapper.
  • addCustomOpenAICompatibleProvider is renamed to addCustomProvider and accepts an optional providerType (default openai-compatible); setProviderConfig accepts providerType edits validated against the enum. Existing configs parse and behave identically; no migration.
  • Tests: schema/guard/service/factory unit coverage plus IPC integration tests that stream through a local mock server and assert the request path per format (/v1/chat/completions, /v1/responses, /v1/messages). A shared happy-dom SelectPrimitive double (tests/ui/selectPrimitiveDouble.tsx, extracted from the advisor settings test) makes the Radix Select interactions testable.

Validation

  • make static-check, touched unit suites, and TEST_INTEGRATION=1 bun x jest tests/ipc/providers/openaiCompatible.test.ts all green locally.
  • Remote dogfood UAT on this exact commit: PASS. All three formats were added through the real UI, wire formats proven against a mock server per endpoint path, format editing on an existing provider took effect without restart, hand-written legacy openai-compatible entries and built-in provider cards regression-checked, and a real-model smoke chat succeeded.

Risks

Low for existing setups: the openai-compatible path and its base URL normalization are byte-for-byte unchanged, and providerType still defaults to it everywhere. The new paths reuse the built-in providers' adapters. Main regression surface is the guard renames touching provider shadowing/routing checks; those are mechanical and covered by existing tests.


Generated with xum • Model: anthropic:claude-fable-5 • Thinking: xhigh

@mintlify

mintlifyBot commented Aug 23, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

ProjectStatusPreviewUpdated (UTC)
Mux🟢 ReadyView PreviewAug 23, 2026, 10:06 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@ibetitsmike

Copy link
Copy Markdown
ContributorAuthor

@codex review

@chatgpt-codex-connector

This comment has been minimized.

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:df0bff3523

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadsrc/node/services/providerModelFactory.ts
Comment threadsrc/node/services/providerService.ts Outdated
Comment threadsrc/browser/features/Settings/Sections/ProvidersSection.tsx Outdated
…ormat edits, UI resync on failed persistence)
@ibetitsmike

Copy link
Copy Markdown
ContributorAuthor

@codex review

@chatgpt-codex-connector

This comment has been minimized.

@ibetitsmike

Copy link
Copy Markdown
ContributorAuthor

@codex review

@chatgpt-codex-connector

This comment has been minimized.

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:639004a620

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadsrc/node/services/providerModelFactory.ts Outdated
Comment threadsrc/node/services/providerModelFactory.ts
Comment threadtests/ui/selectPrimitiveDouble.tsx Outdated
Comment threadsrc/node/services/providerService.ts Outdated
…adapters, tools identity wire remap, in-lock shadow recheck, drop manual useMemo)
@ibetitsmike

Copy link
Copy Markdown
ContributorAuthor

@codex review

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Security Review

Here are some automated security review suggestions for this pull request.

Reviewed commit:5782e2cd4a

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment threadsrc/node/services/providerModelFactory.ts

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:5782e2cd4a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadsrc/node/services/providerModelFactory.ts
Comment threadsrc/node/services/providerModelFactory.ts
Comment threadsrc/common/utils/ai/providerOptions.ts
Comment threadsrc/browser/features/Settings/Sections/ProvidersSection.tsx Outdated
Comment threadsrc/common/utils/ai/cacheStrategy.ts
Comment threadsrc/node/services/providerModelFactory.ts
…apters, store policy, raw-identity metadata, cache classification, keyless auth headers, drop useCallback)
@ibetitsmike

Copy link
Copy Markdown
ContributorAuthor

@codex review

@chatgpt-codex-connector

This comment has been minimized.

@ibetitsmike

Copy link
Copy Markdown
ContributorAuthor

@codex review

@chatgpt-codex-connector

This comment has been minimized.

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:05bd8b58d9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadsrc/node/services/aiService.ts
Comment threadsrc/browser/features/Settings/Sections/ProvidersSection.tsx
Comment threadsrc/common/utils/providers/customProviders.ts
Comment threadsrc/node/services/providerModelFactory.ts
Comment threadsrc/common/utils/ai/providerOptions.ts
Comment threadsrc/node/services/providerModelFactory.ts
…ptions, Anthropic base URL path normalization)
@ibetitsmike

Copy link
Copy Markdown
ContributorAuthor

@codex review

@chatgpt-codex-connector

This comment has been minimized.

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:895a24c462

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadsrc/node/services/aiService.ts Outdated
…advisor createModel so alias metadata survives the wire remap)
@ibetitsmike

Copy link
Copy Markdown
ContributorAuthor

@codex review

@chatgpt-codex-connector

This comment has been minimized.

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:0a5ee4bd61

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadsrc/browser/features/Settings/Sections/ProvidersSection.tsx Outdated

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Security Review

Here are some automated security review suggestions for this pull request.

Reviewed commit:7b18a91b23

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment threadsrc/common/utils/ai/cacheStrategy.ts

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:7b18a91b23

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadsrc/node/services/providerModelFactory.ts

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:7b18a91b23

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadsrc/browser/features/Settings/Sections/ProvidersSection.tsx
Comment threadsrc/common/utils/providers/coderGatewayMetadata.ts
…he wire when Anthropic beta features are disabled)
@ibetitsmike

Copy link
Copy Markdown
ContributorAuthor

@codex review

@chatgpt-codex-connector

This comment has been minimized.

@ibetitsmike

Copy link
Copy Markdown
ContributorAuthor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit:337f07cf8e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

This comment has been minimized.

@ibetitsmike

Copy link
Copy Markdown
ContributorAuthor

@codex review

@chatgpt-codex-connector

This comment has been minimized.

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:a904cc88c8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadsrc/node/utils/providerRequirements.ts
@ibetitsmike

Copy link
Copy Markdown
ContributorAuthor

@codex review

@chatgpt-codex-connector

This comment has been minimized.

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:a904cc88c8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadsrc/node/services/providerModelFactory.ts
All three SDK adapters (@ai-sdk/anthropic, @ai-sdk/openai,
@ai-sdk/openai-compatible) build request URLs by appending the endpoint
path directly onto the base URL string, so a query or fragment swallows
the endpoint (https://proxy.example/v1?token=x -> .../v1?token=x/messages).
Reject such base URLs at addCustomProvider, setConfig baseUrl edits, and
the add form instead of silently stripping them: auth query params can
never work with these adapters, and stripping would surface as a
confusing request-time 401.
@ibetitsmike

Copy link
Copy Markdown
ContributorAuthor

@codex review

@chatgpt-codex-connector

This comment has been minimized.

@ibetitsmike

Copy link
Copy Markdown
ContributorAuthor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit:8faed8d33b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike added this pull request to the merge queueAug 24, 2026
@github-merge-queue
github-merge-queueBot removed this pull request from the merge queue due to failed status checks Aug 24, 2026
@ibetitsmike
ibetitsmike added this pull request to the merge queueAug 24, 2026
Merged via the queue into main with commit d500aa8Aug 24, 2026
21 checks passed
@ibetitsmike
ibetitsmike deleted the mike/fix-3934-custom-provider-api-format branch August 24, 2026 15:52
@mux-botmux-botBot mentioned this pull request Aug 24, 2026
Sign up for freeto 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.

Feature Request: Make custom provider support multiple LLM API format

1 participant

@ibetitsmike