llm.align/v1
A model says when each line and each word of a known text is said in its audio. Nothing is transcribed or guessed:
every word that comes back is one you sent, in order. For captions timed to a narration, karaoke-style highlighting,
or finding a phrase in a recording. 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, the
errors) are in pocketone.dev/ext/contracts/llm.
A wire contract at /api/_c/llm.align/v1 (align.go), one provider. The
llm extension provides it, over Vultr (aligner-1).
Use
In page code it's $llm.align (bound by the llm extension):
const r = await $llm.align.alignAsync({
model: "vultr/aligner-1",
audio: speech.file, // { name: "story.mp3", data }
text: "Once upon a time...\nEvery night...",
mode: "speech",
})
r.lines // [{ index, text, start, end, score, certain }], seconds from the start
r.words // [{ line, text, start, end, score }]
Over HTTP (a superuser, or a token with the scope shown):
| Operation | HTTP | Body | Token scope |
|---|---|---|---|
| Align | POST /api/_c/llm.align/v1/align |
{"model": "...", "audio": {"name": "story.mp3", "data": "<base64>"}, "text": "...", "mode": "speech"} |
llm |
| Models | GET /api/_c/llm.align/v1/models |
?provider= (optional) |
llm:read |
It answers {"duration", "lines", "words", "unaligned", "model", "usage"}. text has one line per line of the audio;
a line in square brackets ([Chorus]) labels the lines under it and isn't timed. mode is speech for a voice
recording, or lyrics (the provider's default) to separate a sung vocal from the music first. Lines the model couldn't
place are listed in unaligned, not dropped. Vultr takes up to 25 MiB, 15 minutes and 12,000 characters per call.
Errors: bad_request (no audio or text, an unknown mode), not_configured (no providers), unknown_model,
not_supported, provider (the cloud's own error), timeout.
From Go: alignv1.Contract.Must(app) (from pocketone.dev/ext/contracts/llm/align/v1).
Provide
Implement alignv1.Align and provide it in Register (alignv1.Contract.Provide(app, impl)). Route on the
provider/ prefix, answer not_supported for a provider that can't align, unknown_model for a missing model or
provider, and provider with the cloud's own message (never its key) when the cloud refuses. Return only words of the
text sent, in order. 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.
align
Says when each line and word of the text is said in the audio.
| REST | POST /api/_c/llm.align/v1/align |
| CLI | pocketone remote llm align --model <value> --audio <json> --text <value> --mode <value> --language <value> --options <json> |
| MCP | llm_align_align |
| Token scope | llm |
| Input field | Flag | Type |
|---|---|---|
model |
--model |
string |
audio |
--audio |
json |
text |
--text |
string |
mode |
--mode |
string |
language |
--language |
string |
options |
--options |
json |
models
Lists the alignment models of every provider in Settings → LLM.
| REST | GET /api/_c/llm.align/v1/models |
| CLI | pocketone remote llm align models --provider <value> |
| MCP | llm_align_models |
| Token scope | llm:read |
| Input field | Flag | Type |
|---|---|---|
provider |
--provider |
string |
Extensions
| Extension | |
|---|---|
| llm | provides |
License
MIT
Questions and comments
Comments are a GitHub Discussions thread; sign in with GitHub to post.