IAiBackend
ReferencesAbstraction 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
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.
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.Parameters:
| history (AiMessage[]) | |
| tools (AiTool[]) | |
| cancellation (CancellationToken) |