ol.llx.ai

platforms: clj, cljs

default-env

clj

platforms: clj

(default-env)

Returns the default environment for your platform.

cljs

platforms: cljs

(default-env)

Returns the default environment for your platform.


complete*

clj

platforms: clj

(complete* env model context opts)

Runs one non-streaming assistant turn using provider-style options.

Use complete* when you need provider-level control and adapter-specific options. This is the provider path.

opts is validated against :ol.llx/provider-request-options in src/ol/llx/ai/impl/schema/options.cljc.

Adapter build-request boundaries also validate adapter-specific schemas: :ol.llx/openai-completions-provider-options, :ol.llx/openai-responses-provider-options, :ol.llx/anthropic-provider-options, and :ol.llx/google-provider-options.

Common provider option keys:

key description

:max-output-tokens

Requested output token cap.

:temperature

Sampling temperature.

:top-p

Nucleus sampling probability.

:reasoning

Provider reasoning map (shape depends on adapter).

:session-id

Optional session identifier for provider-side caching/routing.

:api-key

Provider API key override for this call.

:headers

Additional provider request headers.

:signal

Abort/cancel signal forwarded to runtime/provider layer.

:max-retry-delay-ms

Optional cap for server-requested retry delays.

:metadata

Request metadata map forwarded to adapter payload builders.

:registry

Per-call adapter registry override.

:max-retries

Retry count for transient failures (default 2).

Returns a promise that resolves to one canonical assistant message map. Errors reject the promise with structured LLX exception data.

Use complete for the unified API.

cljs

platforms: cljs

(complete* env model context opts)

Runs one non-streaming assistant turn using provider-style options.

Use complete* when you need provider-level control and adapter-specific options. This is the provider path.

opts is validated against :ol.llx/provider-request-options in src/ol/llx/ai/impl/schema/options.cljc.

Adapter build-request boundaries also validate adapter-specific schemas: :ol.llx/openai-completions-provider-options, :ol.llx/openai-responses-provider-options, :ol.llx/anthropic-provider-options, and :ol.llx/google-provider-options.

Common provider option keys:

key description

:max-output-tokens

Requested output token cap.

:temperature

Sampling temperature.

:top-p

Nucleus sampling probability.

:reasoning

Provider reasoning map (shape depends on adapter).

:session-id

Optional session identifier for provider-side caching/routing.

:api-key

Provider API key override for this call.

:headers

Additional provider request headers.

:signal

Abort/cancel signal forwarded to runtime/provider layer.

:max-retry-delay-ms

Optional cap for server-requested retry delays.

:metadata

Request metadata map forwarded to adapter payload builders.

:registry

Per-call adapter registry override.

:max-retries

Retry count for transient failures (default 2).

Returns a promise that resolves to one canonical assistant message map. Errors reject the promise with structured LLX exception data.

Use complete for the unified API.


stream*

clj

platforms: clj

(stream* env model context opts)

Runs one streaming assistant turn using provider-style options.

Use stream* when you need provider-level control and adapter-specific options. This is the provider path.

opts is validated against :ol.llx/provider-request-options in src/ol/llx/ai/impl/schema/options.cljc, and adapter-specific schemas are enforced at each adapter build-request boundary.

Common provider option keys:

key description

:max-output-tokens

Requested output token cap.

:temperature

Sampling temperature.

:top-p

Nucleus sampling probability.

:reasoning

Provider reasoning map (shape depends on adapter).

:session-id

Optional session identifier for provider-side caching/routing.

:api-key

Provider API key override for this call.

:headers

Additional provider request headers.

:signal

Abort/cancel signal forwarded to runtime/provider layer.

:max-retry-delay-ms

Optional cap for server-requested retry delays.

:metadata

Request metadata map forwarded to adapter payload builders.

:registry

Per-call adapter registry override.

:max-retries

Retry count for transient failures (default 2).

Returns a Promesa CSP channel emitting canonical LLX event maps. Stream completion emits terminal :done or :error and closes the channel. Consumer cancellation is channel closure.

Use stream for the unified API.

cljs

platforms: cljs

(stream* env model context opts)

Runs one streaming assistant turn using provider-style options.

Use stream* when you need provider-level control and adapter-specific options. This is the provider path.

opts is validated against :ol.llx/provider-request-options in src/ol/llx/ai/impl/schema/options.cljc, and adapter-specific schemas are enforced at each adapter build-request boundary.

