Skip to content

@chinmaymk/aikit v0.0.40


@chinmaymk/aikit / OpenAIOptions

Interface: OpenAIOptions

Defined in: types.ts:451

OpenAI Chat Completions API configuration and generation options (default OpenAI implementation). These can be provided at construction time or generation time. Generation time options will override construction time options.

Extends

Properties

model?

optional model: string

Defined in: types.ts:305

The specific model you want to use. e.g., 'gpt-4o' or 'claude-3-5-sonnet-20240620'.

Inherited from

ProviderOptions.model


maxOutputTokens?

optional maxOutputTokens: number

Defined in: types.ts:307

The maximum number of output tokens to generate. Don't want it to ramble on forever, do you?

Inherited from

ProviderOptions.maxOutputTokens


temperature?

optional temperature: number

Defined in: types.ts:313

The sampling temperature. Higher values (e.g., 0.8) make the output more random, while lower values (e.g., 0.2) make it more focused and deterministic. A bit like adjusting the chaos knob.

Inherited from

ProviderOptions.temperature


topP?

optional topP: number

Defined in: types.ts:318

Top-p sampling. It's a way to control the randomness of the output by only considering the most likely tokens. It's like telling the AI to only pick from the top of the deck.

Inherited from

ProviderOptions.topP


topK?

optional topK: number

Defined in: types.ts:323

Top-k sampling. Similar to top-p, but it considers a fixed number of top tokens. Not all providers support this, because life isn't fair.

Inherited from

ProviderOptions.topK


stopSequences?

optional stopSequences: string[]

Defined in: types.ts:325

A list of sequences that will stop the generation. A safe word, if you will.

Inherited from

ProviderOptions.stopSequences


tools?

optional tools: Tool[]

Defined in: types.ts:327

The list of tools you're making available to the model.

Inherited from

ProviderOptions.tools


toolChoice?

optional toolChoice: { name: string; } | "auto" | "required" | "none"

Defined in: types.ts:335

How the model should choose which tool to use. 'auto': The model decides. 'required': The model must use a tool. 'none': The model can't use any tools. { name: 'my_tool' }: Force the model to use a specific tool.

Inherited from

ProviderOptions.toolChoice


apiKey?

optional apiKey: string

Defined in: types.ts:344

API key for authentication with the provider.

Inherited from

ProviderOptions.apiKey


baseURL?

optional baseURL: string

Defined in: types.ts:346

Custom base URL for the API endpoint.

Inherited from

ProviderOptions.baseURL


timeout?

optional timeout: number

Defined in: types.ts:348

Request timeout in milliseconds.

Inherited from

ProviderOptions.timeout


maxRetries?

optional maxRetries: number

Defined in: types.ts:350

Maximum number of retry attempts for failed requests.

Inherited from

ProviderOptions.maxRetries


mutateHeaders()?

optional mutateHeaders: (headers) => void

Defined in: types.ts:356

A function that allows you to modify the headers before a request is sent. This is useful for adding custom headers or modifying existing ones.

Parameters

headers

Record<string, string>

The original headers object to mutate directly.

Returns

void

Inherited from

ProviderOptions.mutateHeaders


organization?

optional organization: string

Defined in: types.ts:453

Your OpenAI organization ID. For when you're part of a fancy club.


project?

optional project: string

Defined in: types.ts:455

Your OpenAI project ID. For even fancier clubs.


presencePenalty?

optional presencePenalty: number

Defined in: types.ts:461

Presence penalty. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. Basically, it discourages repetition.


frequencyPenalty?

optional frequencyPenalty: number

Defined in: types.ts:467

Frequency penalty. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. Stop me if you've heard this one before.


user?

optional user: string

Defined in: types.ts:471

A stable identifier for your end-users.


logprobs?

optional logprobs: boolean

Defined in: types.ts:477

Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the content of message. This feature is available on gpt-4.1, gpt-4o, gpt-4o-mini, gpt-3.5-turbo, and other supported models.


topLogprobs?

optional topLogprobs: number

Defined in: types.ts:482

An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true if this parameter is used.


seed?

optional seed: number

Defined in: types.ts:489

This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed, and you should refer to the system_fingerprint response parameter to monitor changes in the backend.


responseFormat?

optional responseFormat: object

Defined in: types.ts:499

An object specifying the format that the model must output. Compatible with GPT-4.1, GPT-4o, GPT-4o-mini, GPT-3.5 Turbo, and all GPT-4 Turbo models newer than gpt-4-turbo-2024-04-09. Setting to { "type": "json_object" } enables JSON mode, which guarantees the message the model generates is valid JSON. Important: when using JSON mode, you must also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if finish_reason="length", which indicates the generation exceeded max_tokens or the conversation exceeded the max context length.

type

type: "text" | "json_object" | "json_schema"

json_schema?

optional json_schema: object

json_schema.name

name: string

json_schema.description?

optional description: string

json_schema.schema?

optional schema: Record<string, unknown>

json_schema.strict?

optional strict: boolean


logitBias?

optional logitBias: Record<string, number>

Defined in: types.ts:515

Modify the likelihood of specified tokens appearing in the completion. Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.


n?

optional n: number

Defined in: types.ts:521

How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep n as 1 to minimize costs.


includeUsage?

optional includeUsage: boolean

Defined in: types.ts:526

Whether to include usage information (token counts and timing) in the response. When true, usage data will be included in the final stream chunk.


parallelToolCalls?

optional parallelToolCalls: boolean

Defined in: types.ts:530

Whether to allow the model to run tool calls in parallel.


reasoning?

optional reasoning: object

Defined in: types.ts:536

Configuration options for reasoning models (o-series models only). Controls the reasoning effort level for enhanced problem-solving capabilities. When enabled, the reasoning process is included in the response.

effort?

optional effort: "low" | "medium" | "high"


modalities?

optional modalities: ("text" | "audio")[]

Defined in: types.ts:543

Output types that you would like the model to generate. Most models are capable of generating text, which is the default. The gpt-4o-audio-preview model can also be used to generate audio.


audio?

optional audio: object

Defined in: types.ts:547

Parameters for audio output. Required when audio output is requested with modalities: ["audio"].

format

format: "wav" | "mp3" | "flac" | "opus" | "pcm16"

Specifies the output audio format. Must be one of wav, mp3, flac, opus, or pcm16.

voice

voice: "alloy" | "ash" | "ballad" | "coral" | "echo" | "fable" | "nova" | "onyx" | "sage" | "shimmer"

The voice the model uses to respond.


maxCompletionTokens?

optional maxCompletionTokens: number

Defined in: types.ts:567

The maximum number of tokens that can be generated in the chat completion, including visible output tokens and reasoning tokens. This replaces the deprecated max_tokens parameter.


prediction?

optional prediction: object

Defined in: types.ts:571

Configuration for a Predicted Output, which can greatly improve response times when large parts of the model response are known ahead of time.

type

type: "content"

The type of predicted content. Currently only 'content' is supported.

content

content: string | object[]

The content that should be matched when generating a model response.


webSearchOptions?

optional webSearchOptions: object

Defined in: types.ts:580

Web search tool configuration for searching the web for relevant results to use in a response.

searchContextSize?

optional searchContextSize: "low" | "medium" | "high"

High level guidance for the amount of context window space to use for the search.

userLocation?

optional userLocation: object

Approximate location parameters for the search.

userLocation.type

type: "approximate"

The type of location approximation. Always 'approximate'.

userLocation.approximate

approximate: Record<string, unknown>

Approximate location parameters for the search.

Released under the MIT License.