Skip to content

proxy,ui: split provider API surfaces#764

Open
olegshulyakov wants to merge 1 commit into
mostlygeek:mainfrom
olegshulyakov:feature/split-api-surfaces
Open

proxy,ui: split provider API surfaces#764
olegshulyakov wants to merge 1 commit into
mostlygeek:mainfrom
olegshulyakov:feature/split-api-surfaces

Conversation

@olegshulyakov

@olegshulyakov olegshulyakov commented May 16, 2026

Copy link
Copy Markdown
Contributor

Add canonical provider-prefixed API paths for OpenAI and Anthropic clients while keeping the existing shared /v1 routes available.

  • add /openai/v1 routes for OpenAI-compatible endpoints
  • add /anthropic/v1 routes for Anthropic-compatible endpoints
  • normalize provider-prefixed paths before proxying upstream
  • update the playground endpoint defaults and model panel API hints
  • document the new API surfaces
image

@coderabbitai

coderabbitai Bot commented May 16, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This PR introduces provider-specific API surfaces for llama-swap by registering canonical /openai/v1/... and /anthropic/v1/... routes alongside existing /v1/... paths. Incoming requests to provider-prefixed routes are normalized and proxied to shared upstream handlers. Documentation, proxy routing, comprehensive tests, and frontend endpoint type system and UI components are updated to support the new structure while maintaining backward compatibility.

Changes

API Surface Split & Provider-Specific Routes

Layer / File(s) Summary
Design Specification & Documentation
README.md, docs/2026-05-16-split-api-surfaces/PRD.md, docs/2026-05-16-split-api-surfaces/SPEC.md
Defines canonical OpenAI (/openai/v1) and Anthropic (/anthropic/v1) base paths, lists supported endpoints under each prefix, specifies path normalization behavior, documents backward-compatible legacy /v1/... routes, and outlines functional/non-functional requirements, user journeys, and implementation plan.
Proxy Route Registration & Path Normalization
proxy/proxymanager.go
Registers new POST/GET routes under /openai/v1/... and /anthropic/v1/... prefixes for chat, responses, completions, messages, count_tokens, embeddings, audio, images, and models. Adds normalizeProviderPrefixedPath helper that strips /openai or /anthropic prefixes. Applies normalization in JSON body proxy, multipart/form proxy, and GET model request handlers before sending upstream.
Test Infrastructure & Handler Coverage
proxy/helpers_test.go, proxy/proxymanager_test.go
Updates test responder helper to include request path in JSON output. Expands mock handler route mux to cover additional /v1/* endpoints. Adds four integration tests: OpenAI JSON routes normalize upstream path, OpenAI multipart/form routes normalize upstream path, Anthropic message routes normalize upstream path, and cross-provider route requests return 404 NotFound.
Frontend API Type System & Routing
ui-svelte/src/lib/chatApi.ts
Updates Endpoint type from legacy "v1/*" literals to canonical "openai/v1/chat/completions" | "anthropic/v1/messages" | "openai/v1/responses". Updates buildRequest and parseStream switch cases to route new endpoint values to corresponding request builders and SSE parsers. Updates streamChatCompletion default endpoint to "openai/v1/chat/completions".
Frontend UI & User Experience
ui-svelte/src/components/playground/ChatInterface.svelte, ui-svelte/src/components/ModelsPanel.svelte
ChatInterface changes default endpoint and selection options to canonical paths, adds $effect to migrate persisted obsolete endpoint values to their canonical equivalents. ModelsPanel adds endpoint display section with copy buttons showing curl commands for OpenAI- and Anthropic-compatible /models and /messages endpoints, with note about shared /v1 routes remaining available.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • mostlygeek/llama-swap#758: Updates chat endpoint mapping logic for /messages and /responses support that is directly adapted to provider-specific routes in this PR.
  • mostlygeek/llama-swap#476: Adds Anthropic count_tokens proxy support that is extended with provider-prefixed variant in this PR.
  • mostlygeek/llama-swap#417: Updates /v1/messages handler behavior that forms the basis for the upstream normalization target in this PR.

Suggested reviewers

  • mostlygeek
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% 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 'proxy,ui: split provider API surfaces' accurately reflects the main changes: splitting API surfaces across proxy and UI components to support provider-specific endpoints.
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.
Description check ✅ Passed The pull request description clearly explains the changeset: adding canonical provider-prefixed API paths (/openai/v1 and /anthropic/v1), normalizing paths before proxying, and updating UI defaults while retaining backward compatibility with shared /v1 routes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot 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.

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 `@README.md`:
- Line 32: The bullet "Shared `/v1/...` paths remain available for existing
clients." is currently nested under the Anthropic endpoints section and should
be moved out to a top-level position so it clearly applies to both OpenAI and
Anthropic surfaces; update README.md by removing the indentation/child-bullet
under the "Anthropic endpoints" block and place that exact bullet at the same
level as the main OpenAI/Anthropic headings (e.g., directly under the
compatibility or overview list) so its scope is unambiguous.

In `@ui-svelte/src/components/playground/ChatInterface.svelte`:
- Around line 41-49: The current $effect maps a few legacy keys via
obsoleteEndpoints but leaves any other stale/invalid $endpointStore values
untouched; update the effect in ChatInterface.svelte to validate $endpointStore
against the obsoleteEndpoints map and known canonical values and, if not
recognized, call endpointStore.set(...) to reset to a canonical default (e.g.
"openai/v1/chat/completions"); use the existing symbols ($effect,
obsoleteEndpoints, $endpointStore, endpointStore.set) to locate and implement
this fallback reset so unrecognized persisted endpoint values never pass
through.
🪄 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

Run ID: dd424aec-ba11-4ce1-86ba-aa8759aff8e1

📥 Commits

Reviewing files that changed from the base of the PR and between b2fcc2d and 76239fa.

📒 Files selected for processing (9)
  • README.md
  • docs/2026-05-16-split-api-surfaces/PRD.md
  • docs/2026-05-16-split-api-surfaces/SPEC.md
  • proxy/helpers_test.go
  • proxy/proxymanager.go
  • proxy/proxymanager_test.go
  • ui-svelte/src/components/ModelsPanel.svelte
  • ui-svelte/src/components/playground/ChatInterface.svelte
  • ui-svelte/src/lib/chatApi.ts

Comment thread README.md
Comment thread ui-svelte/src/components/playground/ChatInterface.svelte
@olegshulyakov

Copy link
Copy Markdown
Contributor Author

@mostlygeek please take a look

@mostlygeek

Copy link
Copy Markdown
Owner

Hi,

Could you share the problem this PR is looking to solve?

@olegshulyakov

Copy link
Copy Markdown
Contributor Author

@mostlygeek As a user, I want to

  • have a clear picture what API signatures do exist;
  • ability to setup tools to appropriate APIs.

For example, most apps use OpenAI API and work with them, while Anthropic ones require only theirs.

When I see "here is OpenAI API" and "here is Anthropic API", it makes me easy to get in.

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.

2 participants