Common provider option keys:

key description

:max-output-tokens

Requested output token cap.

:temperature

Sampling temperature.

:top-p

Nucleus sampling probability.

:reasoning

Provider reasoning map (shape depends on adapter).

:session-id

Optional session identifier for provider-side caching/routing.

:api-key

Provider API key override for this call.

:headers

Additional provider request headers.

:signal

Abort/cancel signal forwarded to runtime/provider layer.

:max-retry-delay-ms

Optional cap for server-requested retry delays.

:metadata

Request metadata map forwarded to adapter payload builders.

:registry

Per-call adapter registry override.

:max-retries

Retry count for transient failures (default 2).

Returns a Promesa CSP channel emitting canonical LLX event maps. Stream completion emits terminal :done or :error and closes the channel. Consumer cancellation is channel closure.

Use stream for the unified API.


complete

clj

platforms: clj

(complete env model context unified-opts)

Runs one non-streaming assistant turn using the unified options API.

This is the unified path and is recommended for most callers. opts is validated against :ol.llx/unified-request-options in src/ol/llx/ai/impl/schema/options.cljc.

Unified options are normalized and forwarded to provider adapters. For example: - :max-tokens → provider :max-output-tokens - :reasoning / :reasoning-effort → provider reasoning shape

Unified option keys:

key description

:max-tokens

Requested output cap. Defaults to min(model.max-tokens, 32000).

:temperature

Sampling temperature.

:top-p

Nucleus sampling probability.

:reasoning

Reasoning level keyword (:minimal :low :medium :high :xhigh).

:reasoning-effort

Alias for :reasoning.

:session-id

Optional session identifier for provider-side caching/routing.

:thinking-budgets

Optional token budgets per reasoning level (provider-dependent).

:api-key

Provider API key override for this call.

:headers

Additional provider request headers.

:signal

Abort/cancel signal forwarded to runtime/provider layer.

:max-retry-delay-ms

Optional cap for server-requested retry delays.

:metadata

Request metadata map forwarded to adapter payload builders.

:registry

Per-call adapter registry override.

Returns a promise that resolves to one canonical assistant message map. Errors reject the promise with structured LLX exception data.

Use complete* if you need provider-specific options that are outside the unified schema.

cljs

platforms: cljs

(complete env model context unified-opts)

Runs one non-streaming assistant turn using the unified options API.

This is the unified path and is recommended for most callers. opts is validated against :ol.llx/unified-request-options in src/ol/llx/ai/impl/schema/options.cljc.

Unified options are normalized and forwarded to provider adapters. For example: - :max-tokens → provider :max-output-tokens - :reasoning / :reasoning-effort → provider reasoning shape

Unified option keys:

key description

:max-tokens

Requested output cap. Defaults to min(model.max-tokens, 32000).

:temperature

Sampling temperature.

:top-p

Nucleus sampling probability.

:reasoning

Reasoning level keyword (:minimal :low :medium :high :xhigh).

:reasoning-effort

Alias for :reasoning.

:session-id

Optional session identifier for provider-side caching/routing.

:thinking-budgets

Optional token budgets per reasoning level (provider-dependent).

:api-key

Provider API key override for this call.

:headers

Additional provider request headers.

:signal

Abort/cancel signal forwarded to runtime/provider layer.

:max-retry-delay-ms

Optional cap for server-requested retry delays.

:metadata

Request metadata map forwarded to adapter payload builders.

:registry

Per-call adapter registry override.

Returns a promise that resolves to one canonical assistant message map. Errors reject the promise with structured LLX exception data.

Use complete* if you need provider-specific options that are outside the unified schema.


stream

clj

platforms: clj

(stream env model context unified-opts)

Runs one streaming assistant turn using the unified options API.

This is the unified path and is recommended for most callers. opts is validated against :ol.llx/unified-request-options in src/ol/llx/ai/impl/schema/options.cljc.

Unified option keys:

key description

:max-tokens

Requested output cap. Defaults to min(model.max-tokens, 32000).

:temperature

Sampling temperature.

:top-p

Nucleus sampling probability.

:reasoning

Reasoning level keyword (:minimal :low :medium :high :xhigh).

:reasoning-effort

Alias for :reasoning.

:session-id

Optional session identifier for provider-side caching/routing.

