You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
api.githubcopilot.com/v1/messages natively accepts Anthropic Messages API requests for Claude 4.5+ models. We need a new service module that forwards requests directly, bypassing the OpenAI translation layer.
Goal
src/services/copilot/create-messages-native.ts — sends an Anthropic Messages payload straight to ${copilotBaseUrl(state)}/v1/messages and returns the raw Anthropic response.
Accept AnthropicMessagesPayload (from anthropic-types.ts) as input — no transformation
Build Copilot auth headers the same way other service modules do (Authorization Bearer, copilot-integration-id, editor-version, user-agent, x-github-api-version, x-request-id, x-vscode-user-agent-library-version)
Forward client's anthropic-version header if present (default: "2023-06-01")
POST to ${copilotBaseUrl(state)}/v1/messages
Non-streaming: return raw parsed AnthropicMessagesResponse JSON
Streaming: return the raw SSE byte stream to be piped directly to the client (no re-parsing needed — Copilot SSE events are already in Anthropic format)
Part of #38.
Background
api.githubcopilot.com/v1/messagesnatively accepts Anthropic Messages API requests for Claude 4.5+ models. We need a new service module that forwards requests directly, bypassing the OpenAI translation layer.Goal
src/services/copilot/create-messages-native.ts— sends an Anthropic Messages payload straight to${copilotBaseUrl(state)}/v1/messagesand returns the raw Anthropic response.Tasks
src/services/copilot/create-messages-native.ts:AnthropicMessagesPayload(fromanthropic-types.ts) as input — no transformationanthropic-versionheader if present (default:"2023-06-01")${copilotBaseUrl(state)}/v1/messagesAnthropicMessagesResponseJSONNATIVE_ANTHROPIC_MODELSconstant (initial hardcoded set; replaced by dynamic detection in feat: Dynamic NATIVE_ANTHROPIC_MODELS detection from /models endpoint (vendor-based) #42):HTTPErrorclass (src/lib/error.ts)state.showTokenfor debug logging (same pattern as other service modules)Upstream SSE events returned (verified by live test)
Note: upstream returns
data: [DONE]at the end (same as OpenAI). Pass it through — Anthropic SDK clients ignore it.Acceptance criteria
createMessagesNative({model: "claude-sonnet-4.5", ...})returns a validAnthropicMessagesResponsewithcontentarraystream: true, the client receives SSE events with correctevent:prefix linessignatureare preserved byte-exact in pass-throughNATIVE_ANTHROPIC_MODELS)File pointers
src/services/copilot/create-messages-native.tssrc/services/copilot/create-chat-completions.ts(header pattern)src/routes/messages/anthropic-types.ts(may needsignaturefield added toAnthropicThinkingBlock)