Liking cljdoc? Tell your friends :D

anthropic.beta.messages

Clojure wrapper for the beta Messages API.

Clojure wrapper for the beta Messages API.
raw docstring

await-streamclj

source

beta-batch-resultsclj

(beta-batch-results client id)
source

beta-tool-runner-handleclj

(beta-tool-runner-handle runner)
(beta-tool-runner-handle client params)
(beta-tool-runner-handle client params opts)

Create a Clojure handle around the SDK's blocking BetaToolRunner.

The handle's :messages and :streaming operations return lazy sequences; :set-next-params! accepts a normal request map, and :last-tool-response returns a translated message-param map or nil. The one-argument form wraps an existing SDK runner; the other forms create one through the beta Messages service.

Create a Clojure handle around the SDK's blocking `BetaToolRunner`.

The handle's `:messages` and `:streaming` operations return lazy sequences;
`:set-next-params!` accepts a normal request map, and `:last-tool-response`
returns a translated message-param map or nil. The one-argument form wraps
an existing SDK runner; the other forms create one through the beta
Messages service.
sourceraw docstring

cancel-beta-batchclj

(cancel-beta-batch client id)
source

cancel-stream!clj

source

close-stream!clj

source

count-beta-tokensclj

(count-beta-tokens client req)
(count-beta-tokens client req opts)

Count beta Messages input tokens without creating a message. Request maps support cache-control, compaction, context-management, mcp-servers, response-format, output-type, effort, task-budget, output-format, speed, user-profile-id, extra-headers, extra-query, and extra-body. Returns :input-tokens and, when present, nested :context-management data.

Count beta Messages input tokens without creating a message. Request maps
support cache-control, compaction, context-management, mcp-servers, response-format,
output-type, effort, task-budget, output-format, speed, user-profile-id, extra-headers,
extra-query, and extra-body. Returns :input-tokens and, when present, nested
:context-management data.
sourceraw docstring

create-beta-batchclj

(create-beta-batch client req)
source

create-beta-messageclj

(create-beta-message client req)
(create-beta-message client req opts)

Send a beta Messages request and return a generic Clojure map response.

Request maps support compaction, context-management, diagnostics, speed, and tool-choice disable-parallel-tool-use options. Tool specs support response-inclusion, input-examples, eager-input-streaming, caching, and dated :version options. System text and text content blocks accept citation-list :citations; document content blocks accept boolean or {:enabled ...} citation configuration. Custom tools accept optional :description and :input-schema; an omitted schema defaults to the SDK's object schema.

Send a beta Messages request and return a generic Clojure map response.

Request maps support compaction, context-management, diagnostics, speed, and
tool-choice disable-parallel-tool-use options. Tool specs support response-inclusion,
input-examples, eager-input-streaming, caching, and dated :version options.
System text and text content blocks accept citation-list `:citations`; document
content blocks accept boolean or `{:enabled ...}` citation configuration.
Custom tools accept optional :description and :input-schema; an omitted schema
defaults to the SDK's object schema.
sourceraw docstring

create-beta-threadclj

(create-beta-thread client req)

Start a beta message thread from a create-beta-message request map and return an opaque thread handle for the thread-* fns. Nothing is sent until thread-send. :unsupported-request-behavior (:error by default, or :continue-unthreaded) decides what happens when a request cannot be threaded.

Start a beta message thread from a `create-beta-message` request map and
return an opaque thread handle for the `thread-*` fns. Nothing is sent until
`thread-send`. `:unsupported-request-behavior` (`:error` by default, or
`:continue-unthreaded`) decides what happens when a request cannot be
threaded.
sourceraw docstring

delete-beta-batchclj

(delete-beta-batch client id)
source

get-beta-batchclj

(get-beta-batch client id)
source

list-beta-batchesclj

(list-beta-batches client)
(list-beta-batches client opts)
source

list-beta-batches-lazyclj

(list-beta-batches-lazy client)
(list-beta-batches-lazy client opts)

Lazily list beta message batches; accepts the same options as list-beta-batches.

Lazily list beta message batches; accepts the same options as `list-beta-batches`.
sourceraw docstring

reduce-beta-batch-resultsclj

(reduce-beta-batch-results client id f init)
source

run-beta-toolsclj

(run-beta-tools client params)
(run-beta-tools client params opts)

Run beta Messages with local tool functions until no tool is requested.

