Skip to content

LLMGenerationOptions

Defined in: core/options.ts:3

optional extra: Record<string, unknown>

Defined in: core/options.ts:12


optional maxTokens: number

Defined in: core/options.ts:6


messages: LLMMessage[]

Defined in: core/options.ts:5


optional metadata: Record<string, unknown>

Defined in: core/options.ts:11


model: string

Defined in: core/options.ts:4


optional responseFormat: "text"

Defined in: core/options.ts:10


optional signal: AbortSignal

Defined in: core/options.ts:47

Optional abort signal for cancelling the request mid-flight.

When the signal is aborted, the provider will attempt to cancel the underlying HTTP request and the stream will terminate with an abort error. Use isAbortError() from @/core/errors to detect cancellation in error handling.

const controller = new AbortController();
const stream = client.stream({
model: "claude-3-5-sonnet-20241022",
messages: [{ role: "user", content: "Tell me a long story" }],
signal: controller.signal,
});
// Cancel after 5 seconds
setTimeout(() => controller.abort(), 5000);
try {
for await (const chunk of stream) {
process.stdout.write(chunk.text);
}
} catch (error) {
if (isAbortError(error)) {
console.log("\nRequest was cancelled");
} else {
throw error;
}
}

optional stopSequences: string[]

Defined in: core/options.ts:9


optional temperature: number

Defined in: core/options.ts:7


optional topP: number

Defined in: core/options.ts:8