Anthropic.Client (SkillKit v0.1.0)

Copy Markdown View Source

Struct holding Anthropic API connection configuration.

Used by Anthropic.stream/3 to build HTTP requests. Struct-based so tests can pass config directly without global state.

Summary

Functions

Creates a new client from a keyword list. :api_key is required.

Sends a streaming request to the Anthropic Messages API.

Types

t()

@type t() :: %Anthropic.Client{api_key: String.t(), endpoint: String.t()}

Functions

new(opts)

@spec new(keyword()) :: t()

Creates a new client from a keyword list. :api_key is required.

stream(client, messages, opts \\ [])

@spec stream(t(), [map()], keyword()) :: {:ok, Enumerable.t()} | {:error, term()}

Sends a streaming request to the Anthropic Messages API.

Returns {:ok, Enumerable.t()} where each element is a parsed JSON map from an SSE data: line. Non-data lines are skipped.

opts are merged into the request body (e.g. model, max_tokens).