Repository navigation
feat: support Anthropic Messages API format in the Custom post-processing provider - #2257
Open
diligentpig wants to merge 2 commits into
Open
diligentpig wants to merge 2 commits into
diligentpig wants to merge 2 commits into
Conversation
…sing provider Endpoints such as Claude on Microsoft Foundry only speak the Anthropic Messages API, so the Custom provider (OpenAI Chat Completions only) could not reach them. An "API Format" option on the Custom provider lets users pick the request format without adding a provider per hosting service. OpenAI Compatible stays the default and its request path is unchanged. Discussion: cjpais#2250 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The translation consistency check requires every locale to carry the new keys. Also sync the section title and provider description so no locale still describes the API section as OpenAI-only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
This works, thanks, I will take a look and pull in when I have a chance |
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.
Before Submitting This PR
Please submit only one fix or feature per pull request. Pull requests containing multiple fixes or features will likely be closed.
Please confirm you have done the following:
If this is a feature or change that was previously closed/rejected:
Human Written Description
I've deployed both the OpenAI GPT model and the Anthropic Claude model in Microsoft Foundry. While gpt model is supported by the Custom provider in post process, the claude model's Anthropic Messages API format is not supported currently.
It would be great if the Custom provider could support the Anthropic Messages API format, which could benefit both online models and future local models.
Implementation notes
As discussed in #2250, I tried to keep this as small as possible:
Dropdown/SettingContainerpattern, so no new UI components.api_formatdefaults toopenaivia#[serde(default)], so existing settings load as before without any migration. Built-in providers always useopenai, and only the Custom provider can change it.send_chat_completionhands off to a newsend_anthropic_messageonly when the format isanthropic. The Chat Completions request/response code is not modified. The other change is inbuild_headers: the Anthropic format usesx-api-key+anthropic-version, like the built-in Anthropic provider.max_tokens(required by the Messages API), and the response joins thetextblocks. The Custom provider never uses structured output and Claude doesn't think unless asked, so there's no schema or reasoning handling. API key auth only./modelsworks on Anthropic's own API now that the headers are right. Microsoft Foundry doesn't offer the Models API (documented here), so the list stays empty there and the deployment name is typed in, which the model field already supports.Small wording changes so the labels stay accurate (applied to all locales; translations for the new strings were added for every language, so a native-speaker check would be welcome):
API (OpenAI Compatible)→API. With two formats the parenthetical was no longer accurate, and Apple Intelligence was already listed under it. A plain title also won't need updating if another format is ever added.Select an OpenAI-compatible provider.→Select an OpenAI-compatible or Anthropic-compatible provider.https://api.anthropic.com/v1for the Anthropic format. As now, the URL is entered up to/v1and Handy appends the endpoint path.I'm happy to adjust naming, placement, or wording, or trim anything further if you'd prefer. As mentioned in the discussion, I'm also glad to help with any bugs that come up around this.
Related Issues/Discussions
Discussion: #2250
Related: #1386 (closed as a feature request rather than a bug, with a note that a PR could be submitted)
Community Feedback
Testing
Tested in
bun run tauri devon macOS 26.6 (Apple Silicon):https://<resource>.services.ai.azure.com/anthropic/v1). Post-processing returns 200 and the text is pasted correctly. The model name is entered manually, as noted above.cargo test(all pass, including 4 new tests for the Anthropic headers, request body, response parsing, and a mock round trip),cargo fmt --check,cargo clippy,bun run lint,prettier --check.Not tested: Anthropic's own API directly (I don't have a key). Help testing there would be appreciated.
Screenshots/Videos (if applicable)
AI Assistance
If AI was used:
🤖 Generated with Claude Code (Claude Opus 5.5, high effort)