When your app needs a model to produce something inside its own code, like a note written halfway through a
research run or a score for a lead, call matter.models.complete. It runs one model turn on this
computer, as the member, on the account they’re signed in with. Pass a prompt and get back text, or pass a
JSON Schema and get back an object that matches it.
Your app never names a model. It names one of its model slots,
such as 'writing', and the call runs on the model the member chose for that slot. If you don’t
name a slot, the call runs on the member’s default model.
const { text } = await matter.models.complete({
slot: 'writing',
system: 'You write short, factual research notes.',
prompt: `Summarize what we know about ${company.title}:\n\n${findings}`,
})const { output } = await matter.models.complete<{ fit: number; reason: string }>({
slot: 'research',
thinking: 'low',
prompt: `How well does ${company.title} fit our ideal customer? ${profile}`,
schema: {
type: 'object',
properties: {
fit: { type: 'number', description: 'From 0 to 10' },
reason: { type: 'string' },
},
required: ['fit', 'reason'],
additionalProperties: false,
},
})
await matter.table('Leads').update(lead.id, { fit: output.fit, fitReason: output.reason })Options#
| Option | Description |
|---|---|
prompt (required) |
What you’re asking the model. |
system |
A system prompt to use instead of the default, a short instruction to answer directly. |
slot |
One of the model slots your matter.json declares in models. If you leave it
out, Matter uses the member’s default model.
|
thinking |
The model’s thinking effort, such as 'low' or 'high', instead of the effort
that comes with the slot’s model or the default. Matter uses the nearest effort the model supports.
|
schema |
A JSON Schema with an object at the top. When you pass one, the result has output, the
parsed object, and no text.
|
timeoutMs |
How long the call may take, including time spent waiting behind your app’s other calls. The default is 120 000 and the most is 600 000. |
Without a schema, the call resolves to { text, backend, model }. With one, it
resolves to { output, backend, model }.
How it runs#
- Just the model: The turn has no tools, MCP servers, browser or file access. Put everything the model needs in the prompt.
- No thread: Nothing shows up in the member’s thread list, and nothing is kept after the call. To let the member see and continue the conversation, start a thread instead.
- From anywhere in your app: It works from pages, the worker and tools. Each call runs on the computer it’s made on, using the member’s accounts there.
-
The slot’s models, in order: The call tries the member’s choice for the slot, then the
slot’s suggestions, then the member’s default, and uses the first one that can run on this computer. If
none of them can, the call fails with
model_unavailable. Matter never uses a model outside that list. - Antigravity: Antigravity’s agent always keeps its own tools, so it can’t answer model calls. A call skips it and tries the next model.
Limits and errors#
-
Size:
promptandsystemtogether can be at most 200 KB. Larger calls fail withtoo_large. -
Calls at once: Each app runs up to 3 calls at a time on a computer. Additional calls wait
their turn, and the wait counts toward
timeoutMs.
| Code | When |
|---|---|
model_unavailable |
None of the slot’s models, nor the default, can run on this computer. |
no_default_model |
The slot has no models (the member hasn’t chosen one and the app suggests none), or you didn’t name a slot, and the member hasn’t chosen a default. |
timeout |
The call took longer than timeoutMs. |
too_large |
The prompt and system prompt together are over 200 KB. |
invalid |
An option has the wrong type, the slot isn’t one the app declares, the call names a model or speed, or the schema doesn’t have an object at the top. |
failed |
The model returned an error, or its reply didn’t match the schema. |
import matter, { MatterError } from '@matter.work/app-sdk'
try {
const { text } = await matter.models.complete({ slot: 'writing', prompt })
} catch (error) {
if (error instanceof MatterError && error.code === 'model_unavailable') {
await matter.notify({ title: 'Choose a writing model to keep drafting', path: '/settings' })
} else throw error
}
Codex checks a schema strictly: every property must be listed in required, and every object
needs additionalProperties: false. If you write schemas that way, they work on both backends.