Redirect an Ollama client to SynapCores¶
Minimum engine: v2.3.1-ce. This how-to uses the Ollama-compatible API — read that for the full route, auth, and configuration reference.
If you already run an Ollama client — ollama-python, LangChain's ChatOllama /
OllamaEmbeddings, LlamaIndex, or raw curl — you can point it at SynapCores and keep your
integration code. SynapCores answers with its native in-process engine: no Ollama daemon,
no data leaving the box, and the same models that back GENERATE and AGENT_RUN.
The only real differences from a stock Ollama server: you authenticate (Ollama has no auth; SynapCores requires a credential by default), and the base URL points at the SynapCores gateway.
Step 1 — Confirm the surface is enabled¶
It is on by default. Probe the pre-auth heartbeat:
If you get {"error":"Ollama API is disabled"}, set enabled = true under [ollama] in
gateway.toml and restart. If the port is unreachable, the gateway isn't running on 8080.
Step 2 — Get a credential¶
Unlike Ollama, data routes require a credential. Two choices:
Create a full-access key once and reuse it:
TOKEN=$(curl -s -X POST http://localhost:8080/v1/auth/login \
-H 'content-type: application/json' \
-d '{"username":"admin","password":"<admin-password>"}' | jq -r .data.access_token)
KEY=$(curl -s -X POST http://localhost:8080/v1/api-keys \
-H "Authorization: Bearer $TOKEN" -H 'content-type: application/json' \
-d '{"name":"ollama-clients","permission":"FullAccess"}' | jq -r '.data.key')
echo "$KEY" # aidb_...
Both go in the Authorization: Bearer … header. The admin bootstrap password is printed in
the server/container logs on first boot.
Step 3 — List the models you can use¶
These are the models installed in your data_dir plus any aliases
your tenant can see. Pull more with synapcores pull <model> (see
First-run AI setup).
Step 4 — Point your client at it¶
# Generate (non-streaming for a clean one-shot)
curl -s http://localhost:8080/api/generate \
-H "Authorization: Bearer $KEY" -H 'content-type: application/json' \
-d '{"model":"qwen2.5:7b","prompt":"Say hello in one word.","stream":false}' | jq -r .response
# Chat
curl -s http://localhost:8080/api/chat \
-H "Authorization: Bearer $KEY" -H 'content-type: application/json' \
-d '{"model":"qwen2.5:7b","stream":false,
"messages":[{"role":"user","content":"Capital of France?"}]}' | jq -r .message.content
from ollama import Client
client = Client(
host="http://localhost:8080",
headers={"Authorization": "Bearer aidb_..."}, # your API key
)
print(client.generate(model="qwen2.5:7b", prompt="Say hello in one word.")["response"])
print(client.chat(model="qwen2.5:7b",
messages=[{"role": "user", "content": "Capital of France?"}]
)["message"]["content"])
from langchain_ollama import ChatOllama, OllamaEmbeddings
llm = ChatOllama(
base_url="http://localhost:8080",
model="qwen2.5:7b",
client_kwargs={"headers": {"Authorization": "Bearer aidb_..."}},
)
print(llm.invoke("Capital of France?").content)
emb = OllamaEmbeddings(
base_url="http://localhost:8080",
model="all-minilm:latest",
client_kwargs={"headers": {"Authorization": "Bearer aidb_..."}},
)
print(len(emb.embed_query("hello world"))) # 384
from llama_index.embeddings.ollama import OllamaEmbedding
emb = OllamaEmbedding(
model_name="all-minilm:latest",
base_url="http://localhost:8080",
ollama_additional_kwargs={},
# pass the auth header through the underlying httpx client:
# (set OLLAMA_HOST / headers as your client version supports)
)
print(len(emb.get_text_embedding("hello world"))) # 384
Verified client matrix
The compatibility surface is tested against ollama 0.6.3, langchain-ollama 1.1.0,
and LlamaIndex embeddings. Clients that gate behavior on the reported Ollama version
read compat_version (default 0.20.6) — adjust it under [ollama] if a client needs a
specific floor.
Step 5 (optional) — Grounded answers with no client changes¶
Attach a rag object to a generate/chat call and the off-the-shelf client gets
retrieval-augmented answers — SynapCores retrieves the context and grounds the completion:
curl -s http://localhost:8080/api/chat \
-H "Authorization: Bearer $KEY" -H 'content-type: application/json' \
-d '{"model":"qwen2.5:7b","stream":false,
"messages":[{"role":"user","content":"What is our refund window?"}],
"rag":{"source":"support_docs","mode":"inject","top_k":6,"strict":true}}' \
| jq -r .message.content
If a client can't send custom fields, configure grounding per key
([ollama.key_defaults]) or per alias so every request from that client is grounded
automatically. See grounding in the reference.
Gotchas¶
- Auth is required by default. A bare client with no
Authorizationheader gets401on data routes./api/versionanswers without one (heartbeat); invalid credentials still401. streamdefaults to true (Ollama behavior). Pass"stream": falsefor a single JSON body; otherwise read the NDJSON stream.contextis not stateful. Thegenerateresponse returns an emptycontextarray — use/api/chatwith a fullmessagesarray for multi-turn, not a fed-backcontext.- In Docker, the gateway is on the published host port; from another container reach it
at
http://host.docker.internal:8080, notlocalhost. - Embedding dimensions must match your vector columns —
all-minilm:latestis 384-dim. See First-run AI setup.
See also¶
- Ollama-compatible API — full route, auth, and config reference
- First-run AI setup — model options and the outbound Ollama provider