(chat & [opts])Create a stateful chat session. Returns a map with :send! and :history functions.
Options: :provider :model :system :tools :max-tokens
Create a stateful chat session. Returns a map with :send! and :history functions. Options: :provider :model :system :tools :max-tokens
(complete req)Call the LLM and return a normalized response map.
Request keys: :provider - :openai or :anthropic (required) :model - model string (optional, defaults to provider's default) :messages - vector of {:role :user/:assistant, :content "..."} (required) :system - system prompt string (optional) :tools - vector of tool defs {:name :description :parameters :fn} (optional) :max-tokens - max tokens in response (default 4096)
Response keys: :content - string text of response (nil if only tool calls) :tool-calls - vector of {:id :name :arguments} (nil if no tool calls) :stop-reason - :stop :tool-calls :length :content-filter :usage - {:input-tokens N :output-tokens N} :raw - original provider response
Call the LLM and return a normalized response map.
Request keys:
:provider - :openai or :anthropic (required)
:model - model string (optional, defaults to provider's default)
:messages - vector of {:role :user/:assistant, :content "..."} (required)
:system - system prompt string (optional)
:tools - vector of tool defs {:name :description :parameters :fn} (optional)
:max-tokens - max tokens in response (default 4096)
Response keys:
:content - string text of response (nil if only tool calls)
:tool-calls - vector of {:id :name :arguments} (nil if no tool calls)
:stop-reason - :stop :tool-calls :length :content-filter
:usage - {:input-tokens N :output-tokens N}
:raw - original provider response(complete-stream req)Like complete but streams SSE events as a lazy seq.
Like complete but streams SSE events as a lazy seq.
(key-status req)Get the current rate-limit standing for a provider's API key. req: {:provider :anthropic :model "..."} (:model optional). Currently implemented for :anthropic only — makes a minimal request and returns the provider's rate-limit response headers as {:requests {:limit :remaining :reset} :tokens {...} :input-tokens {...} :output-tokens {...}}.
Full billing/cost data requires an Anthropic Admin API key (ANTHROPIC_ADMIN_API_KEY, distinct from a standard API key) — see hyperphor.ellum.providers.anthropic/usage-report and /cost-report.
Get the current rate-limit standing for a provider's API key.
req: {:provider :anthropic :model "..."} (:model optional).
Currently implemented for :anthropic only — makes a minimal request and
returns the provider's rate-limit response headers as
{:requests {:limit :remaining :reset} :tokens {...} :input-tokens {...} :output-tokens {...}}.
Full billing/cost data requires an Anthropic Admin API key
(ANTHROPIC_ADMIN_API_KEY, distinct from a standard API key) — see
hyperphor.ellum.providers.anthropic/usage-report and /cost-report.(list-models provider)List available models for a provider (:openai or :anthropic). Returns a vector of {:id :created :raw} (:name also present for :anthropic).
List available models for a provider (:openai or :anthropic).
Returns a vector of {:id :created :raw} (:name also present for :anthropic).(query provider text & {:keys [model system max-tokens tools]})Convenience: single-turn user query, returns text content string. provider can be :openai or :anthropic. Throws if the provider returns no content (e.g. a refusal or content filter).
Convenience: single-turn user query, returns text content string. provider can be :openai or :anthropic. Throws if the provider returns no content (e.g. a refusal or content filter).
(query-json provider text & {:as opts})Run a query and attempt to parse the response as JSON. Returns [parsed-json remaining-text] or nil.
Run a query and attempt to parse the response as JSON. Returns [parsed-json remaining-text] or nil.
(query-structured provider
text
schema-name
json-schema
&
{:keys [model system max-tokens]})Run a query with a JSON schema and return the parsed, coerced result. For OpenAI, uses native structured output (response_format). For Anthropic, instructs via system prompt and parses JSON from response.
Run a query with a JSON schema and return the parsed, coerced result. For OpenAI, uses native structured output (response_format). For Anthropic, instructs via system prompt and parses JSON from response.
(run-agent req & {:keys [max-iterations on-tool-call] :or {max-iterations 10}})Run a provider call with tools, automatically executing tool calls in a loop until the model reaches a :stop reason.
req should include :provider :messages :tools (and optionally :system :model :max-tokens). max-iterations defaults to 10 to prevent infinite loops.
Returns the final normalized response.
Run a provider call with tools, automatically executing tool calls in a loop until the model reaches a :stop reason. req should include :provider :messages :tools (and optionally :system :model :max-tokens). max-iterations defaults to 10 to prevent infinite loops. Returns the final normalized response.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |