llm.text/v1

A language model answers a prompt or a conversation, whole or as it's written. With a JSON schema the answer's parsed value comes back as data. Every call names its model as provider/model: a provider the app's admins added in Settings → LLM, a slash, and that provider's own id for the model. Shared types (File, Usage, ModelInfo, Job, the errors) are in pocketone.dev/ext/contracts/llm.

A wire contract at /api/_c/llm.text/v1 (text.go), one provider. The llm extension provides it, over Vultr, Cloudflare Workers AI, OpenRouter and any OpenAI-compatible API.

Use

In page code it's $llm.text (bound by the llm extension):

const r = await $llm.text.completeAsync({ model: "vultr/glm-5.2", system: "Label the ticket.", prompt: body, reasoning: "off",
  schema: { type: "object", properties: { label: { enum: ["bug", "billing", "question"] } }, required: ["label"] } })
r.data.label
await $llm.text.streamAsync({ model: "vultr/glm-5.2", prompt: question }, (piece) => { /* show it */ })

Over HTTP (a superuser, or a token with the scope shown):

Operation HTTP Body Token scope
Complete POST /api/_c/llm.text/v1/complete {"model": "vultr/glm-5.2", "prompt": "...", "maxTokens": 200} llm
Stream POST /api/_c/llm.text/v1/stream as Complete; server-sent events llm
Count POST /api/_c/llm.text/v1/count {"text": "..."} or {"system": "...", "messages": [...]} llm:read
Models GET /api/_c/llm.text/v1/models ?provider=vultr (optional) llm:read

complete takes prompt or messages ([{"role": "user", "content": "..."}]), and optionally system, schema, maxTokens, temperature, stop, reasoning ("off", "low", "medium", "high"; thinking counts toward maxTokens) and options (the provider's own fields). It answers text, data, reasoning (the model's thinking, when the provider returns it), stopReason, model and usage. stream sends one event: stream per piece, {"text": "..."} (or {"reasoning": "..."}), then {"done": true, "result": {...}}. count estimates at about four characters a token.

Errors: not_configured (no providers), unknown_model, not_supported, provider (the cloud's own error), timeout.

From Go: textv1.Contract.Must(app) (from pocketone.dev/ext/contracts/llm/text/v1).

Provide

Implement textv1.Text and provide it in Register (textv1.Contract.Provide(app, impl)). Route on the provider/ prefix, answer not_supported for a provider that can't do this kind, unknown_model for a missing model or provider, and provider with the cloud's own message (never its key) when the cloud refuses. Fill model with the full provider/model that answered, and usage with what the provider reports.

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.

complete

Answers a prompt or a conversation.

REST POST /api/_c/llm.text/v1/complete
CLI pocketone remote llm text complete --model <value> --system <value> --prompt <value> --messages <json> --schema <json> --maxtokens <n> --temperature <json> --stop <a,b> --reasoning <value> --options <json> --enrich <json>
MCP llm_text_complete
Token scope llm
Input field Flag Type
model --model string
system --system string
prompt --prompt string
messages --messages json
schema --schema json
maxTokens --maxtokens int
temperature --temperature json
stop --stop strings
reasoning --reasoning string
options --options json
enrich --enrich json

stream

Answers like Complete, sending the answer as it's written: a chunk with text (or reasoning) for each piece, then one with done and the whole result.

REST POST /api/_c/llm.text/v1/stream
CLI pocketone remote llm text stream --model <value> --system <value> --prompt <value> --messages <json> --schema <json> --maxtokens <n> --temperature <json> --stop <a,b> --reasoning <value> --options <json> --enrich <json>
MCP llm_text_stream
Token scope llm
Answer a stream of JSON entries (server-sent events); the command prints one line each
Input field Flag Type
model --model string
system --system string
prompt --prompt string
messages --messages json
schema --schema json
maxTokens --maxtokens int
temperature --temperature json
stop --stop strings
reasoning --reasoning string
options --options json
enrich --enrich json

count

Says about how many tokens a text or a conversation is, for budgeting what to send.

REST POST /api/_c/llm.text/v1/count
CLI pocketone remote llm text count --model <value> --text <value> --system <value> --messages <json>
MCP llm_text_count
Token scope llm:read
Input field Flag Type
model --model string
text --text string
system --system string
messages --messages json

models

Lists the text models of every provider in Settings → LLM.

REST GET /api/_c/llm.text/v1/models
CLI pocketone remote llm text models --provider <value>
MCP llm_text_models
Token scope llm:read
Input field Flag Type
provider --provider string

Extensions

Extension
llm provides
llm-chat requires

License

MIT