Provider request-transform helpers. Adapts messages and request options to a model's declared capabilities (filtering unsupported attachments, deriving temperature/reasoning variants, capping output tokens) before a request is sent.

Members

(static, constant) OUTPUT_TOKEN_MAX

Hard cap on output tokens (overridable via CLOSEDCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX).

(static, constant) ProviderTransform

Aggregated namespace of the provider-transform helpers.

Methods

(static) maxOutputTokens(model) → {number}

Compute the max output tokens for a request: the model's output limit clamped to OUTPUT_TOKEN_MAX (falling back to that cap when no limit is set).

Parameters:
NameTypeDescription
modelObject

The resolved model (its limit.output is consulted).

Returns:

The capped max output token count.

Type: 
number

(static) message(msgs, model, _options) → {Array}

Filter message file parts down to modalities the model can actually accept, dropping attachments whose MIME type maps to an unsupported (or unknown) modality.

Parameters:
NameTypeDescription
msgsArray

The chat messages.

modelObject

The resolved model (its capabilities.input is consulted).

_options*

Unused; reserved for future per-request options.

Returns:

The messages with unsupported file parts removed.

Type: 
Array

(static) options(input) → {Object}

Build the request options bag, spreading the caller's provider options and nesting them under the providerOptions namespace via providerOptions.

Parameters:
NameTypeDescription
inputObject

{model, providerOptions} — the model and any caller-supplied provider options.

Returns:

The combined options object.

Type: 
Object

(static) providerOptions(_model, options) → {Object}

Wrap provider options under the openaiCompatible namespace expected by the

Parameters:
NameTypeDescription
_modelObject

The resolved model (unused).

optionsObject

The provider options to namespace.

Returns:

{openaiCompatible: options}.

Type: 
Object

(static) schema(_model, schema) → {Object}

Transform an output JSON schema for a model (currently a pass-through).

Parameters:
NameTypeDescription
_modelObject

The resolved model (unused).

schemaObject

The schema to transform.

Returns:

The schema, unchanged.

Type: 
Object

(static) smallOptions(model) → {Object}

Build the default options for the small/auxiliary model (empty provider options).

Parameters:
NameTypeDescription
modelObject

The resolved model.

Returns:

The options object from options.

Type: 
Object

(static) temperature(model) → {number}

Resolve the temperature to send for a model: 0 when supported, undefined otherwise.

Parameters:
NameTypeDescription
modelObject

The resolved model (its capabilities.temperature is consulted).

Returns:

0 if temperature is supported; otherwise undefined.

Type: 
number

(static) topK(_model) → {*}

Resolve the top-k value to send for a model (currently always unset).

Parameters:
NameTypeDescription
_modelObject

The resolved model (unused).

Returns:

undefined.

Type: 
*

(static) topP(_model) → {*}

Resolve the top-p value to send for a model (currently always unset).

Parameters:
NameTypeDescription
_modelObject

The resolved model (unused).

Returns:

undefined.

Type: 
*

(static) variants(model) → {Object}

Build the set of reasoning-effort variants ("low"/"medium"/"high") for a model that supports reasoning; returns an empty object when reasoning is unsupported.

Parameters:
NameTypeDescription
modelObject

The resolved model (its capabilities.reasoning is consulted).

Returns:

A map of variant name to options, or {}.

Type: 
Object

(inner) mimeToModality(mime) → {string}

Map a MIME type to the modality category used by model capability checks.

Parameters:
NameTypeDescription
mimestring

The media type (e.g. "image/png", "application/pdf").

Returns:

"image" | "audio" | "video" | "pdf", or undefined if unrecognized.

Type: 
string