Ollama-compatible API (drop-in replacement)¶
Minimum engine: v2.3.1-ce (the
/api/*surface);/api/versionpre-auth heartbeat and/api/tagsfor table-scoped keys landed in v2.4.0-ce;/api/embedbatch embeddings in v2.5.0-ce. Enabled by default — authentication is required out of the box.
SynapCores serves a bare Ollama-compatible HTTP API under /api/*. Point an existing
Ollama client — ollama-python, LangChain's ChatOllama / OllamaEmbeddings, LlamaIndex, or
your own curl — at the SynapCores gateway and it works without changing the client's
integration layer.
This is the inbound direction: SynapCores is the Ollama server. It is distinct from
pointing SynapCores out at a separate Ollama daemon (provider = "ollama" in
First-run AI setup — Option 2). You do not need Ollama installed to use this;
requests are answered by the native in-process inference engine (the same embedded
llama.cpp that serves GENERATE and AGENT_RUN). There is no external Ollama dependency, no
provider/result cache, and your data never leaves the box.
For a step-by-step walkthrough (enable it, mint a key, redirect each client), see Redirect an Ollama client to SynapCores.
Endpoints¶
All routes are served under /api on the same gateway port as the REST and SQL APIs
(default 8080).
| Method & path | Purpose | Notes |
|---|---|---|
POST /api/generate |
Single-prompt completion | Streaming NDJSON by default; rag grounding extension |
POST /api/chat |
Multi-message chat completion | messages[], tools, rag grounding extension |
POST /api/embed |
Batch embeddings (modern) | input is a string or array of strings |
POST /api/embeddings |
Embeddings (legacy single) | prompt is a single string |
GET /api/tags |
List models available to the caller | Installed models + visible aliases |
GET /api/version |
Version heartbeat | Pre-auth by default; reports compat_version |
POST /api/show |
Model metadata | |
GET /api/ps |
Loaded / resident models |
Error format is Ollama-native, not the SynapCores envelope
These routes deliberately do not use the {data, meta} / {error:{code,message}}
REST envelope. They return Ollama's bare {"error": "<message>"} on failure and the plain
Ollama body on success, so unmodified clients parse them correctly.
Authentication¶
The Ollama surface has its own policy, configured in the [ollama] block (below). It is
independent of the global [auth] setting — turning global auth off does not weaken it.
- Credentials accepted:
Authorization: Bearer <JWT>,Authorization: Bearer aidb_…(API key), orAuthorization: ApiKey <key>. A token beginningaidb_is treated as an API key; anything else as a JWT. Exactly oneAuthorizationheader is allowed. - Default:
allow_anonymous = false, so every data route (/api/generate,/api/chat,/api/embed, …) requires a credential. The credential must be able to read tenant data. GET /api/versionis a pre-auth heartbeat (version_requires_auth = falseby default): it answers without a credential so clients can probe reachability. An invalid credential is still rejected with401.- Table-scoped (restricted) API keys may reach only their allowlisted data routes, plus
the metadata surfaces
GET /api/versionandGET /api/tags(neither reads tenant data). Everything else is denied.
POST /api/generate¶
Request fields (Ollama-standard unless marked):
| Field | Type | Notes |
|---|---|---|
model |
string | required — an installed model name or a configured alias |
prompt |
string | the user prompt |
system |
string | optional system prompt |
raw |
bool | bypass templating |
stream |
bool | defaults to true (Ollama behavior) → NDJSON stream |
format |
string/object | e.g. "json" for JSON-mode |
keep_alive |
— | accepted; native residency is managed by the bounded server cache |
options |
object | Ollama sampling options (temperature, num_predict, …) |
rag |
object | SynapCores extension — grounding |
Streaming chunks look like standard Ollama:
The final chunk carries done:true with timing and token counts
(done_reason, total_duration, load_duration, prompt_eval_count,
prompt_eval_duration, eval_count, eval_duration).
context is not stateful
The context array in the final generate response is returned empty ([]).
SynapCores does not round-trip an opaque conversation context the way a long-lived Ollama
daemon does. For multi-turn conversations use POST /api/chat with the full messages
array, or carry your own history — do not rely on feeding a previous context back in.
POST /api/chat¶
Fields: model (required), messages[] ({role, content, images?, tool_calls?}), stream,
format, keep_alive, tools, options, and the rag extension. The response streams
chunks whose delta is under message ({"message":{"role":"assistant","content":"…"}}),
with the same done/timing fields on the final chunk.
Embeddings¶
POST /api/embed(modern):{"model": "...", "input": "text" | ["a","b"], "dimensions"?: N}.keep_aliveis rejected on embeddings — residency is managed by the bounded cache.POST /api/embeddings(legacy):{"model": "...", "prompt": "text"}, single string.
The default embedding model (all-minilm:latest) returns 384-dim vectors. Mind the
embedding-dimension caveat in First-run AI setup — vectors embedded under one
model must not be searched against another.
rag grounding extension¶
A SynapCores-only extension on /api/generate and /api/chat: attach a rag object to
retrieve bounded context before the completion, so an off-the-shelf Ollama client gets
retrieval-augmented answers with no client-side RAG plumbing.
rag field |
Type | Meaning |
|---|---|---|
source |
string | the collection / data source to ground against |
mode |
inject | agent |
inject retrieves a bounded context before one completion; agent delegates retrieval and answering to the in-database agent service |
top_k |
int | how many chunks to retrieve |
strict |
bool | refuse to answer beyond the retrieved context |
context_tokens |
int | optional cap on injected context |
identity, persona |
string | optional caller identity / agent persona |
Grounding can also be applied automatically per key ([ollama.key_defaults]) or per
alias (below), so a client that cannot send a rag field still gets a governed, grounded
answer.
Configuration — [ollama]¶
Set in gateway.toml. Defaults shown; the whole block is optional (the surface is enabled by
default).
[ollama]
enabled = true # serve the /api/* surface at all
allow_anonymous = false # require a credential on data routes
version_requires_auth = false # /api/version is a pre-auth heartbeat
compat_version = "0.20.6" # version string reported to clients
max_body_bytes = 2097152 # 2 MiB (bounds: 1 KiB … 64 MiB)
max_prompt_bytes = 1048576 # 1 MiB (must be ≤ max_body_bytes)
max_messages = 256 # per chat request (1 … 4096)
max_context_tokens = 32768 # (128 … 131072)
max_output_tokens = 4096 # (1 … 131072)
timeout_secs = 120 # per generate/chat request (1 … 3600)
Model aliases¶
Map a friendly name:tag a client expects onto a base model you have installed, optionally
scoped to a tenant and with default grounding/persona attached:
[ollama.aliases."support-bot:latest"]
model = "qwen2.5:7b"
persona = "support-agent"
[ollama.aliases."support-bot:latest".grounding]
source = "support_docs"
mode = "inject"
top_k = 6
strict = true
Aliases resolve one hop — an alias must name a real base model, not another alias. You
cannot define both name and its implicit name:latest form. Aliases appear in /api/tags
for the tenants allowed to see them.
Changing compat_version
Some clients gate features on the Ollama version string. compat_version controls what
/api/version and /api/tags report; it must be a bounded MAJOR.MINOR.PATCH string.
See also¶
- Redirect an Ollama client to SynapCores — the step-by-step how-to
- First-run AI setup — provider options, including calling out to Ollama
- Release notes — v2.3.1-ce · v2.4.0-ce · v2.5.0-ce