Skip to content

OpenAIRequest

Defined in: adapters/openai.ts:108

OpenAI Chat Completions API request structure.

Defines all parameters for making a chat completion request to OpenAI’s API. This matches the official OpenAI API specification and is compatible with OpenAI-compatible endpoints (Azure OpenAI, local models, etc.).

const request: OpenAIRequest = {
model: 'gpt-4',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'Hello!' }
],
temperature: 0.7,
max_tokens: 150
};

optional frequency_penalty: number

Defined in: adapters/openai.ts:125

Penalty for token frequency -2 to 2. Reduces repetition


optional max_tokens: number

Defined in: adapters/openai.ts:119

Maximum tokens to generate in the response


messages: OpenAIMessage[]

Defined in: adapters/openai.ts:113

Array of conversation messages


model: string

Defined in: adapters/openai.ts:110

Model ID (e.g., ‘gpt-4’, ‘gpt-3.5-turbo’)


optional presence_penalty: number

Defined in: adapters/openai.ts:128

Penalty for token presence -2 to 2. Encourages new topics


optional seed: number

Defined in: adapters/openai.ts:140

Deterministic sampling seed for reproducible outputs


optional stop: string | string[]

Defined in: adapters/openai.ts:131

Stop sequence(s) - generation stops when encountered


optional stream: boolean

Defined in: adapters/openai.ts:134

Enable streaming responses via Server-Sent Events


optional temperature: number

Defined in: adapters/openai.ts:116

Sampling temperature 0-2. Higher = more random. Default 1


optional top_p: number

Defined in: adapters/openai.ts:122

Nucleus sampling parameter 0-1. Alternative to temperature


optional user: string

Defined in: adapters/openai.ts:137

Unique user identifier for abuse monitoring