Pixir.Providers.Anthropic (pixir v0.1.8)

Copy Markdown View Source

Anthropic Messages API transport core for Pixir's Provider seam.

This module accepts Anthropic-native request maps and returns the same assembled streamed shape the Turn loop consumes from providers. The OpenAI Responses implementation stays separate in Pixir.Provider; this namespace owns Anthropic request shaping, SSE event decoding, usage normalization, and transport selection.

Summary

Functions

Stream one Anthropic Messages API call over HTTP/SSE.

Types

request()

@type request() :: %{
  optional(:model) => String.t(),
  optional(:messages) => [map()],
  optional(:history) => [map()],
  optional(:system) => String.t() | [map()],
  optional(:system_prompt) => String.t(),
  optional(:tools) => [map()],
  optional(:max_tokens) => pos_integer(),
  optional(:reasoning_effort) => String.t() | atom()
}

result()

@type result() :: %{
  text: String.t(),
  reasoning: String.t(),
  reasoning_items: [map()],
  function_calls: [%{call_id: String.t(), name: String.t(), args: map()}],
  output_items: [reasoning: map(), function_call: map()],
  usage: map() | nil,
  usage_summary: map(),
  provider_metadata: map(),
  finish_reason: :stop | :tool_calls
}

Functions

stream(request, opts \\ [])

@spec stream(
  request(),
  keyword()
) :: {:ok, result()} | {:error, map()}

Stream one Anthropic Messages API call over HTTP/SSE.