View Source Anthropic.Models (anthropic_community v0.5.0)

The Models resource: list and retrieve available Claude models.

Summary

Functions

Lists available models, most recently released first.

Like list/2, but returns a lazy Stream of individual model maps that transparently fetches subsequent pages as it's consumed, instead of one page at a time.

Retrieves a single model by id.

Types

@type list_opts() :: [
  before_id: String.t(),
  after_id: String.t(),
  limit: pos_integer()
]
@type list_result() :: %{
  data: [map()],
  has_more: boolean(),
  first_id: String.t() | nil,
  last_id: String.t() | nil
}

Functions

Link to this function

list(client, opts \\ [])

View Source
@spec list(Anthropic.Client.t(), list_opts()) ::
  {:ok, list_result()} | {:error, Anthropic.Error.t()}

Lists available models, most recently released first.

Examples

{:ok, %{data: models}} = Anthropic.Models.list(client)
Link to this function

list_all(client, opts \\ [])

View Source
@spec list_all(Anthropic.Client.t(), list_opts()) :: Enumerable.t()

Like list/2, but returns a lazy Stream of individual model maps that transparently fetches subsequent pages as it's consumed, instead of one page at a time.

Examples

client
|> Anthropic.Models.list_all()
|> Enum.each(&IO.puts(&1["id"]))
Link to this function

retrieve(client, model_id)

View Source
@spec retrieve(Anthropic.Client.t(), model_id :: String.t()) ::
  {:ok, map()} | {:error, Anthropic.Error.t()}

Retrieves a single model by id.