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(string apiKey)
apiKey (string)

Properties

MaxTokens

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

Model

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

Provider

#
public AiProvider Provider { get; }
Provider

TranscriptCallback

#
public Action<string, string> TranscriptCallback { get; set; }
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.
TranscriptCallback

Methods

Generate

#
public Task<AiBackendResponse> Generate(AiMessage[] history, AiTool[] tools, CancellationToken cancellation)
history (AiMessage[])
tools (AiTool[])
cancellation (CancellationToken)
Generate