:thinking-budgets

Optional token budgets per reasoning level (provider-dependent).

:api-key

Provider API key override for this call.

:headers

Additional provider request headers.

:signal

Abort/cancel signal forwarded to runtime/provider layer.

:max-retry-delay-ms

Optional cap for server-requested retry delays.

:metadata

Request metadata map forwarded to adapter payload builders.

:registry

Per-call adapter registry override.

Returns a Promesa CSP channel emitting canonical LLX event maps. Stream completion emits terminal :done or :error and closes the channel. Consumer cancellation is channel closure.

Use stream* for provider-specific option control.

cljs

platforms: cljs

(stream env model context unified-opts)

Runs one streaming assistant turn using the unified options API.

This is the unified path and is recommended for most callers. opts is validated against :ol.llx/unified-request-options in src/ol/llx/ai/impl/schema/options.cljc.

Unified option keys:

key description

:max-tokens

Requested output cap. Defaults to min(model.max-tokens, 32000).

:temperature

Sampling temperature.

:top-p

Nucleus sampling probability.

:reasoning

Reasoning level keyword (:minimal :low :medium :high :xhigh).

:reasoning-effort

Alias for :reasoning.

:session-id

Optional session identifier for provider-side caching/routing.

:thinking-budgets

Optional token budgets per reasoning level (provider-dependent).

:api-key

Provider API key override for this call.

:headers

Additional provider request headers.

:signal

Abort/cancel signal forwarded to runtime/provider layer.

:max-retry-delay-ms

Optional cap for server-requested retry delays.

:metadata

Request metadata map forwarded to adapter payload builders.

:registry

Per-call adapter registry override.

Returns a Promesa CSP channel emitting canonical LLX event maps. Stream completion emits terminal :done or :error and closes the channel. Consumer cancellation is channel closure.

Use stream* for provider-specific option control.


get-model

clj

platforms: clj

(get-model provider model-id)

Returns the model definition for provider and model-id, or nil when absent.

cljs

platforms: cljs

(get-model provider model-id)

Returns the model definition for provider and model-id, or nil when absent.


get-models

clj

platforms: clj

(get-models provider)

Returns all models for provider as a deterministic vector sorted by :id.

cljs

platforms: cljs

(get-models provider)

Returns all models for provider as a deterministic vector sorted by :id.


get-providers

clj

platforms: clj

(get-providers)

Returns supported providers as a deterministic sorted vector.

cljs

platforms: cljs

(get-providers)

Returns supported providers as a deterministic sorted vector.


calculate-cost

clj

platforms: clj

(calculate-cost model usage)

Calculates usage cost totals from model pricing and usage token counts.

cljs

platforms: cljs

(calculate-cost model usage)

Calculates usage cost totals from model pricing and usage token counts.


supports-xhigh?

clj

platforms: clj

(supports-xhigh? model)

Returns true when model supports :xhigh reasoning effort.

cljs

platforms: cljs

(supports-xhigh? model)

Returns true when model supports :xhigh reasoning effort.


models-equal?

clj

platforms: clj

(models-equal? a b)

Returns true when two model maps refer to the same :provider and :id.

cljs

platforms: cljs

(models-equal? a b)

Returns true when two model maps refer to the same :provider and :id.


validate-tool-call

clj

platforms: clj

(validate-tool-call tools tool-call)

Validates a tool-call entry against matching tool definitions in tools.

cljs

platforms: cljs

(validate-tool-call tools tool-call)

Validates a tool-call entry against matching tool definitions in tools.


context-overflow?

clj

platforms: clj

(context-overflow? assistant-message)
(context-overflow? assistant-message context-window)

Returns true when the input matches known context-window overflow patterns.

cljs

platforms: cljs

(context-overflow? assistant-message)
(context-overflow? assistant-message context-window)

Returns true when the input matches known context-window overflow patterns.


sanitize-surrogates

clj

platforms: clj

(sanitize-surrogates text)

Removes unpaired surrogate code units while preserving valid Unicode pairs.

cljs

platforms: cljs

(sanitize-surrogates text)

Removes unpaired surrogate code units while preserving valid Unicode pairs.


schema-regsitry

clj

platforms: clj

(schema-regsitry)

Returns the full LLX schema registry map.

cljs

platforms: cljs

(schema-regsitry)

Returns the full LLX schema registry map.