ExAgent.Models.Anthropic (ExAgent v0.1.0)

Copy Markdown View Source

Anthropic Messages API provider, or any endpoint that speaks the same format (e.g. Z.AI's /api/anthropic, which serves GLM models natively in Anthropic form).

Two auth modes (mirroring the Anthropic SDK):

  • :api_key → sent as x-api-key (real Anthropic, ANTHROPIC_API_KEY).
  • :auth_token → sent as Authorization: Bearer (Z.AI coding plan, ANTHROPIC_AUTH_TOKEN).

Examples

# Real Anthropic
ExAgent.Models.Anthropic.new(model: "claude-3-5-haiku-20241022")

# Z.AI's Anthropic-compatible endpoint, cheap model
ExAgent.Models.Anthropic.new(
  model: "glm-4.5-air",
  auth_token: System.fetch_env!("ZAI_API_KEY"),
  base_url: "https://api.z.ai/api/anthropic"
)

Summary

Functions

Build an Anthropic model.

Types

t()

@type t() :: %ExAgent.Models.Anthropic{
  api_key: String.t() | nil,
  auth_token: String.t() | nil,
  base_url: String.t() | nil,
  model: String.t()
}

Functions

new(opts)

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

Build an Anthropic model.

Options: :model (required), :api_key, :auth_token, :base_url. :api_key falls back to ANTHROPIC_API_KEY.