Skip to main content

AIChat

Defined in: js-api/src/ai.ts:73

A conversation with one engine. Implementations provide respond; stream and prompt add the shared grok.ai.on* turn events.

Constructors

Constructor

new AIChat(): AIChat

Returns

AIChat

Methods

close()

close(): void

Defined in: js-api/src/ai.ts:121

Releases the conversation; the default does nothing.

Returns

void


prompt()

prompt(prompt, options?): Promise<AIResult>

Defined in: js-api/src/ai.ts:112

Sends [prompt] and awaits the full result.

Parameters

ParameterType
promptstring
options?AIRunOptions

Returns

Promise<AIResult>


respond()

abstract protected respond(prompt, options?): AIStream

Defined in: js-api/src/ai.ts:75

Produces the reply to [prompt] as a stream of text chunks that ends with the AIResult.

Parameters

ParameterType
promptstring
options?AIRunOptions

Returns

AIStream


stream()

stream(prompt, options?): AIStream

Defined in: js-api/src/ai.ts:78

Sends [prompt]; yields text chunks and returns the final result. Emits the grok.ai.on* events.

Parameters

ParameterType
promptstring
options?AIRunOptions

Returns

AIStream