Skip to content

Conversation

@Cozmopolit
Copy link
Contributor

Motivation and Context

This PR adds a native Anthropic connector for Semantic Kernel, enabling direct integration with Claude models.

Why is this change required?

  • Anthropic's Claude models are among the leading LLMs, but SK currently lacks native support
  • Microsoft recently started offering Anthropic models on Azure, making this connector increasingly relevant
  • Users currently need to implement custom solutions or use workarounds

What problem does it solve?

  • Provides first-class Claude model support in Semantic Kernel
  • Enables consistent SK patterns (function calling, filters, telemetry) with Anthropic models
  • Supports both direct Anthropic API and Azure-hosted Anthropic endpoints

What scenario does it contribute to?

  • Developers building multi-model applications who want to use Claude alongside other models
  • Azure customers who want to use Anthropic models through their existing Azure infrastructure
  • Anyone who needs Claude's capabilities with SK's function calling and agent patterns

Description

This PR introduces a complete Anthropic connector with full feature parity to other SK connectors.

Implementation approach:

  • Aligned with existing SK patterns - Structure and code closely follows the .NET OpenAI Connector and the Python Anthropic Connector for consistency
  • Anthropic SDK Integration - Built on top of the official Anthropic .NET SDK (Anthropic.SDK NuGet package)
  • Dual Endpoint Support - Works with both direct Anthropic API and Anthropic models on Azure
  • Full Feature Parity - Chat completion, streaming, function calling, multi-modal (images), prompt execution settings
  • SK Integration Patterns - Follows established SK patterns for service registration, filters, telemetry, and activity tracing
  • FunctionChoiceBehavior Support - Full auto function calling with filters (IAutoFunctionInvocationFilter)

Supported Prompt Execution Settings:

  • ModelId, MaxTokens, Temperature, TopP, TopK
  • StopSequences, SystemPrompt
  • FunctionChoiceBehavior (Auto, Required, None)

Testing:

The connector includes 157 unit tests covering chat completion, function calling with filters, streaming, multi-modal content, error handling, and settings serialization.

Contribution Checklist

Adds a new connector for Anthropic's Claude models with full feature parity
to other SK connectors:

Features:
- Chat completion (streaming and non-streaming)
- Auto function calling with proper text and usage aggregation
- Tool/function definitions and invocation
- Multi-modal support (images)
- Prompt execution settings (temperature, top_p, max_tokens, etc.)
- Auto function invocation filters
- Telemetry and activity tracing

Key implementation details:
- Text content generated before tool calls is preserved across iterations
- Token usage (InputTokens, OutputTokens, TotalTokens) is aggregated across
  all function calling iterations
- All exit points (normal completion, filter termination, max iterations)
  correctly apply aggregated values
- Defensive validation for API response edge cases

Includes comprehensive unit tests (157 tests) covering:
- Chat completion scenarios
- Function calling with filters
- Streaming behavior
- Text and usage aggregation
- Error handling
@Cozmopolit Cozmopolit requested a review from a team as a code owner December 16, 2025 16:06
@moonbox3 moonbox3 added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel labels Dec 16, 2025
@github-actions github-actions bot changed the title feat(.Net): Add Anthropic Connector for Claude models .Net: feat(.Net): Add Anthropic Connector for Claude models Dec 16, 2025
@Cozmopolit Cozmopolit changed the title .Net: feat(.Net): Add Anthropic Connector for Claude models .Net: feat: Add Anthropic Connector for Claude models Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants