llm.embed/v1

A model turns texts into vectors, one per text, for search by meaning. 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.embed/v1 (embed.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.embed (bound by the llm extension):

const r = await $llm.embed.embedAsync({ model: "cf/@cf/baai/bge-base-en-v1.5", input: ["bedtime story", "lighthouse"] })
r.vectors[0]

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

Operation HTTP Body Token scope
Embed POST /api/_c/llm.embed/v1/embed {"model": "...", "input": ["..."], "dimensions": 0} llm
Models GET /api/_c/llm.embed/v1/models ?provider= (optional) llm:read

It answers {"vectors": [[...]], "model", "usage"}, in the inputs' order.

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

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

Provide

Implement embedv1.Embed and provide it in Register (embedv1.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.

embed

Returns one vector per input text, in order.

REST POST /api/_c/llm.embed/v1/embed
CLI pocketone remote llm embed --model <value> --input <a,b> --dimensions <n> --options <json>
MCP llm_embed_embed
Token scope llm
Input field Flag Type
model --model string
input --input strings
dimensions --dimensions int
options --options json

models

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

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

Extensions

Extension
llm provides
llm-search works with

License

MIT