AnthropicBackend

class AnthropicBackend(baseUrl: String, model: String, apiKey: String, systemPrompt: String = "", tools: List<AgentTool> = emptyList(), approver: ToolApprover = ToolApprover.AlwaysApprove, maxTokens: Int = 8192, maxSteps: Int = 8, client: OkHttpClient = DefaultHttpClient) : ChatBackend(source)

The Anthropic Messages API (POST /v1/messages, streaming), usable with api.anthropic.com or any Anthropic-compatible proxy.

Like dev.ai.elements.core.provider.openai.OpenAiChatBackend it runs the tool loop on-device. Thinking blocks (when the model emits them) are shown as reasoning and echoed back verbatim, with their signatures, on the next step as the API requires.

Constructors

Link copied to clipboard
constructor(baseUrl: String, model: String, apiKey: String, systemPrompt: String = "", tools: List<AgentTool> = emptyList(), approver: ToolApprover = ToolApprover.AlwaysApprove, maxTokens: Int = 8192, maxSteps: Int = 8, client: OkHttpClient = DefaultHttpClient)

Functions

Link copied to clipboard
open override fun stream(history: List<Message>): Flow<ChatEvent>