AnthropicGateway

class AnthropicGateway(apiKey: String, host: String = DEFAULT_ANTHROPIC_HOST, anthropicVersion: String = DEFAULT_ANTHROPIC_VERSION, engine: HttpClientEngine? = null, json: Json = DEFAULT_JSON) : LlmGateway

Ktor-Client backed gateway to the Anthropic Messages API.

Mirrors the Python reference (mojentic.llm.gateways.anthropic.AnthropicGateway) with Kotlin idioms (suspend, structured concurrency, Flow streaming) and the Kotlin-specific shape of the LlmGateway interface.

Parameters

apiKey

API key sent in the x-api-key header. Required.

host

Base URL of the Anthropic HTTP API. Override for Anthropic-compatible endpoints (e.g. AWS Bedrock proxies that speak the Anthropic protocol).

anthropicVersion

Value of the mandatory anthropic-version header.

engine

Optional Ktor engine override. Tests inject a MockEngine here.

json

Json codec used for request / response (de)serialisation.

Constructors

Link copied to clipboard
constructor(apiKey: String, host: String = DEFAULT_ANTHROPIC_HOST, anthropicVersion: String = DEFAULT_ANTHROPIC_VERSION, engine: HttpClientEngine? = null, json: Json = DEFAULT_JSON)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open suspend override fun availableModels(): List<String>
Link copied to clipboard
fun close()

Closes the underlying Ktor client.

Link copied to clipboard
open suspend override fun complete(model: String, messages: List<LlmMessage>, tools: List<LlmTool>?, config: CompletionConfig): LlmGatewayResponse
Link copied to clipboard
open suspend override fun completeJson(model: String, messages: List<LlmMessage>, schema: JsonObject, config: CompletionConfig): JsonObject
Link copied to clipboard
open suspend fun completeJsonResponse(model: String, messages: List<LlmMessage>, schema: JsonObject, config: CompletionConfig): LlmGatewayResponse
Link copied to clipboard
open override fun stream(model: String, messages: List<LlmMessage>, tools: List<LlmTool>?, config: CompletionConfig): Flow<GatewayStreamEvent>