AnthropicAiBackend

public sealed class AnthropicAiBackend : IAiBackend
IAiBackend implementation talking to Anthropic's Messages API directly over HTTPS. Supports tool use and prompt caching of the system block, which gives a ~10x cost reduction on cached input tokens once the cache is warm.

Constructors

AnthropicAiBackend

#
public AnthropicAiBackend(
apiKey
)

Properties

MaxTokens

#
Maximum tokens the model may produce in a single turn.
public int MaxTokens { get; set; }

Model

#
Model identifier passed to the API. Defaults to the latest Opus.
public string Model { get; set; }

Provider

#
public AiProvider Provider { get; }
Provider

TranscriptCallback

#
Optional hook invoked with (requestJson, responseBody) after every HTTP exchange, including non-2xx responses and retries. The host uses this to maintain a complete transcript of what was sent and received. Backends must invoke this before throwing on non-success status codes.
public Action<string, string> TranscriptCallback { get; set; }
TranscriptCallback

Methods

Generate

#
public Task<AiBackendResponse> Generate(
history,
tools,
cancellation
)
Generate