OllamaClient.generate

Generates text based on a prompt using the specified model.

class OllamaClient
@safe
JSONValue
generate
(
string model
,
string prompt
,
JSONValue options = JSONValue.init
,
bool stream = false
,
string system = null
,
string[] images = null
,
JSONValue format = JSONValue.init
,
string suffix = null
,
string keepAlive = null
,)

Parameters

model string

Model name (e.g. "llama3.1:8b").

prompt string

Input text.

options JSONValue

Raw JSONValue generation options (backward-compatible).

stream bool

Whether to stream the response (not fully supported).

system string

Optional system prompt.

images string[]

Optional base64-encoded images for multimodal input.

format JSONValue

Structured output: JSONValue("json") or a JSON Schema.

suffix string

Text appended after the generated response.

keepAlive string

How long to keep the model loaded (e.g. "5m", "0").

opts OllamaOptions

Typed OllamaOptions; takes precedence over options.

Return Value

Type: JSONValue

A JSONValue containing "response", "done", and metadata.

Meta