Public developer documentation
Next-question intelligence, without slowing down your chat.
ContextChips observes conversation turns in one project and returns up to three relevant follow-up questions. The recommended flow precomputes candidates while your AI is already generating its answer.
Quickstart
Create a project API key in the dashboard after your workspace has been approved, then keep it in server-only environment variables.
Terminalpnpm add @contextchips/sdkTypeScriptimport { ContextChips } from "@contextchips/sdk";
const chips = new ContextChips({
apiKey: process.env.CONTEXTCHIPS_API_KEY!,
baseUrl: process.env.CONTEXTCHIPS_BASE_URL, // optional
});
// Begin this at the same time as your host-model request.
const retrieval = chips.startTurn({
sessionId: chat.id,
userMessage: userMessage,
});
const assistantMessage = await myAssistant.respond(userMessage);
const started = await retrieval;
// Render result.suggestions in your own UI.
const result = await chips.completeTurn({
turnId: started.turnId,
sessionId: chat.id,
assistantMessage,
});completeTurn succeeds. A started turn is a short-lived pending record; it expires if it is never completed.The recommended two-phase flow
- Start: send only the user message. ContextChips searches bounded, project-scoped history and creates a short-lived candidate pool.
- Your AI answers: this happens in parallel. ContextChips does not sit in your model's critical answer path.
- Complete: submit the assistant answer. The API removes candidates already answered, selects a diverse set, persists the turn, and returns chips.
- Refine: a background worker performs non-critical analytics/refinement. Your UI can show the immediate result without waiting.
cURL — phase onecurl -X POST "$CONTEXTCHIPS_BASE_URL/v1/turns/start" \
-H "Authorization: Bearer $CONTEXTCHIPS_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 6cc8cce7-2fe5-4cfe-a679-9edcec96f5e2" \
-d '{
"turnId": "6cc8cce7-2fe5-4cfe-a679-9edcec96f5e2",
"sessionId": "chat_123",
"userMessage": "How do I invite my team?"
}'cURL — phase twocurl -X POST "$CONTEXTCHIPS_BASE_URL/v1/turns/complete" \
-H "Authorization: Bearer $CONTEXTCHIPS_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 6cc8cce7-2fe5-4cfe-a679-9edcec96f5e2" \
-d '{
"turnId": "6cc8cce7-2fe5-4cfe-a679-9edcec96f5e2",
"sessionId": "chat_123",
"assistantMessage": "Open Settings, then select Members."
}'Response{
"turnId": "6cc8cce7-2fe5-4cfe-a679-9edcec96f5e2",
"conversationId": "b6e1b94e-9c8e-4585-b8d2-6b4b49229f22",
"pending": false,
"usedFallback": false,
"suggestions": [
{
"id": "24b5d5de-ec48-4fc3-a426-a5e2fb0f95ec",
"text": "Can I assign an admin role?",
"score": 0.89,
"reason": "Common next step"
}
]
}SDK reference
| Method | Use | Returns |
|---|---|---|
startTurn() | Precompute before the host answer. | turnId, status, candidate count, expiry. |
completeTurn() | Join the host answer and retrieve immediate chips. | Conversation ID, up to 3 suggestions, fallback signal. |
capture() | Ingest a completed turn asynchronously (legacy/batch flow). | Accepted/duplicate state. |
getSuggestions() | Read the active suggestions for a session. | Conversation ID, chips, worker pending flag. |
trackSuggestion() | Record an impression, click, or dismissal. | Completes with no return value. |
Legacy/batch captureawait chips.capture({
sessionId: "chat_123",
// eventId is generated by the SDK when omitted.
messages: [
{ role: "user", content: "How do I invite my team?" },
{ role: "assistant", content: "Open Settings, then select Members." },
],
metadata: { surface: "web" }, // optional; avoid sensitive values
});Authentication and request rules
All ingestion endpoints require Authorization: Bearer cc_live_.... The key is tied to one project, so retrieval, storage, suggestions, and event tracking stay within that project's data boundary.
- Use JSON request bodies and a server-side API key.
- POSTs accept
Idempotency-Key. Forstartandcomplete, it must matchturnId; for capture/tracking, matcheventIdwhen sent. sessionIdis your stable conversation identifier, 1–256 characters. Do not use email addresses or other PII as session IDs.- Messages support
user,assistant, andsystemroles. Content is limited to 100,000 characters per message.
Endpoints
GET/health
Unauthenticated service readiness check. Returns { ok: true, service: "contextchips-api" }.
POST/v1/turns/start
Preferred first phase. Body: turnId UUID, sessionId, userMessage, optional non-sensitive metadata. Returns 202 with turnId, status, candidateCount, and expiresAt.
POST/v1/turns/complete
Preferred second phase. Body: the same turnId, same sessionId, assistantMessage, and optional metadata. Returns immediate active suggestions. A missing start is 404 TURN_NOT_FOUND; an expired start is 410 TURN_EXPIRED.
POST/v1/chat-turns
Legacy asynchronous capture. Body: eventId UUID, sessionId, messages (2–100), optional metadata. Returns 202 when queued or 200 with duplicate: true for a repeat event.
GET/v1/suggestions?sessionId=…
Reads up to three active suggestions for a project-scoped conversation. Returns 404 if the session does not exist. pending indicates worker refinement is still queued or running.
POST/v1/suggestions/:id/events
Records impression, clicked, or dismissed. Body: eventId UUID and type. Returns 201, or 200 for an idempotent duplicate.
POST/v1/dashboard/projects/:projectId/api-keys
Dashboard-only key creation. Requires the signed-in developer's Supabase JWT and authorized project membership; the raw key is returned exactly once.
POST/v1/dashboard/projects/:projectId/api-keys/:keyId/revoke
Dashboard-only revocation. Requires the signed-in developer's Supabase JWT and authorized project membership. Returns 204.
GET/v1/dashboard/projects/:projectId/knowledge
Lists optional project knowledge sources. Owner/admin only.
POST/v1/dashboard/projects/:projectId/knowledge
Creates optional knowledge with title, content, optional sourceType, priority, and isActive. Knowledge is never sent through the runtime SDK.
PATCH/v1/dashboard/projects/:projectId/knowledge/:knowledgeId
Updates a knowledge source. Owner/admin only.
DELETE/v1/dashboard/projects/:projectId/knowledge/:knowledgeId
Deletes a knowledge source. Owner/admin only.
GET/v1/dashboard/access/me
Returns the signed-in user's workspace state: none, pending, active, rejected, or suspended.
POST/v1/dashboard/access-requests
Requests access to an existing workspace after sign-up. A pending account cannot access tenant data or create API keys.
GET/v1/dashboard/organizations/:organizationId/access-requests
Lists pending workspace access requests. Owner/admin only.
PATCH/v1/dashboard/organizations/:organizationId/access-requests/:requestId
Owner/admin approval endpoint. Only an owner can grant an admin role.
GET/v1/dashboard/organizations/:organizationId/members
Lists members and their active, pending, or suspended state. Owner/admin only.
PATCH/v1/dashboard/organizations/:organizationId/members/:userId/access
Suspends or restores a member. Suspending revokes keys issued by that member.
Errors, retries, and incomplete turns
Error responses use { error: { code, message }, requestId }. The SDK retries network failures, 408, 429, and 5xx responses with bounded exponential backoff.
| Situation | Result | What to do |
|---|---|---|
| The developer never calls complete | The user-only pending turn expires. No completed chat event is stored from that flow. | Do nothing; start a new turn for the next user message. |
| Complete is retried | The same turn returns its persisted result once complete. | Reuse the exact turn ID and idempotency key. |
| Two callers complete simultaneously | One caller gets 409 TURN_IN_PROGRESS. | Retry shortly with the same ID. |
| Final model selection is unavailable | Ranked observed candidates, or safe cold-start prompts, are returned with usedFallback: true. | Render them normally and monitor fallback rate; runtime chips are kept stable for retry safety. |
Privacy and PII: the current reality
When a project's pii_redaction_enabled setting is on (the database default), the API scrubs common direct identifiers before persistence and before the optional selection model sees a turn: emails, phone numbers, Luhn-valid card numbers, IPv4 addresses, recognizable project/OpenAI-style secrets, and metadata values whose keys indicate a credential or contact field. Session IDs are stored as stable HMAC-based opaque identifiers rather than raw values.
This is a deterministic baseline, not full PII compliance. It applies to new writes, not retroactive historical cleanup. It does not classify every language, entity, government identifier, health record, or proprietary document; it has no deletion API, consent workflow, data-residency control, or enforced retention worker yet. Project isolation prevents cross-project reads; it does not make arbitrary personal data safe to ingest.
Before production use with personal data, add retention/deletion operations, subject-access handling, a DPA/security review, and application-side redaction suited to your jurisdiction and data types.
For coding agents
This page is public and the compact machine-readable integration contract is available as /docs/llms.txt. Give that URL to a coding agent together with your server framework and host-model call.
docs/llms.txt# ContextChips integration contract
Use ContextChips only from a trusted server. Never expose a cc_live_ API key
in browser code, mobile clients, logs, URLs, or NEXT_PUBLIC_ variables.
Preferred flow per interaction:
1. Start POST /v1/turns/start in parallel with the host LLM call.
2. Keep returned turnId. Call POST /v1/turns/complete with the exact same
turnId, sessionId, and the finished assistantMessage.
3. Render up to three returned suggestions. Track impressions/clicks/dismissals
from your trusted backend.
Authentication: Authorization: Bearer cc_live_... for ingestion APIs.
Idempotency: POST requests accept Idempotency-Key. For start/complete, it must
equal turnId. For capture/tracking, it must equal eventId when supplied.
With a project's pii_redaction_enabled setting (on by default), ContextChips
scrubs common emails, phone numbers, valid card numbers, IP addresses, known
secret formats, and sensitive metadata keys before storage and model selection.
This is a baseline safeguard, not a complete PII classifier or compliance
program. Do not send secrets, health data, government IDs, or unnecessary
personal data.