Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add provider Azure Anthropic#5151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
hugentobler wants to merge2 commits intotensorzero:main
base:main
Choose a base branch
Loading
fromhugentobler:main

Conversation

@hugentobler
Copy link

@hugentoblerhugentobler commentedDec 12, 2025
edited by ellipsis-devbot
Loading

Hi I started off on a new azure-anthropic provider, using a new azure /anthropic/messages endpoint. Borrowed heavily from gcp-vertex-anthropic provider example. Not yet added all the tests yet. Want to see if you guys agree with the direction first.

The solution I implemented is using the /anthropic/messages endpoint on Azure. It's basically a wrapper around vanilla Anthropic API request and response.

Azure also has a separate direction that supports a unified response format for both OpenAI and Anthropic models - using the Responses API.Here is an illustration of what that looks like.

What do you guys think. Look good to you? Then I will add all the tests.


Important

Add Azure Anthropic provider for handling API requests with support for non-streaming and streaming inference.

  • Behavior:
    • AddsAzureAnthropicProvider inazure_anthropic.rs for handling Azure Anthropic API requests.
    • Supports non-streaming and streaming inference; batch inference is not supported.
    • Uses/anthropic/messages endpoint with Azure-specific configurations.
  • Configuration:
    • AddsAzureAnthropicProviderTypeConfig toprovider_types.rs.
    • IntroducesAzureAnthropicCredentials for handling API keys with support for static, dynamic, and fallback credentials.
  • Model Integration:
    • UpdatesProviderConfig inmodel.rs to includeAzureAnthropic.
    • ImplementsAzureAnthropicKind inmodel_table.rs for credential management.
  • Misc:
    • Adds tests forAzureAnthropicRequestBody andget_default_max_tokens() inazure_anthropic.rs.

This description was created byEllipsis forb313e34. You cancustomize this summary. It will automatically update as commits are pushed.

ellipsis-dev[bot] reacted with rocket emoji
CopilotAI review requested due to automatic review settingsDecember 12, 2025 00:22
@github-actions
Copy link
Contributor

github-actionsbot commentedDec 12, 2025
edited
Loading

All contributors have signed the CLA ✍️ ✅
Posted by theCLA Assistant Lite bot.

@hugentobler
Copy link
Author

I have read the Contributor License Agreement (CLA) and hereby sign the CLA.

@hugentobler
Copy link
Author

recheck

github-actionsbot added a commit that referenced this pull requestDec 12, 2025
Copy link
Contributor

CopilotAI 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 adds a new Azure Anthropic provider that enables the TensorZero Gateway to interact with Anthropic models hosted on Azure. The implementation follows the pattern established by the GCP Vertex Anthropic provider and uses Azure's/anthropic/messages endpoint, which wraps the standard Anthropic API.

Key Changes:

  • New provider implementation supporting Azure's Anthropic Claude models (claude-haiku-4-5, claude-opus-4-1, claude-sonnet-4-5, claude-opus-4-5)
  • Support for core features including streaming, tools, thinking blocks, and JSON mode
  • Integration with existing credential and endpoint management systems

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 10 comments.

Show a summary per file
FileDescription
tensorzero-core/src/providers/azure_anthropic.rsNew provider implementation with request/response handling, streaming support, and basic tests
tensorzero-core/src/providers/mod.rsAdds azure_anthropic module to the providers list
tensorzero-core/src/model_table.rsRegisters AzureAnthropic provider type and implements credential management
tensorzero-core/src/model.rsIntegrates AzureAnthropicProvider into the model configuration and inference routing
tensorzero-core/src/config/provider_types.rsAdds configuration structure with default AZURE_ANTHROPIC_API_KEY environment variable
.gitignoreAdds dev-config/ directory to ignored paths

Comment on lines +889 to +896
// TODO: Implement test_from_tool
// This test should verify that AnthropicTool is correctly created from a FunctionToolConfig
// See gcp_vertex_anthropic.rs for reference implementation
#[tokio::test]
async fn test_from_tool() {
// TODO: Test tool conversion from FunctionToolConfig to AnthropicTool
// Should test both dynamic and static tool configs
}

