Ollama · Generate
Generates a completion for a single prompt using the Ollama generate API shape.#
/api/generateOllama-compatible generate endpoint: one prompt in, one completion out, with optional system message, base64 images, structured output via the format field, and streaming (newline-delimited JSON) or non-streaming responses. Streaming is the default, matching Ollama.
An empty prompt preloads the model without generating; combined with keep_alive: 0 it unloads the model. The raw, suffix, template and context fields are not supported and are rejected with a clear error; use /api/chat for multi-turn conversations.
Reference: https://docs.ollama.com/api#generate-a-completion
Request body
application/json ·
| Property | Type | Description |
|---|---|---|
model | string | The model identifier (e.g. "gemma3:4b"). If not specified, the server's default chat model is used. |
prompt | string | The prompt to complete. An empty prompt preloads the model (or unloads it when keep_alive is 0) without generating. |
suffix | string | Text after the insertion point (fill-in-the-middle). Not supported by this server. |
system | string | System message applied to the request. |
template | string | Custom prompt template override. Not supported by this server. |
context | object (int64)[] | Deprecated per-conversation state from a previous generate response. Not supported by this server; use /api/chat for multi-turn conversations. |
images | string[] | Base64-encoded images attached to the prompt (multimodal models). |
format | one of object · | |
options | Runtime options (temperature, num_ctx, stop, ...). | |
stream | boolean | Whether to stream the response as newline-delimited JSON. Defaults to true. |
raw | boolean | Bypass prompt templating. Not supported by this server. |
keep_alive | one of object · | |
think | one of object · |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | OK | |
| 400 | Bad Request | |
| 404 | Not Found | |
| 500 | application/json | Internal Server Error |
curl -X POST "$LMKIT_ONE_URL/api/generate" \
-H "Authorization: Bearer $LMKIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "string",
"prompt": "string",
"suffix": "string",
"system": "string"
}'