llm.chat/v1
A chat is a conversation with a language model that the provider stores: the app keeps only its id. Each question goes
to llm.text/v1 with the chat's recent messages and a summary of the older ones, and both
turns are saved. The cloud providers keep no conversations themselves (every call sends the whole conversation), which
is what this contract is for. Chats aren't tied to users: an app that has them puts the user's id in the chat's meta,
lists by it, and decides who may read what.
A wire contract at /api/_c/llm.chat/v1 (chat.go), one provider. It requires llm.text/v1. The
llm-chat extension provides it.
Use
In page code (the llm extension binds these on $llm.chat when a provider runs):
const id = $llm.chat.new({ title: "Support", meta: { user: ctx.auth.id } })
const chat = $llm.chat.open(id, { model: "vultr/glm-5.2", system: preamble, context: (q) => findExcerpts(q) })
const answer = await chat.sendAsync(question) // or sendAsync(question, { onText }) to stream it
chat.history({ limit: 20 }) // [{ id, role, content, created }], oldest first
$llm.chat.list({ meta: { user: ctx.auth.id } })
$llm.chat.forget({ meta: { user: deletedUserId } })
Over HTTP (a superuser, or a token with the chat scope):
| Operation |
HTTP (POST) |
Body |
Token scope |
| New |
/api/_c/llm.chat/v1/new |
{"title": "", "meta": {}} |
chat |
| Send |
/api/_c/llm.chat/v1/send |
{"id": "...", "text": "...", "model": "vultr/glm-5.2", "system": "", "window": 12, "summarizeEvery": 6, "context": ""} |
chat |
| Send, streamed |
/api/_c/llm.chat/v1/send-stream |
as Send; server-sent events of llm.text/v1 chunks |
chat |
| Get |
/api/_c/llm.chat/v1/get |
{"id": "..."} |
chat:read |
| History |
/api/_c/llm.chat/v1/history |
{"id": "...", "limit": 0, "before": ""} |
chat:read |
| Update |
/api/_c/llm.chat/v1/update |
{"id": "...", "title": "...", "meta": {}} |
chat |
| List |
/api/_c/llm.chat/v1/list |
{"meta": {"user": "..."}, "limit": 50, "offset": 0} |
chat:read |
| Forget |
/api/_c/llm.chat/v1/forget |
{"id": "..."} |
chat |
| Forget by meta |
/api/_c/llm.chat/v1/forget-where |
{"meta": {"user": "..."}} |
chat |
send needs model and answers {"answer": <llm.text/v1's result>, "summarized": bool}; it also takes reasoning,
schema, maxTokens and temperature. A chat is {id, title, summary, meta, messages, created, updated}. meta
filters match each top-level key exactly (strings, numbers, true/false, null). context is sent after the question;
history shows the question alone, and later turns send it with its context again, so each prompt starts exactly like
the last one did (which the providers' prompt caches reward). Errors: not_found (404) for an unknown chat, and
llm.text/v1's.
Provide
Implement chatv1.Chats and provide it in Register. Keep chats in the app's own database (each instance of a host
has its own) and call llm.text/v1 for answers and summaries.
Commands and APIs
Every operation is a REST endpoint, a pocketone command and an MCP tool, all generated from the contract and behind the same token scope check and hooks. See Remote CLI, or the full CLI, Extension APIs and MCP references.
new
Starts a chat and returns it; its id is how the app finds it again.
|
|
| REST |
POST /api/_c/llm.chat/v1/new |
| CLI |
pocketone remote llm chat new --title <value> --meta <json> |
| MCP |
llm_chat_new |
| Token scope |
chat |
| Input field |
Flag |
Type |
title |
--title |
string |
meta |
--meta |
json |
send
Asks the chat a question: the provider sends the system text, the chat's summary, its recent messages and the question (with Context after it) to llm.text/v1, saves both turns, and folds older messages into the summary when it's due.
|
|
| REST |
POST /api/_c/llm.chat/v1/send |
| CLI |
pocketone remote llm chat send --id <value> --text <value> --system <value> --window <n> --summarizeevery <n> --context <value> --schema <json> --maxtokens <n> --temperature <json> --model <value> --reasoning <value> --enrich <json> |
| MCP |
llm_chat_send |
| Token scope |
chat |
| Input field |
Flag |
Type |
id |
--id |
string |
text |
--text |
string |
system |
--system |
string |
window |
--window |
int |
summarizeEvery |
--summarizeevery |
int |
context |
--context |
string |
schema |
--schema |
json |
maxTokens |
--maxtokens |
int |
temperature |
--temperature |
json |
model |
--model |
string |
reasoning |
--reasoning |
string |
enrich |
--enrich |
json |
send_stream
Is Send with the answer as it's written: llm.text/v1 chunks, the last one with done and the result.
|
|
| REST |
POST /api/_c/llm.chat/v1/send-stream |
| CLI |
pocketone remote llm chat send-stream --id <value> --text <value> --system <value> --window <n> --summarizeevery <n> --context <value> --schema <json> --maxtokens <n> --temperature <json> --model <value> --reasoning <value> --enrich <json> |
| MCP |
llm_chat_send_stream |
| Token scope |
chat |
| Answer |
a stream of JSON entries (server-sent events); the command prints one line each |
| Input field |
Flag |
Type |
id |
--id |
string |
text |
--text |
string |
system |
--system |
string |
window |
--window |
int |
summarizeEvery |
--summarizeevery |
int |
context |
--context |
string |
schema |
--schema |
json |
maxTokens |
--maxtokens |
int |
temperature |
--temperature |
json |
model |
--model |
string |
reasoning |
--reasoning |
string |
enrich |
--enrich |
json |
get
Returns a chat.
|
|
| REST |
POST /api/_c/llm.chat/v1/get |
| CLI |
pocketone remote llm chat get --id <value> |
| MCP |
llm_chat_get |
| Token scope |
chat:read |
| Input field |
Flag |
Type |
id |
--id |
string |
history
Returns a chat's messages, oldest first: the last Limit before the message Before (all when 0 and "").
|
|
| REST |
POST /api/_c/llm.chat/v1/history |
| CLI |
pocketone remote llm chat history --id <value> --limit <n> --before <value> |
| MCP |
llm_chat_history |
| Token scope |
chat:read |
| Input field |
Flag |
Type |
id |
--id |
string |
limit |
--limit |
int |
before |
--before |
string |
update
Sets a chat's title or meta (fields left out stay).
|
|
| REST |
POST /api/_c/llm.chat/v1/update |
| CLI |
pocketone remote llm chat update --id <value> --title <json> --meta <json> |
| MCP |
llm_chat_update |
| Token scope |
chat |
| Input field |
Flag |
Type |
id |
--id |
string |
title |
--title |
json |
meta |
--meta |
json |
list
Returns chats, most recently updated first; Meta keeps those whose meta has each of its top-level keys with that value.
|
|
| REST |
POST /api/_c/llm.chat/v1/list |
| CLI |
pocketone remote llm chat list --meta <json> --limit <n> --offset <n> |
| MCP |
llm_chat_list |
| Token scope |
chat:read |
| Input field |
Flag |
Type |
meta |
--meta |
json |
limit |
--limit |
int |
offset |
--offset |
int |
forget
Deletes a chat, its messages and the model's state for it.
|
|
| REST |
POST /api/_c/llm.chat/v1/forget |
| CLI |
pocketone remote llm chat forget --id <value> |
| MCP |
llm_chat_forget |
| Token scope |
chat |
| Input field |
Flag |
Type |
id |
--id |
string |
forget_where
Deletes every chat whose meta matches (as in List), e.g. all of a user the app deleted.
|
|
| REST |
POST /api/_c/llm.chat/v1/forget-where |
| CLI |
pocketone remote llm chat forget-where --meta <json> --limit <n> --offset <n> |
| MCP |
llm_chat_forget_where |
| Token scope |
chat |
| Input field |
Flag |
Type |
meta |
--meta |
json |
limit |
--limit |
int |
offset |
--offset |
int |
Extensions
License
MIT
Questions and comments
Comments are a GitHub Discussions thread; sign in with GitHub to post.