IAiBackend

References
public interface IAiBackend
Abstraction over an LLM provider. Implementations wrap the actual HTTP + JSON dance for a specific service (Anthropic, OpenAI, Google, OpenRouter, ...) or for a development stand-in like the play-act backend.

Properties

Provider

#
AiProvider Provider { get; }
Gets the provider associated with this backend.

TranscriptCallback

#
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.

Methods

Generate

#
Task<AiBackendResponse> Generate(AiMessage[] history, AiTool[] tools, CancellationToken cancellation)
Generate the next turn for the conversation. The full message history is passed on every call, the wire protocol is stateless. tools declares which tools the model is allowed to invoke this turn.
history (AiMessage[])
tools (AiTool[])
cancellation (CancellationToken)