Liking cljdoc? Tell your friends :D

openai.core

Idiomatic Clojure wrapper over the official OpenAI Java SDK (com.openai/openai-java), focused on the Responses API.

Idiomatic Clojure wrapper over the official OpenAI Java SDK
(`com.openai/openai-java`), focused on the Responses API.
raw docstring

cancel-responseclj

(cancel-response client response-id)

Cancel an in-progress response by id and return the resulting response map.

Cancel an in-progress response by id and return the resulting response map.
sourceraw docstring

clientclj

(client)
(client {:keys [api-key organization project base-url timeout-ms max-retries]})

An OpenAI client. With no args, resolves credentials from the environment (OPENAI_API_KEY). Pass explicit config keys to set client options: :api-key, :organization, :project, :base-url, :timeout-ms, and :max-retries.

An OpenAI client. With no args, resolves credentials from the environment
(`OPENAI_API_KEY`). Pass explicit config keys to set client options:
`:api-key`, `:organization`, `:project`, `:base-url`, `:timeout-ms`, and
`:max-retries`.
sourceraw docstring

compactclj

(compact client response-id)

Compact a previous response by id and return the compacted response map.

Compact a previous response by id and return the compacted response map.
sourceraw docstring

count-input-tokensclj

(count-input-tokens client req)

Count input tokens for a Responses request shape. Accepts the same request map style as create-response; fields unsupported by the SDK's input token count endpoint are ignored. Returns {:input-tokens n}.

Count input tokens for a Responses request shape. Accepts the same request map
style as `create-response`; fields unsupported by the SDK's input token count
endpoint are ignored. Returns `{:input-tokens n}`.
sourceraw docstring

create-responseclj

(create-response client req)

Send a Responses API request and return a Clojure map.

Request keys: :model (required string), :input (required string or vector), :instructions, :max-output-tokens, :temperature, :top-p, :metadata, :previous-response-id, :store, :reasoning, :user, :tools, :tool-choice, :parallel-tool-calls, :background, :include, :truncation, :prompt-cache-key, :safety-identifier, :service-tier, :max-tool-calls, :top-logprobs, :json-schema, :verbosity, :conversation, :stream-options, and :moderation.

Message-vector input items accept {:role :system|:developer|:user|:assistant :content "..."}, multimodal content vectors containing text, image, or file part maps, and {:type :function-call-output :call-id "..." :output "..."}. Map outputs are JSON-encoded.

Structured outputs: :json-schema {:name "..." :schema {...} :strict true :description "..."}.

Tools: {:type :function :name "..." :description "..." :strict true :parameters {...}}, {:type :web-search}, {:type :file-search :vector-store-ids [...]}, or {:type :code-interpreter :container "..."}. Code interpreter defaults to an auto container when :container is omitted.

Tool choice: :auto, :required, :none, or {:type :function :name "..."}.

Returns {:id :model :status :output :text :usage :created-at} plus :error, :incomplete-details, or :previous-response-id when present. Output items are normalized to :message, :function-call, :reasoning, :web-search-call, :file-search-call, :code-interpreter-call, or :unknown.

Send a Responses API request and return a Clojure map.

Request keys: `:model` (required string), `:input` (required string or vector),
`:instructions`, `:max-output-tokens`, `:temperature`, `:top-p`, `:metadata`,
`:previous-response-id`, `:store`, `:reasoning`, `:user`, `:tools`,
`:tool-choice`, `:parallel-tool-calls`, `:background`, `:include`,
`:truncation`, `:prompt-cache-key`, `:safety-identifier`, `:service-tier`,
`:max-tool-calls`, `:top-logprobs`, `:json-schema`, `:verbosity`,
`:conversation`, `:stream-options`, and `:moderation`.

Message-vector input items accept `{:role :system|:developer|:user|:assistant
:content "..."}`, multimodal content vectors containing text, image, or file
part maps, and `{:type :function-call-output :call-id "..." :output "..."}`.
Map outputs are JSON-encoded.

Structured outputs: `:json-schema {:name "..." :schema {...} :strict true
:description "..."}`.

Tools: `{:type :function :name "..." :description "..." :strict true
:parameters {...}}`, `{:type :web-search}`, `{:type :file-search
:vector-store-ids [...]}`, or `{:type :code-interpreter :container "..."}`.
Code interpreter defaults to an auto container when `:container` is omitted.

Tool choice: `:auto`, `:required`, `:none`, or `{:type :function :name "..."}`.

Returns `{:id :model :status :output :text :usage :created-at}` plus
`:error`, `:incomplete-details`, or `:previous-response-id` when present.
Output items are normalized to `:message`, `:function-call`, `:reasoning`,
`:web-search-call`, `:file-search-call`, `:code-interpreter-call`, or
`:unknown`.
sourceraw docstring

delete-responseclj

(delete-response client response-id)

Delete one stored response by id. The OpenAI Java SDK returns void.

Delete one stored response by id. The OpenAI Java SDK returns void.
sourceraw docstring

get-modelclj

(get-model client model-id)

Retrieve one model by id as a {:id :created :owned-by} map.

Retrieve one model by id as a `{:id :created :owned-by}` map.
sourceraw docstring

get-responseclj

(get-response client response-id)

Retrieve one stored response by id as a response map.

Retrieve one stored response by id as a response map.
sourceraw docstring

list-input-itemsclj

(list-input-items client response-id)

List input items for a stored response id as normalized maps. Pages are followed automatically.

List input items for a stored response id as normalized maps. Pages are
followed automatically.
sourceraw docstring

list-modelsclj

(list-models client)

List available models as a vector of {:id :created :owned-by} maps. Pages are followed automatically.

List available models as a vector of `{:id :created :owned-by}` maps. Pages
are followed automatically.
sourceraw docstring

retrieve-streamingclj

(retrieve-streaming client response-id on-event)

Resume streaming an existing background response id. Invokes on-event with normalized event maps and returns concatenated output text, matching stream.

Resume streaming an existing background response id. Invokes `on-event` with
normalized event maps and returns concatenated output text, matching `stream`.
sourceraw docstring

streamclj

(stream client req on-event)

Stream a Responses API request, invoking on-event with a normalized event map for every server-sent event as it arrives, and returning the concatenated output text. Takes the same req map as create-response. The underlying HTTP stream is closed automatically.

Stream a Responses API request, invoking `on-event` with a normalized event
map for every server-sent event as it arrives, and returning the concatenated
output text. Takes the same `req` map as `create-response`. The underlying
HTTP stream is closed automatically.
sourceraw docstring

stream-textclj

(stream-text client req on-text)

Stream a Responses API request, calling on-text with each output text delta string as it arrives, and returning the full concatenated text.

Stream a Responses API request, calling `on-text` with each output text delta
string as it arrives, and returning the full concatenated text.
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