Options include :max-iterations, :on-message, and :on-turn. :on-turn receives each assistant response and the current params, and returns params for the next iteration, allowing tools and request settings to change. Tool functions may return {:tool-result value :compact-before-next-turn true} to request a {:type :summarize} compaction turn after their result; this drops :context-management from that request. Tool specs support response-inclusion, input-examples, eager-input-streaming, caching, and dated :version options.

Run beta Messages with local tool functions until no tool is requested.

Options include `:max-iterations`, `:on-message`, and `:on-turn`. `:on-turn`
receives each assistant response and the current params, and returns params
for the next iteration, allowing tools and request settings to change. Tool
functions may return `{:tool-result value :compact-before-next-turn true}` to
request a `{:type :summarize}` compaction turn after their result; this drops
`:context-management` from that request. Tool
specs support response-inclusion, input-examples, eager-input-streaming,
caching, and dated :version options.
sourceraw docstring

stream-beta-messageclj

(stream-beta-message client req on-event)
source

stream-beta-message-handleclj

(stream-beta-message-handle client req on-event)
(stream-beta-message-handle client req on-event opts)

Start a beta Messages SSE stream on a worker thread and return a cancellable handle. on-event receives normalized event maps.

Start a beta Messages SSE stream on a worker thread and return a
cancellable handle. `on-event` receives normalized event maps.
sourceraw docstring

stream-beta-message-queueclj

(stream-beta-message-queue client req)
(stream-beta-message-queue client req opts)

Start a bounded pull stream of normalized beta Messages events.

Start a bounded pull stream of normalized beta Messages events.
sourceraw docstring

stream-beta-textclj

(stream-beta-text client req on-text)
source

take-stream-eventclj

source

thread-appendclj

(thread-append thread message)

Add a message map, or a seq of them, to the thread without sending.

Add a message map, or a seq of them, to the thread without sending.
sourceraw docstring

thread-forkclj

(thread-fork thread)

Copy the thread's local history into a new, independent thread handle. Its next send opens a new server-side thread.

Copy the thread's local history into a new, independent thread handle. Its
next send opens a new server-side thread.
sourceraw docstring

thread-last-messageclj

(thread-last-message thread)

The most recent reply as a message map, or nil before the first send.

The most recent reply as a message map, or nil before the first send.
sourceraw docstring

thread-messagesclj

(thread-messages thread)

The thread's local message history as message maps.

The thread's local message history as message maps.
sourceraw docstring

thread-previous-message-idclj

(thread-previous-message-id thread)

The id the next send continues from, or nil before the first send.

The id the next send continues from, or nil before the first send.
sourceraw docstring

thread-sendclj

(thread-send thread)
(thread-send thread message)

Send the thread's pending turns plus message (a user text string, a message map, or a seq of message maps) and return the reply as a map like create-beta-message's. With no message, sends what the thread holds.

Send the thread's pending turns plus `message` (a user text string, a
message map, or a seq of message maps) and return the reply as a map like
`create-beta-message`'s. With no message, sends what the thread holds.
sourceraw docstring

thread-send-streamingclj

(thread-send-streaming thread message on-event)

Streaming thread-send: on-event receives normalized event maps, and the concatenated text is returned, as with stream-beta-message. The thread records the reply once the stream completes.

Streaming `thread-send`: `on-event` receives normalized event maps, and the
concatenated text is returned, as with `stream-beta-message`. The thread
records the reply once the stream completes.
sourceraw docstring

thread-tool-runnerclj

(thread-tool-runner thread)

A beta-tool-runner-handle that runs tools within the thread.

A `beta-tool-runner-handle` that runs tools within the thread.
sourceraw docstring

thread-updateclj

(thread-update thread
               {:keys [model max-tokens system stop-sequences thinking
                       tool-choice tools metadata inference-geo user-profile-id
                       cache-control betas]})

Change request fields used by later sends: :model, :max-tokens, :system, :stop-sequences, :thinking, :tool-choice, :tools, :metadata, :inference-geo, :user-profile-id, :cache-control, and :betas.

Change request fields used by later sends: `:model`, `:max-tokens`,
`:system`, `:stop-sequences`, `:thinking`, `:tool-choice`, `:tools`,
`:metadata`, `:inference-geo`, `:user-profile-id`, `:cache-control`, and
`:betas`.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close