Docs

REST API.

Not every AI speaks MCP. The REST API gives any assistant — ChatGPT, Gemini, or your own code — the same Belleq memory over plain HTTP. Authenticate with a context's API key and call four endpoints: recall, query, record, and flush.

Overview

Each context has its own knowledge base. The REST API exposes that knowledge base over HTTP, scoped by the context's API key. Every request goes to a single base URL:

https://api.belleq.app

The REST API is served only on api.belleq.app. MCP connections live on mcp.belleq.app — the two never mix.

REST or MCP — which to use

Both reach the same context and return the same data. Pick by what your AI supports.

Use MCP

For Claude, Cursor, Windsurf, and any client with custom-connector support. One URL, no key to paste — tools appear automatically.

Use REST

For ChatGPT (Actions), Gemini (function calling), automations, or your own code — anywhere MCP isn't available.

Authentication

Every request is authenticated with a context's API key as a bearer token. The key both proves who you are and selects the context — one key, one context — so you never put a context id in the URL.

Find and copy a context's key in the dashboard: Contexts → open a context → API key → Reveal. You can rotate it any time with Regenerate — the old key stops working at once and your MCP connection is unaffected.

Authorization: Bearer <YOUR_CONTEXT_API_KEY>

Treat the key like a password. Anyone with it can read and write that context's memory. Rotate it immediately if it leaks.

Endpoints

Four endpoints, all POST, all under https://api.belleq.app/v1.

POST/v1/recall
Load recently saved memory for this context. Call it at the start of a conversation to catch up. Body: { "limit": 10 } (optional).
POST/v1/query
Search the knowledge base for a topic. Body: { "query": "..." }. Returns ranked chunks with scores and metadata.
POST/v1/record
Save a user/assistant exchange verbatim. Body: { "user_message", "assistant_message", "conversation_id" }. Belleq distills facts on its side — send the full text, don't summarize.
POST/v1/flush
Index buffered exchanges immediately instead of waiting for the idle sweep. No body.

A machine-readable spec is always available at https://api.belleq.app/v1/openapi.json.

Quickstart

Save an exchange, then search for it — straight from your terminal.

# 1. Record an exchange (send full text, verbatim)
curl -X POST https://api.belleq.app/v1/record \
  -H "Authorization: Bearer $BELLEQ_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "user_message": "We decided to launch on June 30.",
    "assistant_message": "Got it — launch date set to June 30.",
    "conversation_id": "planning-2026"
  }'

# 2. Index it right away
curl -X POST https://api.belleq.app/v1/flush \
  -H "Authorization: Bearer $BELLEQ_KEY"

# 3. Search for it later
curl -X POST https://api.belleq.app/v1/query \
  -H "Authorization: Bearer $BELLEQ_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query": "when are we launching?"}'

Use with ChatGPT

Add Belleq as a custom GPT Action. ChatGPT will then call recall / query / record on its own.

  1. 1Create or edit a GPT → ConfigureCreate new action.
  2. 2Under Schema, choose Import from URL and paste https://api.belleq.app/v1/openapi.json.
  3. 3Set Authentication to API Key → Bearer, and paste your context API key.
  4. 4Save. Paste the snippet below into the GPT's Instructions so it uses the memory loop automatically.

Use with Gemini

Gemini has no custom-connector UI, so register the endpoints as function declarations in your own app and forward the calls to the REST API with your key.

import os, requests
from google import genai
from google.genai import types

BELLEQ = "https://api.belleq.app/v1"
KEY = os.environ["BELLEQ_KEY"]

def belleq(op: str, **body):
    r = requests.post(f"{BELLEQ}/{op}",
        headers={"Authorization": f"Bearer {KEY}"}, json=body)
    r.raise_for_status()
    return r.json()

recall = types.FunctionDeclaration(
    name="recall", description="Load recent Belleq memory at the start of a chat.",
    parameters={"type": "object", "properties": {"limit": {"type": "integer"}}})
query = types.FunctionDeclaration(
    name="query", description="Search Belleq memory for a topic.",
    parameters={"type": "object", "properties": {"query": {"type": "string"}},
                "required": ["query"]})

client = genai.Client()
tools = types.Tool(function_declarations=[recall, query])
# When Gemini calls a function, dispatch it: belleq(call.name, **call.args)

Use from code

The API is just HTTP — wire it into any script, agent, or backend.

import os, requests

BELLEQ = "https://api.belleq.app/v1"
H = {"Authorization": f"Bearer {os.environ['BELLEQ_KEY']}"}

# Search
hits = requests.post(f"{BELLEQ}/query", headers=H,
    json={"query": "launch date"}).json()
for c in hits["chunks"]:
    print(round(c["score"], 2), c["text"])

# Save + index
requests.post(f"{BELLEQ}/record", headers=H, json={
    "user_message": "...", "assistant_message": "...",
    "conversation_id": "session-1"})
requests.post(f"{BELLEQ}/flush", headers=H)

The memory loop

For hands-free memory, tell your assistant to run this loop. Paste it into the system prompt / instructions of any REST-connected AI:

You have a persistent memory tool, Belleq. Use it automatically:
1. At the START of a conversation, call recall to load prior context.
2. When a question needs past detail, call query before answering.
3. After EACH reply, call record with the user's message and your reply
   verbatim (do not summarize). Reuse one conversation_id for the chat.
4. Call flush when the conversation winds down.
Do this silently, without asking permission.

Always send the verbatim message and reply to record — don't pre-summarize. Belleq distills the raw turn on its side, so summarizing first throws away detail it could have kept.

Errors

401

Missing or invalid API key. Check the Authorization header, or reveal the current key in the dashboard.

404

Wrong host. The REST API is only on api.belleq.app — not mcp.belleq.app or the bare domain.

409

The context is still provisioning. Wait until it shows as ready in the dashboard.

502

The memory service is temporarily unreachable. Retry shortly.

Get your API key

Open a context in the dashboard, reveal its API key, and make your first call.

Go to Contexts