---
title: "POST /api/v1/{context_id}/chat"
method: POST
path: "/api/v1/{context_id}/chat"
---

# POST /api/v1/{context_id}/chat

`POST /api/v1/{context_id}/chat`

Phase 7.5 — Spectron-as-agent chat endpoint. Stores the user message via /facts, retrieves context via the unified /query router, calls the configured LLM provider, stores the assistant response via /facts, and emits a response_trace. Set `stream=true` for SSE.

## Path parameters

- `context_id` string, required

## Request body

- ChatRequestJson
  - `bypassCache` boolean — Phase 7.6 — when `true` skips the tier-2 response cache and forces a fresh tier-3 call. Defaults to `false`.
  - `labels` string[] — Descriptive labels for rows the chat persists.
  - `message` string, required
  - `model` string, nullable
  - `scopes` array[] — A DNF scope selector: an OR of conjunctive clauses. Each clause is an array of scope paths, ALL of which a reader must cover (AND); the outer array is the OR. E.g. [["team/a"],["team/b","clearance/secret"]] means team/a OR (team/b AND clearance/secret). Empty means unscoped (the caller's default region). A bare string is also accepted as a singleton clause.
    - string[]
  - `sessionId` string, nullable
  - `stream` boolean

## Response `200`

- ChatResponseJson
  - `memoryUpdates` ExtractionResultJson, required
    - `attributes` AttributeSummaryJson[], required
      - `entityId` string, required
      - `id` string, required
      - `key` string, required
      - `memoryCategory` 'identity' | 'knowledge' | 'context', required — Memory category classification applied during extraction.
      - `value` string, required
    - `corrections` CorrectionSummaryJson[], required
      - `entityId` string, required
      - `key` string, required
      - `newValue` string, required
      - `oldValue` string, required
    - `entities` EntitySummaryJson[], required
      - `entityType` string, required
      - `id` string, required
      - `isNew` boolean, required
      - `memoryCategory` 'identity' | 'knowledge' | 'context', required — Memory category classification applied during extraction.
      - `name` string, required
    - `instructions` InstructionSummaryJson[], required
      - `description` string, required
      - `id` string, required
      - `label` string, required
    - `relations` RelationSummaryJson[], required
      - `label` string, required
      - `memoryCategory` 'identity' | 'knowledge' | 'context', required — Memory category classification applied during extraction.
      - `object` string, required
      - `subject` string, required
    - `turnId` string, required
    - `uncertainties` UncertaintySummaryJson[], required
      - `about` string, required
      - `reason` string, required
  - `reply` string, required
  - `sessionId` string, required
  - `traceId` string, required

## Other responses

- `400` — Invalid request
- `401` — Unauthorized
- `422` — Invalid context id

---

[API](https://skmtc.net/surrealdb/apis/spectron.md) · [All operations](https://skmtc.net/surrealdb/apis/spectron/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/surrealdb/spectron/versions/52b41ab517b6/schema)
