From 9440adf4355fb37a45e3d6d180706882a6be2e12 Mon Sep 17 00:00:00 2001 From: Yevhenii Shcherbina Date: Tue, 31 Mar 2026 12:08:45 -0400 Subject: [PATCH] feat: add chatgpt support for aibridge (#23822) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Registers a new aibridge provider for ChatGPT by reusing the existing OpenAI provider with a different `Name` and `BaseURL` (https://chatgpt.com/backend-api/codex). The ChatGPT backend API is OpenAI-compatible, so no new provider type is needed. ChatGPT authenticates exclusively via per-user OAuth JWTs (BYOK mode) — no centralized API key is configured. The OpenAI provider already handles this: when no key is set, it falls through to the bearer token from the request's Authorization header. Depends on #23811 --- coderd/aibridge/aibridge.go | 6 ++++++ enterprise/cli/aibridged.go | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/coderd/aibridge/aibridge.go b/coderd/aibridge/aibridge.go index 74484fca3a..d91efa7dbb 100644 --- a/coderd/aibridge/aibridge.go +++ b/coderd/aibridge/aibridge.go @@ -28,6 +28,12 @@ const ( HostCopilotEnterprise = "api.enterprise.githubcopilot.com" ) +// ChatGPT provider. +const ( + ProviderChatGPT = "chatgpt" + BaseURLChatGPT = "https://chatgpt.com/backend-api/codex" +) + // IsBYOK reports whether the request is using BYOK mode, determined // by the presence of the X-Coder-AI-Governance-Token header. func IsBYOK(header http.Header) bool { diff --git a/enterprise/cli/aibridged.go b/enterprise/cli/aibridged.go index 2dd5ca6c78..7c9952c901 100644 --- a/enterprise/cli/aibridged.go +++ b/enterprise/cli/aibridged.go @@ -65,6 +65,12 @@ func newAIBridgeDaemon(coderAPI *coderd.API) (*aibridged.Server, error) { BaseURL: "https://" + agplaibridge.HostCopilotEnterprise, CircuitBreaker: cbConfig, }), + aibridge.NewOpenAIProvider(aibridge.OpenAIConfig{ + Name: agplaibridge.ProviderChatGPT, + BaseURL: agplaibridge.BaseURLChatGPT, + CircuitBreaker: cbConfig, + SendActorHeaders: cfg.SendActorHeaders.Value(), + }), } reg := prometheus.WrapRegistererWithPrefix("coder_aibridged_", coderAPI.PrometheusRegistry)