Skip to content

fix: adds sgl anthropic compatible apis via key level setting - #5305

Merged
akshaydeo merged 1 commit into
devfrom
07-16-fix_adds_sgl_anthropic_compatible_apis_via_key_level_setting
Jul 18, 2026
Merged

akshaydeo merged 1 commit into
devfrom
07-16-fix_adds_sgl_anthropic_compatible_apis_via_key_level_setting

Conversation

@sammaji

@sammaji sammaji commented Jul 16, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds a use_anthropic_endpoints flag to SGLang keys and aliases that routes chat completion, streaming, and responses requests through SGLang's Anthropic-compatible /v1/messages endpoint instead of its default OpenAI-compatible endpoints. This enables users running SGLang with Anthropic-format models to take advantage of native Anthropic request/response semantics without switching providers.

Changes

  • Added UseAnthropicEndpoints *bool to schemas.Key and AliasConfig, with full persistence through the RDB config store and key hash generation.
  • Added ResolveUseAnthropicEndpboints helper in the Anthropic utils package that checks the resolved alias config first, then falls back to the key-level flag.
  • Registered schemas.SGL in AnthropicProviderRequestDefaultsMap so the Anthropic request builder accepts SGL as a valid provider.
  • Updated SGLProvider.ChatCompletion, ChatCompletionStream, Responses, and ResponsesStream to branch on the flag and delegate to the shared Anthropic handlers (HandleAnthropicChatCompletionRequest, HandleAnthropicChatCompletionStreaming, HandleAnthropicResponsesRequest, HandleAnthropicResponsesStream) with a Bearer auth + anthropic-version: 2023-06-01 header set.
  • TextCompletion intentionally always uses the OpenAI-compatible endpoint, as SGLang's Anthropic-compatible layer does not expose a legacy text-completions surface.
  • Added a database migration (add_use_anthropic_endpoints_column) to add the column to config_keys.
  • Updated config.schema.json to expose use_anthropic_endpoints on both the key and alias levels for SGLang.
  • Added a UI toggle in the API keys form (key-level) and a new SGLSection in the deployments table (alias-level override).
  • Updated TypeScript types and Zod schemas to include use_anthropic_endpoints.

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

# Core/Transports
go test ./...

# UI
cd ui
pnpm i
pnpm build
  1. Configure an SGLang provider key with use_anthropic_endpoints: true (via config file or UI toggle).
  2. Send a chat completion request routed to the SGLang provider and confirm the request is forwarded to /v1/messages with anthropic-version: 2023-06-01 and a Bearer token.
  3. Send a streaming chat completion and responses request and confirm the same routing.
  4. Confirm that without the flag set (or set to false), requests continue to use the OpenAI-compatible endpoints.
  5. Set use_anthropic_endpoints on an alias config and confirm it overrides the key-level setting.
  6. Verify the database migration runs cleanly on a fresh and existing database.

Breaking changes

  • Yes
  • No

Related issues

Security considerations

The use_anthropic_endpoints flag does not introduce new secret handling. Authentication continues to use the existing key secret via Bearer token, consistent with the existing OpenAI-compatible path.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

@coderabbitai

coderabbitai Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 989cb002-58ee-43f8-94e8-fa607d708d48

📥 Commits

Reviewing files that changed from the base of the PR and between 6ef7ed4 and 2af938f.

📒 Files selected for processing (14)
  • core/providers/anthropic/requestbuilder.go
  • core/providers/anthropic/utils.go
  • core/providers/sgl/sgl.go
  • core/schemas/account.go
  • framework/configstore/clientconfig.go
  • framework/configstore/migrations.go
  • framework/configstore/rdb.go
  • framework/configstore/tables/key.go
  • transports/bifrost-http/lib/config.go
  • transports/config.schema.json
  • ui/app/workspace/providers/fragments/apiKeysFormFragment.tsx
  • ui/app/workspace/providers/fragments/deploymentsTable.tsx
  • ui/lib/types/config.ts
  • ui/lib/types/schemas.ts
📝 Walkthrough

Walkthrough

SGLang supports optional routing through Anthropic-compatible /v1/messages endpoints for chat and responses APIs. The setting is added to configuration schemas, persisted keys, hash reconciliation, and SGLang-, DeepSeek-, and Fireworks-specific UI controls.