Choose a reason for hiding this comment

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

This TODO test for tool conversion is critical for verifying that tools work correctly with the Azure Anthropic provider. Given that other similar providers in the codebase have this test implemented, this should be completed before merging to ensure feature parity and prevent potential issues with tool usage.

Copilot uses AI. Check for mistakes.
Comment on lines +908 to +917
// TODO: Implement test_initialize_anthropic_request_body
// This test should verify request body construction with various configurations
// See gcp_vertex_anthropic.rs for reference implementation
#[tokio::test]
async fn test_initialize_anthropic_request_body() {
// TODO: Test case 1: Empty message list (should error)
// TODO: Test case 2: Messages with system message
// TODO: Test case 3: Messages with temperature, top_p, max_tokens
// TODO: Test case 4: Tool use & choice
}

Choose a reason for hiding this comment

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

This TODO test for request body initialization should verify critical functionality including system messages, temperature, top_p, max_tokens, and tool use. These are core features that need testing before production use.

Copilot uses AI. Check for mistakes.
Comment on lines +945 to +950
// TODO: Implement test_prefill_json_message
// This test should verify JSON prefill functionality
#[test]
fn test_prefill_json_message() {
// TODO: Test that prefill_json_message adds an assistant message with "{"
}

Choose a reason for hiding this comment

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

This TODO test for JSON prefill functionality should verify that the JSON mode works correctly by adding the appropriate prefix. This is particularly important given the inconsistency with other Anthropic providers noted elsewhere.

Copilot uses AI. Check for mistakes.
text: String,
},
Thinking {
thinking: String,

Choose a reason for hiding this comment

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

The Thinking content block is missing the signature field that is present in the standard Anthropic provider. According to the Anthropic API, thinking blocks should include both the thinking text and a signature field. This omission could lead to incomplete data being captured from Azure Anthropic responses. The struct should match the standard AnthropicContentBlock which has both thinking and signature fields.

Suggested change
thinking:String,
thinking:String,
signature:String,

Copilot uses AI. Check for mistakes.
Comment on lines +633 to +640
AzureAnthropicContentBlock::Thinking { thinking } => {
Ok(ContentBlockOutput::Thought(Thought {
text: Some(thinking),
signature: None,
summary: None,
provider_type: Some(PROVIDER_TYPE.to_string()),
}))
}

Choose a reason for hiding this comment

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

The conversion of Thinking blocks sets signature to None, but the standard Anthropic provider expects a signature field. This inconsistency with the Anthropic API spec could result in data loss when Azure Anthropic returns thinking blocks with signatures.

Copilot uses AI. Check for mistakes.
id: String,
name: String,
input: Value,
},

Choose a reason for hiding this comment

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

The AzureAnthropicContentBlock enum is missing the RedactedThinking variant that exists in both the standard Anthropic and GCP Vertex Anthropic providers. If Azure Anthropic can return redacted thinking blocks (where the thinking content is hidden but metadata is provided), this provider will fail to deserialize such responses. Consider adding the RedactedThinking variant for API completeness.

Suggested change
},
},
RedactedThinking{
reason:Option<String>,
},

Copilot uses AI. Check for mistakes.
Comment on lines +445 to +453
fn prefill_json_message(mut messages: Vec<AnthropicMessage>) -> Vec<AnthropicMessage> {
messages.push(AnthropicMessage {
role: AnthropicRole::Assistant,
content: vec![FlattenUnknown::Normal(AnthropicMessageContent::Text {
text: "{",
})],
});
messages
}

Choose a reason for hiding this comment

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

The JSON prefill message implementation differs from the standard Anthropic and GCP Vertex Anthropic providers. The standard prefill adds "Here is the JSON requested:\n{" while this implementation only adds "{". This inconsistency could lead to different behavior between providers when using JSON mode. Consider using the same prefill text as the other Anthropic-based providers for consistency.

