feat: Multi-API format support (OpenAI Chat, Response API, Anthropic)#43
Merged
Conversation
- Define InternalMessage, InternalRequest, InternalResponse types - Define InternalStreamChunk for streaming response handling - Add UpstreamAdapter interface for provider communication - Add RequestAdapter/ResponseAdapter interfaces for format conversion - Implement adapter factory with getRequestAdapter, getResponseAdapter, getUpstreamAdapter functions Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add request adapters to convert incoming requests to internal format: - openai-chat.ts: OpenAI Chat Completion format - openai-response.ts: OpenAI Response API format - anthropic.ts: Anthropic Messages API format Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add response adapters to convert internal responses to client formats: - openai-chat.ts: Internal → OpenAI Chat Completion format - openai-response.ts: Internal → OpenAI Response API format - anthropic.ts: Internal → Anthropic Messages API format Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add upstream adapters for building requests to different providers: - openai.ts: Build requests for OpenAI-compatible APIs - openai-responses.ts: Build requests for OpenAI Response API - anthropic.ts: Build requests for Anthropic Claude API Also adds tools.ts for cross-format tool/function calling conversion. Includes SSE parsing fixes to handle both "data: " and "data:" formats for compatibility with various providers (e.g., Alibaba DashScope). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add 'anthropic' and 'openai-responses' to provider_type enum - Add api_version column to providers table (for Anthropic version header) - Add request_format column to completions table - Add raw_request JSONB column to store original request data Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add POST /v1/messages endpoint for Anthropic Messages API compatibility - Add POST /v1/responses endpoint for OpenAI Response API compatibility - Register new routes in api/index.ts Both endpoints support streaming and non-streaming modes with full format conversion to/from internal representation. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Refactor /v1/chat/completions to use the new adapter pattern for handling different upstream provider types (OpenAI, Anthropic, OpenAI Responses). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Support both authentication methods: - Authorization: Bearer <token> (OpenAI style) - x-api-key: <token> (Anthropic style) This allows Anthropic SDK clients to authenticate with NexusGate using their native authentication header format. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Support apiVersion field for Anthropic providers - Update provider testing to handle different provider types - Adjust model discovery for Anthropic and Response API providers Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add 'Anthropic' and 'OpenAI Responses' options to provider type selector - Add API Version input field for Anthropic providers - Update provider columns to display new types - Add i18n translations for new provider types (en-US, zh-CN) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Local Python test scripts for manual API testing. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
koitococo
reviewed
Jan 13, 2026
Backend changes: - Extract common API helpers to backend/src/utils/api-helpers.ts - extractUpstreamHeaders, selectModel, extractContentText - parseModelProvider, PROVIDER_HEADER, EXCLUDED_HEADERS - Replace t.Unknown() with specific type schemas in API endpoints - completions.ts: add tStreamOptions schema - messages.ts: add Anthropic content block, tool, and metadata types - responses.ts: add Response API input, tool, and metadata types Frontend changes: - Extract PROVIDER_TYPES constant to frontend/src/constants/providers.ts - Add PROVIDER_TYPE_LABELS for display names - Add requiresApiVersion() and getApiVersionPlaceholder() helpers - Update provider components to use shared constants This reduces code duplication and improves type safety. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add "reasoning" to ResponseApiOutput.type union (fixes TS2367) - Add @ts-expect-error for TextDecoderStream.pipeThrough compatibility issue in 4 SSE parser locations (fixes TS2345) - Remove unused @ts-expect-error directive in utils.ts (fixes TS2578) Backend now passes tsc --noEmit with no errors. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix JSDoc tag in api-helpers.ts (changed @Provider to description) - Remove unnecessary type argument in sse.ts - Add @ts-expect-error for Eden type imports in frontend api.ts Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This was
linked to
issues
Jan 13, 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.
Summary
This PR implements full multi-API format support for NexusGate, enabling:
Key Changes
Adapter Pattern Architecture: Introduced a clean adapter pattern with:
New API Endpoints:
POST /v1/messages- Anthropic Messages API compatible endpointPOST /v1/responses- OpenAI Response API compatible endpointAuthentication: Support for both
Authorization: Bearer(OpenAI) andx-api-key(Anthropic) headersDatabase Schema: Extended to support new provider types and track request formats
Frontend: Added provider type selection and API version configuration
API Format Support Matrix
Commits (11 atomic commits)
feat(adapters): add internal unified types and adapter factoryfeat(adapters): add request adapters for all API formatsfeat(adapters): add response adapters for all API formatsfeat(adapters): add upstream adapters and tool conversion utilitiesfeat(db): extend schema for multi-API format supportfeat(api): add Anthropic Messages and OpenAI Response API endpointsrefactor(api): update completions endpoint to use adapter patternfeat(auth): add x-api-key header support for Anthropic SDKfeat(admin): update provider management for new provider typesfeat(ui): add provider type selection and API version configchore: add python_test_code to gitignoreTest plan
🤖 Generated with Claude Code