Class AnthropicProvider
Transport for Anthropic's Messages API (POST {baseUrl}/v1/messages).
Maps to Anthropic's messages/tools/
tool_use/tool_result content-block model and parses
from the standard response envelope.
Streaming is true SSE — content blocks are reassembled from
content_block_start/content_block_delta/content_block_stop
events; tool-use blocks accumulate partial JSON in input_json_delta
and surface as a single complete at the end
of their block.
Error mapping: HTTP 429 → (honours
retry-after); HTTP 529 ("overloaded") and HTTP 5xx →
. Other failures surface as
.
public sealed class AnthropicProvider : ILlmProvider
Inheritance
Implements
Properties
ProviderId
Provider identifier ("anthropic", "openai", "stub", ...).
public string ProviderId { get; }
Methods
CompleteAsync(LlmRequest, CancellationToken)
Performs a single non-streaming completion call.
public Task<LlmResponse> CompleteAsync(LlmRequest request, CancellationToken ct = default)
StreamAsync(LlmRequest, CancellationToken)
Anthropic SSE streaming. Pieces are yielded as they arrive: visible text as , the
public IAsyncEnumerable<LlmStreamChunk> StreamAsync(LlmRequest request, CancellationToken ct = default)
Constructors
AnthropicProvider(LlmConnectionFactory, HttpClient)
Creates the provider with an externally owned HttpClient.
AnthropicProvider(LlmConnectionFactory)
Creates the provider with a connection factory (builds an internal HttpClient).