> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zeroruntime.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Openai

> JavaScript API reference for the openai llm plugin.

## OpenAILLM

OpenAI large language model (LLM).

### Constructor

```typescript theme={null}
new OpenAILLM(opts: OpenAILLMOptions)
```

<ParamField path="apiKey" type="string">
  OpenAI API key. Defaults to the `OPENAI_API_KEY` environment variable.
</ParamField>

<ParamField path="model" type="OpenAILLMModel | string">
  Model id. Default `'gpt-5.4-nano'`.
</ParamField>

<ParamField path="temperature" type="number">
  Sampling temperature; higher is more random. Default `0.7`.
</ParamField>

<ParamField path="maxOutputTokens" type="number">
  Maximum number of tokens to generate. Default `1024`.
</ParamField>

<ParamField path="topP" type="number | null">
  Nucleus sampling probability mass (0-1). Default `null`.
</ParamField>

<ParamField path="frequencyPenalty" type="number | null">
  Penalizes new tokens by their frequency so far (-2.0 to 2.0). Default `null`.
</ParamField>

<ParamField path="presencePenalty" type="number | null">
  Penalizes new tokens by whether they appear so far (-2.0 to 2.0). Default `null`.
</ParamField>

<ParamField path="seed" type="number | null">
  Seed for deterministic sampling. Default `null`.
</ParamField>

<ParamField path="responseFormat" type="Record<string, any> | null">
  Output format specification, e.g. `{ type: 'json_object' }`. Default `null`.
</ParamField>

<ParamField path="toolChoice" type="string | null">
  Controls tool selection, e.g. `'none'`, `'auto'`, `'required'`, or a tool name. Default `null`.
</ParamField>

<ParamField path="parallelToolCalls" type="boolean | null">
  Whether to allow multiple tool calls to run in parallel. Default `null`.
</ParamField>

<ParamField path="stop" type="string | null">
  Stop sequence(s) at which generation halts. Default `null`.
</ParamField>

<ParamField path="user" type="string | null">
  Stable identifier for the end user, used for abuse monitoring. Default `null`.
</ParamField>

<ParamField path="reasoningEffort" type="string | null">
  Reasoning effort for reasoning-capable models, e.g. `'none'`, `'low'`, `'medium'`, `'high'`. Default `null`.
</ParamField>

<ParamField path="verbosity" type="string | null">
  Response verbosity for capable models, e.g. `'low'`, `'medium'`, `'high'`. Default `null`.
</ParamField>

<ParamField path="streaming" type="boolean">
  Stream tokens from the model. Default `false`.
</ParamField>

<ParamField path="wssUrl" type="string | null">
  Override the realtime websocket URL. Default `null`.
</ParamField>

<ParamField path="store" type="boolean">
  Whether OpenAI may store the request/response for later retrieval. Default `true`.
</ParamField>

### cancelCurrentGeneration

```typescript theme={null}
cancelCurrentGeneration(): Promise<void>
```

Cancel the in-flight generation for the current session, if any.

### chat

```typescript theme={null}
chat(_messages: any, _opts?: LLMChatOptions): AsyncIterator<LLMResponse>
```

Stream a completion for the given messages, yielding LLMResponse chunks.

<ResponseField name="returns" type="AsyncIterator<LLMResponse>" />

### close

```typescript theme={null}
close(): Promise<void>
```

Release any resources held by the provider.

### closeEmitter

```typescript theme={null}
closeEmitter(): Promise<void>
```

Close the emitter: drop all handlers and stop emitting. Waits up to 2 seconds
for in-flight async handlers to settle before returning.

### emit

```typescript theme={null}
emit(event: string, ...args: any[]): void
```

<ParamField path="event" type="string" required />

### getRuntimeConfig

```typescript theme={null}
getRuntimeConfig(): Record<string, any>
```

<ResponseField name="returns" type="Record<string, any>" />

### listenerCount

```typescript theme={null}
listenerCount(event: string): number
```

<ParamField path="event" type="string" required />

<ResponseField name="returns" type="number" />

### off

```typescript theme={null}
off(event: string, handler: EventHandler): void
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

### on

```typescript theme={null}
on(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### once

```typescript theme={null}
once(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### removeAllListeners

```typescript theme={null}
removeAllListeners(event?: string): void
```

<ParamField path="event" type="string" />

***

## OpenAILLMModel

Supported OpenAI LLM model ids.

```typescript theme={null}
type OpenAILLMModel = | 'gpt-5.5' | 'gpt-5.4' | 'gpt-5.4-mini' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5' | 'gpt-5-mini' | 'gpt-5-nano' | 'gpt-5-pro' | 'gpt-5-chat-latest' | 'gpt-4.1' | 'gpt-4.1-mini' | 'gpt-4. …
```