Copilot uses AI. Check for mistakes.
Comment on lines +898 to +906
// TODO: Implement test_try_from_content_block
// This test should verify content block conversions (text, tool calls, tool results)
// See gcp_vertex_anthropic.rs for reference implementation
#[tokio::test]
async fn test_try_from_content_block() {
// TODO: Test text content block conversion
// TODO: Test tool call content block conversion
// TODO: Test tool result content block conversion
}

Choose a reason for hiding this comment

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

This TODO test for content block conversion is critical for ensuring that text content, tool calls, and tool results are correctly handled. These conversions are essential for proper functioning of the provider, especially when using tools or processing structured outputs.

Copilot uses AI. Check for mistakes.
Comment on lines +934 to +943
// TODO: Implement test_azure_anthropic_response_conversion
// This test should verify full response conversion from AzureAnthropicResponse
// See gcp_vertex_anthropic.rs for reference implementation
#[test]
fn test_azure_anthropic_response_conversion() {
// TODO: Test case 1: Text response
// TODO: Test case 2: Tool call response
// TODO: Test case 3: Thinking block response
// TODO: Test case 4: Mixed content response
}

Choose a reason for hiding this comment

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

This TODO test for response conversion should verify correct handling of text responses, tool calls, thinking blocks, and mixed content. This is important for ensuring that various response types from Azure Anthropic are properly converted to the internal format.

Copilot uses AI. Check for mistakes.
Comment on lines +952 to +958
// TODO: Implement test_azure_anthropic_apply_inference_params
// This test should verify inference params are applied correctly
#[test]
fn test_azure_anthropic_apply_inference_params() {
// TODO: Test thinking_budget_tokens is applied
// TODO: Test that reasoning_effort and service_tier emit warnings
}

Choose a reason for hiding this comment

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

This TODO test for inference params application should verify that thinking_budget_tokens is correctly applied and that unsupported parameters like reasoning_effort and service_tier emit appropriate warnings.

Copilot uses AI. Check for mistakes.
@hugentoblerhugentobler marked this pull request as draftDecember 12, 2025 02:51
@virajmehta
Copy link
Member

Hi@hugentobler, thanks for the PR. I haven't reviewed thoroughly yet but just based on what you said I support the current approach. In my opinion, the less magical & stateful the integration the better.

@hugentobler
Copy link
Author

Thanks@virajmehta so to confirm todos before I resume:

  • Complete unit tests in azure-anthropic.rs
  • Add docs page/docs/integrations/model-providers/azure-anthropic
  • Add azure-anthropic e2e test config and test case, withAZURE_ANTHROPIC_API_KEY andAZURE_ANTHROPIC_ENDPOINT

Do I need to generate any sdk type bindings?

@GabrielBianconi
Copy link
Member

@hugentobler Does Azure Anthropic require a different API key vs. regular Azure? If it's re-usable, let's just re-use the same env var. If it's different, the naming convention above is fine.

You'll likely need to generate bindings for TypeScript:cd internal/tensorzero-node && pnpm build-bindings && pnpm -r build

This will force you to edit some assorted files likeui/app/utils/providers.ts. If you search the codebase for some long-tail provider e.g.groq, you'll see some files you might need to edit. (Once the implementation is more fleshed out, we can run CI and sweep the codebase to see if there's anything else missing.)

hugentobler reacted with thumbs up emoji

@hugentobler
Copy link
Author

@GabrielBianconi Probably it is using the same azure key. The reason I suggested another key is coz the current default azure key isAZURE_OPENAI_API_KEY. Which might be confusing. Wdyt

@GabrielBianconi
Copy link
Member

@hugentobler Good point, I forgot that. Azure is actually deprecating "OpenAI Service", so might as well deprecate that in favor ofAZURE_API_KEY.#5178

You can useAZURE_API_KEY. Unless you want to tackle this issue too. :)

@hugentobler
Copy link
Author

hugentobler commentedDec 13, 2025
edited
Loading

@GabrielBianconi OK good I will catch up to#5178 and follow that style
May handle it as well if I get around to it before you

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

Copilot code reviewCopilotCopilot left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@hugentobler@virajmehta@GabrielBianconi

[8]ページ先頭

©2009-2025 Movatter.jp