Changes

SGLang Anthropic endpoint routing

Layer / File(s) Summary
Routing contracts and configuration shapes
core/providers/anthropic/..., core/schemas/account.go, ui/lib/types/*, transports/config.schema.json
Adds endpoint flag fields, alias override resolution, provider defaults, and SGLang, DeepSeek, and Fireworks configuration schemas.
Configuration persistence and hash reconciliation
framework/configstore/..., transports/bifrost-http/lib/config.go
Migrates, stores, hydrates, redacts, and hashes UseAnthropicEndpoints configuration.
SGLang Anthropic request paths
core/providers/sgl/sgl.go
Routes chat and responses requests, including streaming variants, through Anthropic-compatible handlers when enabled.
Provider endpoint controls
ui/app/workspace/providers/fragments/*
Adds endpoint switches for SGLang, DeepSeek, and Fireworks API key and deployment configuration forms.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant SGLProvider
  participant EndpointResolver
  participant AnthropicHandler
  participant SGLang
  Client->>SGLProvider: Submit chat or responses request
  SGLProvider->>EndpointResolver: Resolve endpoint configuration
  EndpointResolver-->>SGLProvider: Return routing decision
  SGLProvider->>AnthropicHandler: Build Anthropic Messages request
  AnthropicHandler->>SGLang: POST /v1/messages
  SGLang-->>AnthropicHandler: Return response or stream
  AnthropicHandler-->>Client: Return normalized result
Loading

Suggested reviewers: akshaydeo, tejasghatte, danpiths, pratham-mishra04, roroghost17

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 68.75% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and matches the main change: adding SGL Anthropic-compatible APIs via a key-level setting.
Description check ✅ Passed The description covers summary, changes, testing, security, and checklist, though UI screenshots/recordings are missing.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 07-16-fix_adds_sgl_anthropic_compatible_apis_via_key_level_setting

Comment @coderabbitai help to get the list of available commands.

sammaji commented Jul 16, 2026 •

Copy link
Copy Markdown
Member Author

@sammaji
sammaji marked this pull request as ready for review July 16, 2026 15:01
Copilot AI review requested due to automatic review settings July 16, 2026 15:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@greptile-apps

greptile-apps Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

This looks safe to merge.

  • The Responses paths now enable extra-parameter passthrough before building Anthropic requests.
  • Streaming requests use the provider streaming client and configured idle timeout.
  • The UI descriptions now match the supported chat and Responses operations.
  • No blocking issues were found in the updated code.

Important Files Changed

Filename Overview
core/providers/sgl/sgl.go Adds Anthropic-compatible unary and streaming routing for SGLang chat and Responses requests.
core/providers/anthropic/requestbuilder.go Registers SGLang with the shared Anthropic request builder.
core/providers/anthropic/utils.go Adds alias-first resolution for the Anthropic endpoint setting.
framework/configstore/migrations.go Adds a reversible migration for the key-level endpoint setting.
framework/configstore/rdb.go Persists the endpoint setting across key reads, inserts, and updates.
transports/config.schema.json Adds the endpoint setting to the provider key and alias configuration schema.
ui/app/workspace/providers/fragments/apiKeysFormFragment.tsx Adds the key-level Anthropic endpoint control.
ui/app/workspace/providers/fragments/deploymentsTable.tsx Adds the deployment-level opt-in override control.

Reviews (6): Last reviewed commit: "fix: adds sgl anthropic compatible apis ..." | Re-trigger Greptile

Comment thread ui/app/workspace/providers/fragments/deploymentsTable.tsx Outdated
Comment thread core/providers/sgl/sgl.go Outdated
Comment thread ui/app/workspace/providers/fragments/apiKeysFormFragment.tsx Outdated
Comment thread ui/app/workspace/providers/fragments/deploymentsTable.tsx Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (2)
framework/configstore/clientconfig.go (1)

845-852: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add table-driven regression coverage for the new hash dimension.

Cover nil, false, and true values, asserting that nil/false produce the same hash while true changes it. Also cover the config reconciliation path that consumes this hash.

As per coding guidelines, Go behavior changes should have table-driven coverage.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@framework/configstore/clientconfig.go` around lines 845 - 852, Add
table-driven regression tests for the hash logic around UseAnthropicEndpoints,
covering nil, false, and true values; assert nil and false produce identical
hashes while true produces a different hash. Also exercise the configuration
reconciliation path that consumes this hash, using existing test helpers and
symbols rather than introducing parallel logic.

Source: Coding guidelines

core/providers/anthropic/utils.go (1)

3357-3358: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Fix the exported helper name typo.

ResolveUseAnthropicEndpboints misspells “Endpoints.” Rename it to ResolveUseAnthropicEndpoints and update its callers before this new API becomes widely referenced.

Proposed fix
-// ResolveUseAnthropicEndpboints reports whether the request should be routed through Anthropic-compatible endpoints
-func ResolveUseAnthropicEndpboints(ctx *schemas.BifrostContext, key schemas.Key) bool {
+// ResolveUseAnthropicEndpoints reports whether the request should be routed through Anthropic-compatible endpoints
+func ResolveUseAnthropicEndpoints(ctx *schemas.BifrostContext, key schemas.Key) bool {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@core/providers/anthropic/utils.go` around lines 3357 - 3358, Rename the
exported helper ResolveUseAnthropicEndpboints to ResolveUseAnthropicEndpoints,
correcting “Endpboints” to “Endpoints,” and update every caller and reference to
use the corrected API name.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@core/providers/sgl/sgl.go`:
- Around line 210-215: Update all four Anthropic request build configurations in
the SGL provider to resolve ShouldSendBackRawRequest and
ShouldSendBackRawResponse through the per-request
BifrostContextKeyCaptureRawRequest and BifrostContextKeyCaptureRawResponse
overrides, falling back to the existing provider defaults when no override is
present. Apply the same change consistently across the configurations near the
referenced request-building paths.

In `@transports/config.schema.json`:
- Around line 3935-3940: Move use_anthropic_endpoints into the properties of
sgl_key_config rather than defining it as a sibling object property. Keep it
optional, retain its boolean type and false default, and ensure the enclosing
sgl_key_config schema accepts this field without allowing unrelated additional
properties.

In `@ui/app/workspace/providers/fragments/apiKeysFormFragment.tsx`:
- Around line 767-785: Update the FormDescription for the
key.use_anthropic_endpoints field in the isSGL block to state that only chat
completions and responses requests are routed through SGLang’s
Anthropic-compatible endpoints; explicitly preserve text completions on the
OpenAI-compatible endpoint without changing the switch or provider behavior.

In `@ui/app/workspace/providers/fragments/deploymentsTable.tsx`:
- Around line 302-305: Update the explanatory text near the deployment endpoint
configuration to state that only chat and responses requests use SGLang’s
Anthropic-compatible endpoints; explicitly preserve text completions on the
OpenAI-compatible /v1/completions endpoint.
- Around line 308-309: Update the use_anthropic_endpoints handler in the alias
configuration to persist explicit false when the checkbox is unchecked, rather
than writing undefined, so aliases can override a true key-level setting. Keep
the checked path writing true and ensure the UI reflects the stored alias-level
boolean; only retain inheritance through a separate explicit state if the
existing design requires it.

---

Nitpick comments:
In `@core/providers/anthropic/utils.go`:
- Around line 3357-3358: Rename the exported helper
ResolveUseAnthropicEndpboints to ResolveUseAnthropicEndpoints, correcting
“Endpboints” to “Endpoints,” and update every caller and reference to use the
corrected API name.

In `@framework/configstore/clientconfig.go`:
- Around line 845-852: Add table-driven regression tests for the hash logic
around UseAnthropicEndpoints, covering nil, false, and true values; assert nil
and false produce identical hashes while true produces a different hash. Also
exercise the configuration reconciliation path that consumes this hash, using
existing test helpers and symbols rather than introducing parallel logic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 85312c70-77b5-41af-83d4-70bc61750ddb

📥 Commits

Reviewing files that changed from the base of the PR and between c0909f9 and dc237d8.

📒 Files selected for processing (14)
  • core/providers/anthropic/requestbuilder.go
  • core/providers/anthropic/utils.go
  • core/providers/sgl/sgl.go
  • core/schemas/account.go
  • framework/configstore/clientconfig.go
  • framework/configstore/migrations.go
  • framework/configstore/rdb.go
  • framework/configstore/tables/key.go
  • transports/bifrost-http/lib/config.go
  • transports/config.schema.json
  • ui/app/workspace/providers/fragments/apiKeysFormFragment.tsx
  • ui/app/workspace/providers/fragments/deploymentsTable.tsx
  • ui/lib/types/config.ts
  • ui/lib/types/schemas.ts

Comment thread core/providers/sgl/sgl.go
Comment thread transports/config.schema.json
Comment thread ui/app/workspace/providers/fragments/apiKeysFormFragment.tsx Outdated
Comment thread ui/app/workspace/providers/fragments/deploymentsTable.tsx
Comment thread ui/app/workspace/providers/fragments/deploymentsTable.tsx Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@transports/config.schema.json`:
- Line 405: Remove the DeepSeek-specific use_anthropic_endpoints schema and
providers.deepseek wiring until runtime support exists, including the
deepseek_key configuration paths referenced in the diff. Ensure DeepSeek no
longer accepts or exposes this ignored toggle across all affected provider
configuration definitions.
- Around line 3677-3680: Update the base_key.aliases.* use_anthropic_endpoints
schema definition to include a boolean default of false, matching the key-level
definition and persisted contract. Preserve the existing type and description.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b4648505-27b6-4ab9-9380-e68e4a469e55

📥 Commits

Reviewing files that changed from the base of the PR and between dc237d8 and b865b54.

📒 Files selected for processing (14)
  • core/providers/anthropic/requestbuilder.go
  • core/providers/anthropic/utils.go
  • core/providers/sgl/sgl.go
  • core/schemas/account.go
  • framework/configstore/clientconfig.go
  • framework/configstore/migrations.go
  • framework/configstore/rdb.go
  • framework/configstore/tables/key.go
  • transports/bifrost-http/lib/config.go
  • transports/config.schema.json
  • ui/app/workspace/providers/fragments/apiKeysFormFragment.tsx
  • ui/app/workspace/providers/fragments/deploymentsTable.tsx
  • ui/lib/types/config.ts
  • ui/lib/types/schemas.ts
🚧 Files skipped from review as they are similar to previous changes (13)
  • ui/lib/types/config.ts
  • ui/lib/types/schemas.ts
  • core/schemas/account.go
  • ui/app/workspace/providers/fragments/apiKeysFormFragment.tsx
  • core/providers/anthropic/utils.go
  • core/providers/anthropic/requestbuilder.go
  • ui/app/workspace/providers/fragments/deploymentsTable.tsx
  • framework/configstore/tables/key.go
  • framework/configstore/rdb.go
  • core/providers/sgl/sgl.go
  • framework/configstore/clientconfig.go
  • transports/bifrost-http/lib/config.go
  • framework/configstore/migrations.go

Comment thread transports/config.schema.json
Comment thread transports/config.schema.json
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 16, 2026
Comment thread ui/app/workspace/providers/fragments/apiKeysFormFragment.tsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@core/schemas/account.go`:
- Around line 233-234: Update isLegacyShape() to require UseAnthropicEndpoints
== nil before classifying an alias as legacy, ensuring MarshalJSON() preserves
the override when set. Add round-trip tests covering both true and false
UseAnthropicEndpoints values and verify they survive JSON marshaling and
unmarshaling.

In `@ui/app/workspace/providers/fragments/deploymentsTable.tsx`:
- Around line 303-304: Update the endpoint description paragraph near the
deployment routing text to add the missing noun after “Anthropic-compatible,” so
the rendered sentence is grammatically complete.
- Around line 301-310: Associate the “Use Anthropic endpoints” label with the
Switch control by assigning the Switch a unique id and matching the label’s
htmlFor, or by adding an appropriate aria-label directly to the Switch. Update
the label/Switch block without changing its checked, change, or disabled
behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d9675621-962a-4f73-98eb-f4cfb3e181ce

📥 Commits

Reviewing files that changed from the base of the PR and between b865b54 and 6ef7ed4.

📒 Files selected for processing (14)
  • core/providers/anthropic/requestbuilder.go
  • core/providers/anthropic/utils.go
  • core/providers/sgl/sgl.go
  • core/schemas/account.go
  • framework/configstore/clientconfig.go
  • framework/configstore/migrations.go
  • framework/configstore/rdb.go
  • framework/configstore/tables/key.go
  • transports/bifrost-http/lib/config.go
  • transports/config.schema.json
  • ui/app/workspace/providers/fragments/apiKeysFormFragment.tsx
  • ui/app/workspace/providers/fragments/deploymentsTable.tsx
  • ui/lib/types/config.ts
  • ui/lib/types/schemas.ts
🚧 Files skipped from review as they are similar to previous changes (11)
  • core/providers/anthropic/utils.go
  • ui/lib/types/config.ts
  • ui/app/workspace/providers/fragments/apiKeysFormFragment.tsx
  • core/providers/anthropic/requestbuilder.go
  • transports/bifrost-http/lib/config.go
  • framework/configstore/clientconfig.go
  • ui/lib/types/schemas.ts
  • transports/config.schema.json
  • framework/configstore/migrations.go
  • core/providers/sgl/sgl.go
  • framework/configstore/rdb.go

Comment thread core/schemas/account.go
Comment thread ui/app/workspace/providers/fragments/deploymentsTable.tsx Outdated
Comment thread ui/app/workspace/providers/fragments/deploymentsTable.tsx Outdated
@sammaji
sammaji force-pushed the 07-16-fix_adds_sgl_anthropic_compatible_apis_via_key_level_setting branch from 6ef7ed4 to 9be779a Compare July 17, 2026 13:23
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 17, 2026
@sammaji
sammaji force-pushed the 07-16-fix_adds_sgl_anthropic_compatible_apis_via_key_level_setting branch from d660a54 to 2af938f Compare July 18, 2026 04:19

akshaydeo commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Merge activity

  • Jul 18, 4:02 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jul 18, 4:02 PM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo
akshaydeo merged commit 43786a7 into dev Jul 18, 2026
14 of 15 checks passed
@akshaydeo
akshaydeo deleted the 07-16-fix_adds_sgl_anthropic_compatible_apis_via_key_level_setting branch July 18, 2026 16:02
akhsaul pushed a commit to akhsaul/bifrost that referenced this pull request Aug 27, 2026
…q#5305)

## Summary

Adds a `use_anthropic_endpoints` flag to SGLang keys and aliases that routes chat completion, streaming, and responses requests through SGLang's Anthropic-compatible `/v1/messages` endpoint instead of its default OpenAI-compatible endpoints. This enables users running SGLang with Anthropic-format models to take advantage of native Anthropic request/response semantics without switching providers.

## Changes

- Added `UseAnthropicEndpoints *bool` to `schemas.Key` and `AliasConfig`, with full persistence through the RDB config store and key hash generation.
- Added `ResolveUseAnthropicEndpboints` helper in the Anthropic utils package that checks the resolved alias config first, then falls back to the key-level flag.
- Registered `schemas.SGL` in `AnthropicProviderRequestDefaultsMap` so the Anthropic request builder accepts SGL as a valid provider.
- Updated `SGLProvider.ChatCompletion`, `ChatCompletionStream`, `Responses`, and `ResponsesStream` to branch on the flag and delegate to the shared Anthropic handlers (`HandleAnthropicChatCompletionRequest`, `HandleAnthropicChatCompletionStreaming`, `HandleAnthropicResponsesRequest`, `HandleAnthropicResponsesStream`) with a Bearer auth + `anthropic-version: 2023-06-01` header set.
- `TextCompletion` intentionally always uses the OpenAI-compatible endpoint, as SGLang's Anthropic-compatible layer does not expose a legacy text-completions surface.
- Added a database migration (`add_use_anthropic_endpoints_column`) to add the column to `config_keys`.
- Updated `config.schema.json` to expose `use_anthropic_endpoints` on both the key and alias levels for SGLang.
- Added a UI toggle in the API keys form (key-level) and a new `SGLSection` in the deployments table (alias-level override).
- Updated TypeScript types and Zod schemas to include `use_anthropic_endpoints`.

## Type of change

- [ ] Bug fix
- [x] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [x] Core (Go)
- [x] Transports (HTTP)
- [x] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [ ] Docs

## How to test

```sh
# Core/Transports
go test ./...

# UI
cd ui
pnpm i
pnpm build
```

1. Configure an SGLang provider key with `use_anthropic_endpoints: true` (via config file or UI toggle).
2. Send a chat completion request routed to the SGLang provider and confirm the request is forwarded to `/v1/messages` with `anthropic-version: 2023-06-01` and a Bearer token.
3. Send a streaming chat completion and responses request and confirm the same routing.
4. Confirm that without the flag set (or set to `false`), requests continue to use the OpenAI-compatible endpoints.
5. Set `use_anthropic_endpoints` on an alias config and confirm it overrides the key-level setting.
6. Verify the database migration runs cleanly on a fresh and existing database.

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

## Security considerations

The `use_anthropic_endpoints` flag does not introduce new secret handling. Authentication continues to use the existing key secret via Bearer token, consistent with the existing OpenAI-compatible path.

## Checklist

- [x] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [x] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [x] I verified the CI pipeline passes locally if applicable
occcat pushed a commit to occcat/bifrost that referenced this pull request Sep 2, 2026
…q#5305)

## Summary

Adds a `use_anthropic_endpoints` flag to SGLang keys and aliases that routes chat completion, streaming, and responses requests through SGLang's Anthropic-compatible `/v1/messages` endpoint instead of its default OpenAI-compatible endpoints. This enables users running SGLang with Anthropic-format models to take advantage of native Anthropic request/response semantics without switching providers.

## Changes

- Added `UseAnthropicEndpoints *bool` to `schemas.Key` and `AliasConfig`, with full persistence through the RDB config store and key hash generation.
- Added `ResolveUseAnthropicEndpboints` helper in the Anthropic utils package that checks the resolved alias config first, then falls back to the key-level flag.
- Registered `schemas.SGL` in `AnthropicProviderRequestDefaultsMap` so the Anthropic request builder accepts SGL as a valid provider.
- Updated `SGLProvider.ChatCompletion`, `ChatCompletionStream`, `Responses`, and `ResponsesStream` to branch on the flag and delegate to the shared Anthropic handlers (`HandleAnthropicChatCompletionRequest`, `HandleAnthropicChatCompletionStreaming`, `HandleAnthropicResponsesRequest`, `HandleAnthropicResponsesStream`) with a Bearer auth + `anthropic-version: 2023-06-01` header set.
- `TextCompletion` intentionally always uses the OpenAI-compatible endpoint, as SGLang's Anthropic-compatible layer does not expose a legacy text-completions surface.
- Added a database migration (`add_use_anthropic_endpoints_column`) to add the column to `config_keys`.
- Updated `config.schema.json` to expose `use_anthropic_endpoints` on both the key and alias levels for SGLang.
- Added a UI toggle in the API keys form (key-level) and a new `SGLSection` in the deployments table (alias-level override).
- Updated TypeScript types and Zod schemas to include `use_anthropic_endpoints`.

## Type of change

- [ ] Bug fix
- [x] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [x] Core (Go)
- [x] Transports (HTTP)
- [x] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [ ] Docs

## How to test

```sh
# Core/Transports
go test ./...

# UI
cd ui
pnpm i
pnpm build
```

1. Configure an SGLang provider key with `use_anthropic_endpoints: true` (via config file or UI toggle).
2. Send a chat completion request routed to the SGLang provider and confirm the request is forwarded to `/v1/messages` with `anthropic-version: 2023-06-01` and a Bearer token.
3. Send a streaming chat completion and responses request and confirm the same routing.
4. Confirm that without the flag set (or set to `false`), requests continue to use the OpenAI-compatible endpoints.
5. Set `use_anthropic_endpoints` on an alias config and confirm it overrides the key-level setting.
6. Verify the database migration runs cleanly on a fresh and existing database.

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

## Security considerations

The `use_anthropic_endpoints` flag does not introduce new secret handling. Authentication continues to use the existing key secret via Bearer token, consistent with the existing OpenAI-compatible path.

## Checklist

- [x] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [x] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [x] I verified the CI pipeline passes locally if applicable
Sign up for free to 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.

3 participants