Skip to content

Comments

dont allow image urls in messages api#3960

Open
justschen wants to merge 1 commit intomainfrom
justin/darumaka
Open

dont allow image urls in messages api#3960
justschen wants to merge 1 commit intomainfrom
justin/darumaka

Conversation

@justschen
Copy link
Contributor

@justschen justschen commented Feb 24, 2026

there is an issue where messages API does not suppoort image url attachments for some reason.

pending disucssion with capi/anthropic. DO NOT MERGE YETTTTT

554-Darumaka

@justschen justschen marked this pull request as ready for review February 24, 2026 02:31
Copilot AI review requested due to automatic review settings February 24, 2026 02:31
@vs-code-engineering vs-code-engineering bot added this to the February 2026 milestone Feb 24, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a compatibility issue where the Anthropic Messages API endpoint (RequestType.ChatMessages) does not support HTTP(S) image URL attachments, only base64 data URLs. The fix excludes the Messages API from the image URL upload code path, ensuring images are sent as base64 data URLs instead.

Changes:

  • Modified image upload logic to exclude Messages API from URL-based image uploads
  • Renamed variable from isChatRequest to isCopilotRequest (though the naming could be clearer)
  • Added comment explaining the exclusion of Messages API
Comments suppressed due to low confidence (3)

src/extension/prompts/node/panel/image.tsx:99

  • The function modelCanUseImageURL (chatModelCapabilities.ts:181) always returns true, but this is misleading given that the Messages API endpoint doesn't support HTTP(S) image URLs. Consider either:
  1. Renaming it to clarify it checks model capabilities, not endpoint capabilities (e.g., modelSupportsVisionImages)
  2. Extending it to accept an optional endpoint parameter to check both model and endpoint compatibility
  3. Creating a separate function like endpointSupportsImageURLs that checks the RequestType

This would make the code more maintainable and reduce the need for manual endpoint checking in multiple places.

This issue also appears in the following locations of the same file:

  • line 97
  • line 96
			if (isCopilotRequest && enabled && modelCanUseImageURL(this.promptEndpoint)) {

src/extension/prompts/node/panel/image.tsx:97

  • The variable name isCopilotRequest is misleading. RequestType.ChatCompletions and RequestType.ChatResponses are also "Copilot requests" in the same way that RequestType.ChatMessages is. This variable now represents "requests that support image URL uploads", not generic "Copilot requests". Consider renaming to something more descriptive like supportsImageURLUpload or isChatCompletionsOrResponses to accurately reflect what it checks.
			const isCopilotRequest = typeof this.promptEndpoint.urlOrRequestMetadata !== 'string' && (this.promptEndpoint.urlOrRequestMetadata.type === RequestType.ChatCompletions || this.promptEndpoint.urlOrRequestMetadata.type === RequestType.ChatResponses);

src/extension/prompts/node/panel/image.tsx:96

  • The comment "exclude messages API for now since it causes issues" is too vague and doesn't explain the root cause. The actual issue is that the Anthropic Messages API only accepts base64-encoded images (data URLs), not HTTP(S) URLs for images. The messagesApi.ts conversion function (rawContentToAnthropicContent) only handles data URLs by extracting base64 content from them. Consider updating the comment to: "Exclude Messages API - it only supports base64 data URLs, not HTTP(S) URLs for images (see messagesApi.ts rawContentToAnthropicContent)".
			// exclude messages API for now since it causes issues

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