REST + WebSocket reference for SynapCores Community Edition. Works with any HTTP client in any language — cURL, Node, Python, PHP samples per endpoint.
Start with one command
1. Install Community Edition (free, no signup)
$curl -fsSL https://get.synapcores.com | SYNAPCORES_REF=developers-hero sh
All endpoints below are under /v1. Replace localhost:8080 with your own host:port.
Auth: both JWT and API key go in Authorization: Bearer …. The gateway picks the right validator from the token prefix (aidb_… for API keys, JWTs are base64-segments). WebSocket routes such as /ws and /mcp take the JWT, on the URL as ?token= or in that header. The legacy X-API-Key header is no longer accepted.
Response envelope: all success responses are wrapped as { data: …, meta: { request_id, timestamp } }. Raw HTTP clients must unwrap body.data; SDKs do this automatically.
Native SDKs for Node.js / TypeScript, Python, PHP / Laravel, Go, and Java / Spring Boot — see Install a native SDK just below. For every other language, the REST samples on this page are plain HTTP calls — no SDK required.
Node.js / TypeScript, Python, PHP, Go, and Java all ship a typed SDK that wraps the full Community Edition gateway surface — auth, SQL, graph, vectors, AI chat, AutoML, recipes, and more. Pick your language below; any other stack uses the REST samples that follow. Laravel users get a thin companion package on top of the PHP SDK (facade, artisan commands, Eloquent vector cast, queueable agent jobs); Spring Boot users get an auto-configured SynapCores bean plus an optional Actuator health indicator on top of the Java SDK.
// npm install @synapcores/sdk
import { SynapCores } from '@synapcores/sdk';
const client = new SynapCores({
host: 'localhost',
port: 8080,
apiKey: process.env.AIDB_API_KEY, // aidb_… key from POST /v1/api-keys
});
const result = await client.executeQuery({ sql: 'SELECT 1 AS ok' });
console.log(result);
Both SDKs follow the gateway surface — when the engine adds a route, the next SDK release wraps it. Pin a major version in your dependency manifest if you want lockstep upgrades.
1. Authentication
Every request needs either a JWT (from /auth/login) or an API key — BOTH go in the Authorization header as "Bearer <token-or-key>". WebSocket routes such as /ws and /mcp take the JWT, on the URL as ?token= or in that header. API keys look like aidb_… (aidb_ plus 64 characters). Create one with POST /v1/api-keys and a body such as {"name": "backend", "permission": "ReadOnly", "expires_in_days": 90} (permission is FullAccess or ReadOnly); the response shows the key once. (Legacy X-API-Key header was retired in the v1.6.5.2-ce wire-format alignment — current servers reject it.)
POST/v1/auth/login
Returns a JWT. If MFA is enabled the response includes mfa_required and you exchange via /v1/auth/mfa/verify.
Both auth schemes shown. Pick one — JWT for interactive sessions, API key for service-to-service.
# JWT (interactive sessions)
curl -s http://localhost:8080/v1/users/me -H "Authorization: Bearer $TOKEN"
# API key (preferred for backend services — same header)
curl -s http://localhost:8080/v1/users/me -H "Authorization: Bearer aidb_..."
2. SQL execution
Run parameterised SQL. Placeholders are PostgreSQL-style: $1, $2, $3 in the SQL string, parameters as a positional array. Returns columns metadata + rows.
Send a plain-English question, get back an executed query with rows. Schema-aware: the planner injects your live table catalog into the LLM prompt. Falls back to a deterministic pattern matcher when no LLM provider is configured.
POST/v1/nl2sql/query
curl -s -X POST http://localhost:8080/v1/nl2sql/query \
-H "Authorization: Bearer $AIDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"question": "Show me top 5 products by revenue last quarter",
"execute": true
}'
4. Document collections
Schema-flexible JSON document stores with built-in vector + full-text indexing. Drop a JSON blob, add a vector field, do similarity search inline.
POST/v1/collections
Create a collection with typed fields and indexes.
Standalone vector store with an HNSW index ("index_type": "hnsw") or exact flat search (the default) per collection. For pure-vector workloads (semantic search over embeddings, recommendation, RAG retrieval) without the document overhead.
POST/v1/vectors/collections
Create a vector collection. distance_metric is cosine (the default), euclidean or dotproduct; index_type is hnsw or flat (the default, exact search).
Insert vectors with optional metadata; an existing id is replaced. For bulk loads, send many vectors in one "vectors" array, keeping each request body within 130,816 bytes of JSON with the default configuration (about 25 vectors of 384 dimensions as /v1/ai/embeddings returns them).
k-NN search: the k closest vectors, closest first; include_metadata returns each match's metadata. A flat collection (the default) applies the metadata filter before the top-k cut, so a filtered search returns the k closest matching vectors. An hnsw collection applies it to the closest candidates its index finds: for a filter that matches only a few vectors, search a flat collection or raise k.
Run Cypher queries against the property graph. Mix structural patterns, vector hops via SIMILAR_TO, and LLM-graded scoring with llm_score() in a single MATCH.
POST/v1/graph/match
Execute a Cypher query. Parameters use $name placeholders.
LLM-driven knowledge-graph extraction — send unstructured text, get back nodes and edges.
curl -s -X POST http://localhost:8080/v1/graph/extract \
-H "Authorization: Bearer $AIDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "In Q3 our CFO Susan Wong joined the call with CEO Tom Chen and confirmed Acme Corp acquired RegionTech for $40M.",
"graph": "earnings_calls"
}'
POST/v1/graph/algorithms
Run PageRank, Louvain (community detection), Label Propagation, or Triangle Count via CALL.
Multi-turn conversational interface with server-side persistent memory. The default chat model runs in-process (llama.cpp): the engine picks one that fits its memory (qwen2.5:0.5b, llama3.2:1b or qwen2.5:7b) and downloads it on first start; OpenAI / Anthropic / Gemini / Ollama are configurable. For AGENT_RUN tool calls, use a tool-capable model such as qwen2.5:7b, or a hosted OpenAI, Anthropic or Gemini model.
POST/v1/ai/sessions
Create a chat session, get back a session_id you reuse for all messages.
curl -s -X POST http://localhost:8080/v1/ai/chat \
-H "Authorization: Bearer $AIDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"session_id": "sess_abc",
"content": "Summarize the sales-pipeline movement this week"
}'
POST/v1/ai/chat/stream
Server-Sent-Events streaming. Tokens arrive incrementally; flush them straight to your UI.
curl -N -X POST http://localhost:8080/v1/ai/chat/stream \
-H "Authorization: Bearer $AIDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"session_id":"sess_abc","content":"Walk me through ..."}'
8. Embeddings + NLP
MiniLM (all-minilm:latest, 384 dimensions) serves embeddings in-process — no external API key needed; the engine downloads it on first start. Plus sentiment / entities / summarization / classification helpers.
POST/v1/ai/embeddings
Single text in, vector out. Use /v1/ai/embeddings/batch for arrays.
NLP helpers — same request envelope, different endpoint per task.
# sentiment
curl -s -X POST http://localhost:8080/v1/ai/sentiment \
-H "Authorization: Bearer $AIDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"the support was slow and the product never worked"}'
# summarize
curl -s -X POST http://localhost:8080/v1/ai/summarize \
-H "Authorization: Bearer $AIDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"...long article...","max_length":120}'
9. Recipes
180+ hand-curated recipes ship with every CE binary; more live on the homepage at /recipes/ and can be imported by URL. List, fetch, execute, and bind your own parameters via REST. Recipes can themselves call EMBED, GENERATE, AGENT_RUN, and Cypher — they bundle schema + seed + workflow into one importable unit.
Import a recipe from a remote URL (synapcores.com/recipes/... or any reachable raw-markdown link). The recipe is parsed, validated, certified against the local engine version, and persisted so subsequent /execute calls find it. Useful for picking up community recipes without rebuilding the binary.
Drop a file into a watched folder and SynapCores automatically chunks + embeds + OCRs + transcribes. Manage collections via REST and stream live progress over WebSocket.
POST/v1/filesystem-collections
Create a watched folder. Returns a collection id and the inferred ingest plan.
WebSocket — live ingest events. Authenticate with a JWT from POST /v1/auth/login, passed on the URL as ?token=.
// open the websocket with a JWT (from POST /v1/auth/login) on the URL
const ws = new WebSocket(
`ws://localhost:8080/ws/filesystem-collections/${id}/progress?token=${token}`,
);
ws.onmessage = (e) => console.log(JSON.parse(e.data));
11. Multimodal
Interpret images natively (describe / visual Q&A) in-process — no cloud key, no daemon — plus cross-modal similarity, search, and embeddings (text↔image↔audio). Vision runs on the local provider by default; OpenAI GPT-4o / Anthropic Claude / Ollama LLaVA also work.
POST/v1/multimodal/describe
Describe or answer a question about an image. Runs in-process on the local vision model (default llava; override per-request with "model", or set AIDB_VISION_MODEL). Set "provider" to openai/anthropic/ollama to use a cloud/daemon model instead.
# image must be base64-encoded (no data: prefix)
IMG=$(base64 -w0 photo.jpg)
curl -s -X POST http://localhost:8080/v1/multimodal/describe \
-H "Authorization: Bearer $AIDB_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"prompt\":\"Describe this image in one sentence.\",\"image\":\"$IMG\"}"
# -> {"text":"...","model":"llava"}
POST/v1/multimodal/search
Cross-modal search — query in any modality, results in any modality.
curl -s -X POST http://localhost:8080/v1/multimodal/search \
-H "Authorization: Bearer $AIDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": {"text": "a red sports car at sunset"},
"modalities": ["image"],
"limit": 10
}'
POST/v1/multimodal/embed
Get an embedding for a text/image/audio/video input.
Train and deploy ML models without writing Python. Train with one CREATE EXPERIMENT statement, then call the trained model by name behind a /predict endpoint.
POST/v1/query/execute
Train a model with CREATE EXPERIMENT. The experiment name becomes the model name you predict with.
13. Inline SQL AI primitives — EMBED, GENERATE, AGENT_RUN
These are SQL functions you call inside any /v1/query/execute statement — no extra endpoint. EMBED returns a vector, COSINE_SIMILARITY scores it, GENERATE runs a one-shot LLM completion, and AGENT_RUN runs a full ReAct agent loop (tool calls, memory, multi-turn reasoning) as a single SQL value. Each ships with a minimum-version stamp below.
POST/v1/query/execute · EMBED + COSINE_SIMILARITY · Available v1.5.0-ce+
Generate a vector and search by meaning, inline in regular SQL. No separate /v1/vectors call. EMBED uses the engine's configured embedding model (MiniLM by default, 384-dim).
curl -s -X POST http://localhost:8080/v1/query/execute \
-H "Authorization: Bearer $AIDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"sql": "SELECT title, COSINE_SIMILARITY(embedding, EMBED($1)) AS sim FROM docs ORDER BY sim DESC LIMIT 5",
"parameters": ["how long for refunds?"]
}'
POST/v1/query/execute · GENERATE · Available v1.6.0-ce+
Inline LLM completion as a SQL value. Useful for per-row classification, summarization, or response composition without round-tripping to /v1/ai/chat.
curl -s -X POST http://localhost:8080/v1/query/execute \
-H "Authorization: Bearer $AIDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"sql": "SELECT ticket_id, GENERATE('"'"'Classify the urgency of this ticket as high, medium, or low: '"'"' || body) AS urgency FROM tickets WHERE created_at > NOW() - INTERVAL '"'"'1 day'"'"'"
}'
POST/v1/query/execute · AGENT_RUN · Available v1.7.0-ce+
Full ReAct agent loop callable as a SQL value. The agent runs server-side with access to the same database, calls tools (execute_query, rag_search, etc.), and returns a synthesized answer with citations. Wall-clock 5-60s — use a 120s HTTP timeout client-side. Requires a tool-capable LLM in [query.ai_service], such as qwen2.5:7b (in-process or via Ollama) or a hosted OpenAI, Anthropic or Gemini model.
curl -s -X POST http://localhost:8080/v1/query/execute \
-H "Authorization: Bearer $AIDB_API_KEY" \
-H "Content-Type: application/json" \
--max-time 120 \
-d '{
"sql": "SELECT AGENT_RUN($1, $2) AS recommendation",
"parameters": [
"aidb-assistant",
"Look at claim CX-9001. Use execute_query to check prior claims for fraud patterns and rag_search on policy_docs for applicable clauses. Output: recommended action with citations."
]
}'
14. MCP — Model Context Protocol
JSON-RPC endpoint (MCP over HTTP) that exposes SynapCores as a tool server to any LLM agent — Claude Code, Cursor, OpenClaw, or your own ReAct loop. The LLM sees query / execute / list_tables / describe_table / semantic_search / graph_query / sql_manual as native function calls and invokes them on its own. Auth: an API key in the Authorization: Bearer header, the same as every REST call. Client configs for Claude Code, Cursor and VS Code are in the MCP guide at /docs/mcp. A WebSocket at /mcp serves the same JSON-RPC with a JWT. Available v1.6.6.9-ce+.
Stdio clients can also use @synapcores/mcp on npm (npx -y @synapcores/mcp). Like the installer's synapcores-mcp-bridge.js described below, it connects them to POST /v1/mcp; set SYNAPCORES_URL and SYNAPCORES_API_KEY (SYNAPCORES_TOKEN also works). Source is in the synapcores-mcp GitHub repository, and it is listed in the Glama MCP server directory.
POST/v1/mcp
Send JSON-RPC 2.0 in the request body (initialize, tools/list, tools/call) with Authorization: Bearer <API key>; a JWT works too. Tool list, schemas, and arguments follow the MCP spec; the HTTP tool list also includes embed_text, generate_text and the AutoML tools. Stdio clients such as Claude Desktop connect through synapcores-mcp-bridge.js, which the installer places in ~/.synapcores/ and the gateway serves at GET /v1/mcp/bridge; the bridge forwards each message to this route (set SYNAPCORES_URL to your instance and SYNAPCORES_TOKEN to an API key).
The same JSON-RPC over a WebSocket. Authenticate with the access_token (a JWT) from POST /v1/auth/login, on the URL as ?token= or as Authorization: Bearer on the upgrade. The WebSocket tool list has the SQL tools (query, execute, list_tables, describe_table, validate_query, sql_manual), the agent-memory tools (memory_remember, memory_recall, memory_current, memory_trace, memory_forget), list_agents and execute_agent; semantic_search and graph_query are on POST /v1/mcp.
// token: a JWT from POST /v1/auth/login
import WebSocket from 'ws';
const ws = new WebSocket(`ws://localhost:8080/mcp?token=${token}`);
ws.on('open', () => {
ws.send(JSON.stringify({
jsonrpc: '2.0', id: 1, method: 'tools/list', params: {},
}));
});
ws.on('message', (m) => console.log(JSON.parse(m.toString())));
15. Transactions
ACID transactions over REST. Begin → execute → commit/rollback, with optional named savepoints.
POST/v1/transactions
Begin a transaction, get back a transaction id.
# 1. begin
TX=$(curl -s -X POST http://localhost:8080/v1/transactions \
-H "Authorization: Bearer $AIDB_API_KEY" | jq -r .id)
# 2. execute one or more statements in the tx
curl -s -X POST http://localhost:8080/v1/transactions/$TX/execute \
-H "Authorization: Bearer $AIDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"sql":"UPDATE accounts SET balance = balance - $1 WHERE id = $2","parameters":[100,"acc_1"]}'
# 3. commit
curl -s -X POST http://localhost:8080/v1/transactions/$TX/commit \
-H "Authorization: Bearer $AIDB_API_KEY"
16. WebSocket
The WebSocket endpoint at /ws handles AI chat streaming and live subscriptions. Connect with ?token=<jwt>, using the access_token from POST /v1/auth/login (valid for 24 hours by default), or send it as Authorization: Bearer from clients that can set headers, and send once the socket is open. To stream SQL results, POST /v1/query/stream returns NDJSON: a schema line, one line per row, then an end line.
// Browser: token is a JWT from POST /v1/auth/login
const ws = new WebSocket(`ws://localhost:8080/ws?token=${token}`);
ws.onmessage = (e) => console.log(JSON.parse(e.data));
// Send once the socket is open
ws.onopen = () => {
ws.send(JSON.stringify({ type: 'subscribe', channel: 'ai-chat' }));
ws.send(JSON.stringify({ type: 'ping' })); // answered on the ai-chat channel
};
17. Errors + conventions
Success envelope: every 2xx body is { "data": …, "meta": { "request_id", "timestamp" } }. Raw HTTP clients must unwrap body.data; SDKs do this for you.
Status codes follow standard REST: 2xx success, 4xx user error, 5xx server error. 401 = bad/expired auth, 403 = authenticated but not authorized, 404 = not found, 409 = conflict (duplicate key), 429 = rate-limited.
Row caps on /v1/query/execute(Available v1.7.0.1-ce+): pass "max_rows": N in the request to raise the cap, or set SQL_MAX_ROW_COUNT in the container env (default 1000). When a result was capped the response body carries data.truncated: true — clients should detect it, warn the user, and bump the cap. Phase 2 cursor pagination ships in v1.7.0.2-ce.
Pagination: limit + offset on list endpoints. Cursor-based pagination on hot paths returns next_cursor in the body.
Rate limits: per-tenant default 60 RPS, burst 120. Response headers include X-RateLimit-Remaining and X-RateLimit-Reset.
Idempotency: send Idempotency-Key header on POST/PUT to make retries safe.
Versioning: every endpoint is namespaced under /v1. Breaking changes ship under /v2 with a deprecation window. Individual features that aren't in every CE version are marked inline as "Available vX.Y.Z+".