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]})

An OpenAI client. With no args, resolves credentials from the environment (OPENAI_API_KEY). Pass explicit config keys to set client options.

An OpenAI client. With no args, resolves credentials from the environment
(`OPENAI_API_KEY`). Pass explicit config keys to set client options.
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, and :parallel-tool-calls.

Message-vector input items accept {:role :system|:developer|:user|:assistant :content "..."} and {:type :function-call-output :call-id "..." :output "..."}. Map outputs are JSON-encoded.

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`, and `:parallel-tool-calls`.

Message-vector input items accept `{:role :system|:developer|:user|:assistant
:content "..."}` and `{:type :function-call-output :call-id "..."
:output "..."}`. Map outputs are JSON-encoded.

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-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

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