Generate API (Ollama Compatible)¶
Generate text for a single prompt with Amazon Bedrock models through the Ollama /api/generate interface. Served under /ollama by default; the examples below use $BASE, which includes that prefix.
At a glance¶
- Drop-in Ollama compatibility — Follows the Ollama
/api/generaterequest and response shape, including its newline-delimited JSON streaming transport, so an existing Ollama client works by changing the base URL. - Single-prompt simplicity — A minimal shape for clients that send one prompt at a time rather than a full conversation.
- Structured output —
formataccepts"json"or a full JSON Schema, and the answer is constrained to it. - Private AWS backend — Served entirely by Amazon Bedrock models in your own AWS account — no traffic to third-party endpoints.
- Image input beyond base64 —
imagesalso takes a URL, a data URI or ans3://URI on models that read images. - Differs from the Ollama API:
raw,suffix,templateandcontextare refused with400andcontextis never returned; models are never resident, sokeep_aliveholds nothing loaded — see Limits and behaviour to know.
Base URL and route prefix
By default, all Ollama-compatible routes are prefixed with /ollama. This means the Generate API is available at /ollama/api/generate instead of /api/generate. You can customize this prefix using the OLLAMA_ROUTES_PREFIX configuration variable documented in HTTP Server and MCP.
The curl examples on this page use a $BASE variable that must include this prefix — set it to your scheme and host followed by OLLAMA_ROUTES_PREFIX:
export BASE="https://your-host/ollama" # <scheme>://<host> + OLLAMA_ROUTES_PREFIX
curl -X POST "$BASE/api/generate" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "amazon.nova-micro-v1:0",
"prompt": "Why is the sky blue?",
"stream": false
}'
Endpoints¶
| Endpoint | Method | What It Does | Powered By | MCP Tool |
|---|---|---|---|---|
/api/generate | POST | Text generation for a single prompt, Ollama Generate API | Amazon Bedrock chat models | ollama_generate |
/api/generate is served in full; new integrations usually pick /api/chat, which carries message history, tool calls and multi-turn thinking.
Model Names¶
Send the model names GET /api/tags publishes — those are the canonical identifiers this server resolves directly. A trailing :latest is accepted and stripped as a fallback when the exact name is not found. Short aliases accepted on this server's other APIs also work here even though /api/tags does not list them. A name learned from ollama.com (for example llama3.2:3b) is not available through this server and answers 404. Every response echoes the model name exactly as the request spelled it, in model.
Find compatible models: Call /search_models with route=ollama_generate to discover model IDs that support this route, or call GET /api/tags for the Ollama-shaped listing.
Feature compatibility¶
| Feature | Status | Notes |
|---|---|---|
| Input | ||
prompt | Full support | |
system | Sent as the conversation's system instruction | |
images | Multimodal models only; base64, a URL, a data URI or an s3:// URI | |
format | "json" or a JSON Schema object; same behavior as /api/chat | |
options | temperature, top_p, top_k, seed, stop, num_predict (max output tokens), presence_penalty and frequency_penalty are forwarded; runner options (num_ctx, num_gpu, num_thread, num_batch, main_gpu, use_mmap, min_p, and any other unknown key) are accepted and ignored | |
stream | Newline-delimited JSON; defaults to true — see Streaming | |
think | Boolean, or low/medium/high/max; comes back in thinking | |
keep_alive | Ignored for residency — models are never resident — but still tells a request with no prompt apart as a load or an unload, below | |
raw, suffix, template, context | Rejected with 400 — see Fields Not Available | |
logprobs / top_logprobs | Rejected with 400 | |
| Output | ||
response | Full support | |
thinking | Follows CHAT_COMPLETIONS_REASONING_FIELD; omitted when the operator sets that to none | |
done_reason | stop or length on a generated answer; load or unload on a prompt-less request — see Loading and Unloading | |
context | Never returned — see Fields Not Available | |
| Usage tracking | ||
prompt_eval_count, eval_count | Real token counts | |
total_duration | Real wall-clock time | |
load_duration | Never reported — there is no model-loading phase to measure | |
prompt_eval_duration, eval_duration | Reported only when streaming, measured from the stream itself; omitted on a non-streaming response |
Legend:
- Supported — Fully compatible with the Ollama API
- Available on Select Models — Check your model's capabilities
- Partial — Supported with limitations
- Unsupported — Not available in this implementation
Streaming¶
By default (stream unset, or true), the response body is newline-delimited JSON (application/x-ndjson): one bare JSON object per line, with no data: prefix and no [DONE] sentinel. The stream is terminated by an object carrying "done": true and the response metrics. See Streaming on the Chat API for the transport details and how a mid-stream failure is reported.
curl -N -X POST "$BASE/api/generate" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "amazon.nova-micro-v1:0",
"prompt": "Write a haiku about the sea."
}'
{"model":"amazon.nova-micro-v1:0","created_at":"2026-08-27T12:00:00.000000+00:00","response":"Waves","done":false}
{"model":"amazon.nova-micro-v1:0","created_at":"2026-08-27T12:00:00.100000+00:00","response":" crash on silent shores","done":false}
{"model":"amazon.nova-micro-v1:0","created_at":"2026-08-27T12:00:00.200000+00:00","response":"","done":true,"done_reason":"stop","total_duration":812345678,"prompt_eval_count":9,"prompt_eval_duration":123456789,"eval_count":11,"eval_duration":688888889}
Fields Not Available¶
raw, suffix, template and context are each rejected with 400 when set. Every one of them needs the model's own prompt template or tokenizer to honor — the exact text the model was trained to expect around a prompt, or the token IDs of a prior turn — and neither is exposed here. The error names the offending field and points at /api/chat as the alternative. Because there is no token context to hand back, response.context is never returned by this endpoint.
Send prompt together with system for a system-prompted single turn, or use /api/chat for a multi-turn conversation.
Images¶
images accepts base64-encoded image data, as Ollama does. This server additionally accepts a URL, a data URI or an s3:// URI in the same field, on models that support image input.
Loading and Unloading¶
A request with no prompt is upstream's way of making a model resident — it is what ollama run <model> sends before it opens its REPL — and the same request with keep_alive set to 0 is what ollama stop <model> sends to evict it. A hosted model is always resident, so both are answered without invoking anything:
{
"model": "amazon.nova-micro-v1:0",
"created_at": "2026-01-01T00:00:00+00:00",
"response": "",
"done": true,
"done_reason": "load"
}
done_reason is unload when keep_alive is 0, load otherwise. The answer is a single JSON object whatever stream says, as upstream's is.
Limits and behaviour to know¶
raw,suffix,templateandcontextare rejected with400— see Fields Not Available.logprobsandtop_logprobsare rejected with400— log probabilities are not available.keep_alivedoes not keep anything loaded: models are never resident. It is read only to tell a prompt-less request'sdone_reasonapart,loadfromunload.- Runner options inside
options(num_ctx,num_gpu,num_thread,num_batch,main_gpu,use_mmap,min_p, and any other key a local runner would use) are accepted and ignored. load_durationis never reported: there is no model-loading phase to measure, and a number there would be invented.prompt_eval_durationandeval_durationare reported only when streaming. All duration and count fields are optional in the Ollama API, so a client computing tokens-per-second from a non-streamed response has no duration to divide by.- A model name learned from ollama.com —
llama3.2:3b, for one — names nothing this server serves and answers404; send a nameGET /api/tagspublishes.
Request headers¶
| Header | Purpose | Notes |
|---|---|---|
Authorization | Gateway API key | Bearer <key>, required like every other route |
A local Ollama server needs no key; this one does, on every route.
Try it¶
curl -X POST "$BASE/api/generate" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "amazon.nova-micro-v1:0",
"prompt": "Why is the sky blue?",
"stream": false
}'
Example response:
{
"model": "amazon.nova-micro-v1:0",
"created_at": "2026-08-27T12:00:00.000000+00:00",
"response": "The sky is blue because of Rayleigh scattering...",
"done": true,
"done_reason": "stop",
"total_duration": 734567890,
"prompt_eval_count": 7,
"eval_count": 42
}
Next steps¶
Next: Chat API · Embed API · Models API · Search Models API