Liking cljdoc? Tell your friends :D

llm.sdk.transport

Transport protocol definition. A transport owns the translation between canonical SDK shapes and provider-native wire formats.

Transport protocol definition. A transport owns the translation between
canonical SDK shapes and provider-native wire formats.
raw docstring

bytes->base64clj

(bytes->base64 bs)
source

content->stringclj

(content->string content)

Extract text string from message content (string or vector of parts).

Extract text string from message content (string or vector of parts).
sourceraw docstring

developer-role-swapclj

(developer-role-swap messages model)

Swap system → developer for models that require it.

Swap system → developer for models that require it.
sourceraw docstring

extract-text-from-partsclj

(extract-text-from-parts content)

Extract text string from parts.

Extract text string from parts.
sourceraw docstring

extract-tool-calls-from-partsclj

(extract-tool-calls-from-parts content)

Extract tool-call parts from message content.

Extract tool-call parts from message content.
sourceraw docstring

extract-tool-resultclj

(extract-tool-result provider-id message)

Return one canonical tool result from a :tool message.

String and text-part content use message-level identifiers. A typed ToolResultPart supplies its own id, name, content, and error status. Mixed or conflicting representations are rejected rather than silently dropping tool output or routing it to the wrong call.

Return one canonical tool result from a :tool message.

String and text-part content use message-level identifiers. A typed
ToolResultPart supplies its own id, name, content, and error status.
Mixed or conflicting representations are rejected rather than silently
dropping tool output or routing it to the wrong call.
sourceraw docstring

file-binary-dataclj

(file-binary-data part)

Return base64 encoded file bytes from :file/data or :file/bytes. :file/data is assumed to already be base64 encoded.

Return base64 encoded file bytes from :file/data or :file/bytes.
:file/data is assumed to already be base64 encoded.
sourceraw docstring

file-data-for-input-fileclj

(file-data-for-input-file part)

Return base64 content for providers whose file input field expects encoded file data. Text content is UTF-8 encoded.

Return base64 content for providers whose file input field expects
encoded file data. Text content is UTF-8 encoded.
sourceraw docstring

file-data-uri-for-input-fileclj

(file-data-uri-for-input-file part)

Return a data URI for OpenAI file_data fields. OpenAI Responses and Chat Completions reject raw base64 here; they expect data:<mime>;base64,<payload>.

Return a data URI for OpenAI file_data fields.
OpenAI Responses and Chat Completions reject raw base64 here; they expect
data:<mime>;base64,<payload>.
sourceraw docstring

file-extensionclj

(file-extension part)
source

file-mime-typeclj

(file-mime-type part)
source

file-nameclj

(file-name part)
source

file-text-contentclj

(file-text-content part)
source

image-url-or-data-uri!clj

(image-url-or-data-uri! provider-id part)

Return an image URL, converting raw base64 :image/data to a data URI. Data URIs already supplied in either canonical field are preserved.

Return an image URL, converting raw base64 :image/data to a data URI.
Data URIs already supplied in either canonical field are preserved.
sourceraw docstring

map-finish-reasonclj

(map-finish-reason raw mapping)

Map provider finish reason strings to canonical keywords.

Map provider finish reason strings to canonical keywords.
sourceraw docstring

merge-extra-bodyclj

(merge-extra-body provider-id canonical extra-body)
(merge-extra-body provider-id canonical extra-body reserved-fields)

Merge provider extra_body fields into a canonical wire body.

String key spellings are normalized to keywords. Any extra field that collides with a canonical body field or an explicitly reserved field is rejected rather than silently discarded.

Merge provider extra_body fields into a canonical wire body.

String key spellings are normalized to keywords. Any extra field that
collides with a canonical body field or an explicitly reserved field is
rejected rather than silently discarded.
sourceraw docstring

missing-file-source!clj

(missing-file-source! provider-id part)
source

parts->text-partsclj

(parts->text-parts content)

Convert a string or seq of parts into a vector of text parts.

Convert a string or seq of parts into a vector of text parts.
sourceraw docstring

reject-error-tool-result!clj

(reject-error-tool-result! provider-id tool-result)

Reject an error result when a provider wire format has no error-status field.

Reject an error result when a provider wire format has no error-status field.
sourceraw docstring

sanitize-messagesclj

(sanitize-messages messages)

Strip internal fields from messages before sending to strict providers. Removes codex_reasoning_items, codex_message_items, tool_name, call_id, response_item_id from tool_calls.

Strip internal fields from messages before sending to strict providers.
Removes codex_reasoning_items, codex_message_items, tool_name, call_id,
response_item_id from tool_calls.
sourceraw docstring

stop-sequencesclj

(stop-sequences stop)

Normalize canonical :request/stop into providers' stop-sequence arrays. A single string is one sequence, not a seq of characters.

Normalize canonical :request/stop into providers' stop-sequence arrays.
A single string is one sequence, not a seq of characters.
sourceraw docstring

text->base64clj

(text->base64 s)
source

Transportcljprotocol

Provider-specific format conversion and normalization.

Provider-specific format conversion and normalization.

build-requestclj

(build-request this profile request)

Given a provider profile and canonical request, return the native request map (body + url + method + headers) ready for HTTP execution.

Given a provider profile and canonical request, return the native
request map (body + url + method + headers) ready for HTTP execution.

normalize-usageclj

(normalize-usage this profile raw-usage)

Given raw provider usage data, return canonical Usage map.

Given raw provider usage data, return canonical Usage map.

parse-errorclj

(parse-error this profile status body)

Given HTTP status and body, return a classified error map.

Given HTTP status and body, return a classified error map.

parse-responseclj

(parse-response this profile raw-response)

Given a provider profile and raw HTTP response body, return a canonical Response map.

Given a provider profile and raw HTTP response body, return a
canonical Response map.

parse-stream-eventclj

(parse-stream-event this profile line)

Given an SSE line string, return a StreamEvent map, a vector of StreamEvent maps (when one SSE line carries multiple semantic events, e.g. Perplexity's final chunk with citations + usage + finish_reason), or nil if the line should be ignored.

Given an SSE line string, return a StreamEvent map, a vector of
StreamEvent maps (when one SSE line carries multiple semantic
events, e.g. Perplexity's final chunk with citations + usage +
finish_reason), or nil if the line should be ignored.

request-capabilitiesclj

(request-capabilities this)

Return set of capabilities supported by this transport.

Return set of capabilities supported by this transport.
sourceraw docstring

unsupported-file-part!clj

(unsupported-file-part! provider-id part)
source

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