LlmCall.Client (llm_call v0.4.0)

Copy Markdown View Source

A provider, resolved for calling.

Built by a provider module's client/1, which turns the declaration plus the call options into concrete values: endpoint, headers (including auth), query parameters, transport options, timeout, and the %LlmCall.Config{} the codecs receive.

The client holds no selected codec: codecs is the provider's map, and each call names one (codec: :chat by default for complete/3 and stream/3).

Values are materialised at build time, so changing config :llm_call afterwards does not mutate an existing client; build a new one.

Timeout

timeout is the read timeout, handed to Finch as :receive_timeout: each body chunk must arrive within it, but it is not a deadline for the whole call. A large response on a slow link, or a provider that keeps sending, can outlast it. For a wall-clock cap, pass Finch's total timeout through http_opts: [request_timeout: ...]. On an HTTP/1 pool it is checked between reads, so a streaming call's effective bound is request_timeout plus one timeout; Finch implements it on HTTP/2 as a wall-clock timer for the whole response, where the bound is request_timeout itself.

Summary

Functions

The codec registered under name, or nil.

The codec registered under name; raises when the provider does not declare it.

Types

t()

@type t() :: %LlmCall.Client{
  base_url: String.t(),
  codecs: %{required(atom()) => module()},
  config: LlmCall.Config.t(),
  credentials: nil | map() | (-> map()),
  headers: [{String.t(), String.t()}],
  http_opts: keyword(),
  provider: module(),
  query: %{optional(String.t()) => String.t() | integer() | boolean()},
  signer: nil | %{service: String.t(), region: String.t()},
  timeout: timeout()
}

Functions

codec(client, name)

@spec codec(t(), atom()) :: module() | nil

The codec registered under name, or nil.

codec!(client, name)

@spec codec!(t(), atom()) :: module()

The codec registered under name; raises when the provider does not declare it.