Migrate from Anthropic.SDK to official Anthropic package (#1083)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
This commit is contained in:
Copilot 2025-12-10 08:58:41 -05:00 • committed by GitHub
commit f9239b0fb7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,4 @@
using Anthropic.SDK;
using Anthropic;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
@ -41,8 +41,8 @@ foreach (var tool in tools)
Console.WriteLine($"Connected to server with tools: {tool.Name}");
}
using var anthropicClient = new AnthropicClient(new APIAuthentication(builder.Configuration["ANTHROPIC_API_KEY"]))
.Messages
using var anthropicClient = new AnthropicClient(new() { APIKey = builder.Configuration["ANTHROPIC_API_KEY"] })
.AsIChatClient("claude-haiku-4-5-20251001")
.AsBuilder()
.UseFunctionInvocation()
.Build();