AI Models
The guide's map is at The guide. This page covers how an app calls an AI model: the rows that ask, the rows written back, and what calls cost.
An app needs no API key in its code and no server of its own to use a model. It writes a row that asks; the app's store calls the model and writes the answer back as rows. A connected model uses the app's integration, and its key stays in the space's vault. A page subscribed to the transcript receives the answer when it is written.
Models and media by task
An agent connected to yaks.app can write and read an app's model requests and replies using graph_apply and graph_query scoped to that app. The same app permissions and space allowance apply whether the write comes from the agent, a page, or a worker.
| Task | App or agent entry point |
|---|---|
| Ask a text model | Write a transcript entry, or make a synchronous call. |
| Read a scan or photo | Send an uploaded image to a vision model. Document Processing Workflows turns its answer into app rows for review. |
| Search by meaning | Use .near with an entity's embedding to find similar rows, or document search with query text. For raw embedding vectors, use a synchronous call. |
| Transcribe a recording or microphone | ElevenLabs or Deepgram through ./api/speech/hear for recordings or ./api/speech/listen for microphones, using the space budget. |
| Generate spoken audio | ElevenLabs through ./api/speech/speak or the Operator’s speech_new. Uses the space budget or the connected account when selected. |
| Generate an image | GPT Image writes an attachment the app can display. |
| Upload a file | upload or POST ./api/blob. An agent with a local file can use a space grant. |
| Use an outside service | Connections and egress let pages, workers and agent scripts call a connected service. |
| Run a workflow | Workflow rules and recorded calls run in the store. The person's own agent can also answer a builder step using its own tools and subscription. |
Transcripts, entries and turns
A transcript is any entity with a session component. Each line of it is an entry. An entry that names a model with using asks for a turn, and sending on the same entry sets what the model is sent:
import { apply, subscribe } from './api/client.js'
let smith = crypto.randomUUID()
await apply([
{ entity: { eid: smith }, doc: { title: 'The smith' }, session: {} },
{
entity: { eid: '$said' },
entry: { session: smith },
content: { body: 'A stranger walks up to the forge.' },
using: { provider: 'workers-ai', model: '@cf/deepseek-ai/deepseek-v4.1-flash-1017' },
sending: {
instructions: 'You are the village smith: gruff, kind, brief.',
},
},
])using selects the model and holds only provider, model and effort. using.model is any model name its selected provider serves. Name the provider explicitly: workers-ai for platform models, openrouter for the app's connected OpenRouter account, or openai for OpenAI. Without using.provider, the store uses the model's sole known provider; an untried @cf/ model or typesafe/jev resolves to workers-ai. An unknown or ambiguous selection receives a refusal entry and the transcript becomes failed.
sending holds what the model is sent, and sending.instructions is what a conversational model is told before the transcript. The store refuses instructions or window written inside using, as it refuses any property the vocabulary does not declare.
using and sending stay in force for the rest of the transcript: each turn uses the newest using and the newest sending that any entry carries. After the first entry with using, every new entry with content asks for another turn with the model and instructions in force, so a later entry carries using or sending only to change them.
Three more properties limit what a turn costs. sending.window is how many of the transcript's newest lines the model reads, extended back to the line that began the turn the window would otherwise cut into; without it every turn reads the whole transcript, so each new line makes a long conversation more expensive. using.effort sets how much reasoning the model does before it answers: DeepSeek V4.1 Flash accepts none, low, high or max, and every reasoning token is billed as output. sending.tokens is the most a reply may write, reasoning included; a platform model writes at most 4,096 tokens without it, which a long answer (a builder's over many rows) needs more than.
using: {
provider: 'workers-ai',
model: '@cf/deepseek-ai/deepseek-v4.1-flash-1017',
effort: 'low',
},
sending: {
instructions: 'You are the village smith: gruff, kind, brief.',
window: 16,
},The store writes its response as more entries in the same transcript:
- an
ask— the moment the model was asked, with what the call used (usage) - the reply —
content { body }withoutput { source }naming the ask
A page receives the reply through a subscription, like any other change:
subscribe(`.entry.session=${smith}&?content&?refusal`, (rows) => {
for (let row of rows) {
if (row.content) console.log(row.content.body)
}
})No polling is needed: the write that asks returns at once, and the reply arrives through the subscription shortly after. Each turn sends the model the transcript's lines: the entries written to it, the model's replies, and any command calls and their results, but not the ask entries, errors, or typed questions and answers. It sends all of them, or only the newest lines sending.window counts. session.status gives the transcript's state: pending while a turn is owed, settled once the model has answered, failed when it could not be asked.
Typed questions and structured answers
Free text is for people to read. For a decision a page acts on, ask Jev (typesafe/jev) a question with a typed answer by putting questions beside the entry:
await apply({
entity: { eid: '$next' },
entry: { session: smith },
content: { body: 'Evening falls. The stranger has gone.' },
using: { provider: 'workers-ai', model: 'typesafe/jev' },
questions: {
asked: {
plan: {
type: 'choice',
instructions: 'Where does the smith go next?',
criteria: { forge: 'back to work', well: 'to rest by the well' },
},
},
},
})Each question's answer comes back as an entry of its own with an answer component, named by the question:
answer { question: 'plan', choice: 'forge', confidence: 0.82,
probabilities: { forge: 0.82, well: 0.18 } }A choice picks one of its criteria's names. A noul answers a yes-or-no as the probability that it holds (answer.noul). A score places the answer along ordered criteria (answer.score). The page reads the newest one with .entry.session=<smith>&.answer.question=plan&.order=-entry.seq&.limit=1.
A model that does not answer typed questions refuses them rather than guessing; only Jev answers them. The answers are for the page only: no later turn reads them, or the questions another turn asked, so a transcript that a page asks questions about every few minutes keeps its window for the conversation itself.
Image generation
An app can make an image with one of OpenAI's GPT Image models, paid from the space's budget like any platform model: gpt-image-2.6-sunburst for detailed work, gpt-image-2.6-flare for fast iteration, and their 2.5 releases gpt-image-2.5-sunburst and gpt-image-2.5-flare. The entry's text is the prompt. sending.input may set size (auto or WIDTHxHEIGHT, both edges multiples of 16), quality (auto, low, medium, high, xhigh, max), background, output_format (png, jpeg or webp), output_compression, moderation and complexity; anything else is refused.
await apply({
entity: { eid: '$picture' },
entry: { session: easel },
content: { body: 'A yak in gouache on a cream background' },
using: { provider: 'openai', model: 'gpt-image-2.6-flare' },
sending: { input: { size: '1024x1024', quality: 'low' } },
})The reply is an entry with attachment.artifact pointing to an artifact row, as with audio, and the page shows it from ./api/blob/<artifact-id>. A prompt OpenAI declines receives a refusal entry.
For reference-based generation or editing, use the same image attachments as a vision transcript. GPT Image accepts up to 16 PNG, JPEG or WebP references, at most 14 MiB each and 20 MiB together through the app transcript. Generated output attachments remain for display until explicitly attached to a later request with audience: 'model'.
Reference requests reserve a finite cost estimate from the same space budget. The provider's measured text, image input and output usage settles once, even if it exceeds the estimate; later calls use the updated balance.
Audio generation with a connected model
An app can ask bytedance-seed/seed-audio-1-0 for an audio clip. Its owner first calls store_connection_need for the app with integration: 'openrouter' and signs in on the space's connections page. The app never receives the OpenRouter key. The entry's text is the sound prompt; this model does not use sending.instructions or typed questions.
await apply({
entity: { eid: '$sound' },
entry: { session: smith },
content: { body: 'A forge hammer ringing on an anvil' },
using: {
provider: 'openrouter',
model: 'bytedance-seed/seed-audio-1-0',
},
})The reply is an entry with attachment.artifact pointing to an artifact row. That row carries the media type and size. A page can play the bytes at ./api/blob/<artifact-id>; the platform keeps them in the app's blob store. If the app has no OpenRouter connection, the transcript receives a refusal with code: 'connection'.
Builders: model output for each stored row
A builder selects rows from this app's store with a query. Its content.body is the $var template; doc.body documents the builder. builder.to names a registered tool. The built-in model tool opens a session in the same store, and its answer becomes built rows:
import { modelToolEid } from '@yaks/builders/model'
await apply({
entity: { eid: '$summaries' },
doc: { title: 'Summaries' },
content: { body: 'Summarize $body.' },
using: { model: '<model-eid>' },
builder: {
query: '$note .note, doc.body=$body',
to: modelToolEid(),
},
})Each outer query match gets a durable build and a fresh tool call when its key changes. The model returns named slots with components and the selected input ids each used. Each call keeps its own take in a slot; its citations are cites edges. Query .build.builder=<builder-id>&*, then .built.build=<build-id>&* to find the outputs; what was built for one row now is .built.build.build.for=<row-id>&.built.current=true&*. When a row stops matching, its build becomes stale, and the build and its outputs are kept as history. Changing builder.floor to a time in the past checks every match again. A wake can check it later, and builder.immediate: true also checks changed inputs. Only app editors may write a builder, since model turns spend the space's budget.
builder.to may instead name one of the app's own worker commands, so each matched row runs the app's code and the worker answers the outputs: see Backend Code, handling each text, email or webhook with the app's own code.
A builder written with staged: {} builds nothing by itself, so a new prompt can be tried on a few rows first. store_builder_build builds it now: only names the rows to build for, limit takes the first few, and a template, provider or model tried in place of its own builds a shadow variant that nothing else selects. Remove the mark (staged: null) to build the rest; a row already built with the same prompt is not asked again.
Synchronous calls with ./api/ai/run
A page that needs the answer in the response to its own request, rather than in a transcript, POSTs the model's name and its input to ./api/ai/run:
let res = await fetch('./api/ai/run', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({
model: '@cf/baai/bge-base-en-v1.5',
input: { text: ['a stranger at the forge'] },
}),
})
let { data } = await res.json()input is what Workers AI takes for that model (its page at https://developers.cloudflare.com/workers-ai/models/), and the response is the model's output. These chat models are answered by OpenAI's model of matching ability, at its price:
| model | answered by | per million tokens in | out |
|---|---|---|---|
@cf/zai-org/glm-5.3-flash | gpt-6-luna | $0.125 | $0.50 |
@cf/meta/llama-4-scout-17b-16e-instruct | gpt-6-luna | $0.125 | $0.50 |
@cf/google/gemma-4-26b-a4b-it | gpt-6-luna | $0.125 | $0.50 |
@cf/openai/gpt-oss-120b | gpt-6-luna | $0.125 | $0.50 |
@cf/zai-org/glm-5.3 | gpt-6.1-terra | $1.25 | $5 |
Their answer is OpenAI's chat completion, with the text also in response and any tool calls also in a flat tool_calls, so code that reads either keeps working. max_tokens is the most the answer may use, and the model does no reasoning first unless reasoning_effort asks for some; temperature and the other sampling settings are not used. Every other model, the embedding models among them, is Workers AI's. Nothing is stored; use a transcript to keep what was said. An app's worker calls a model the same way through a binding: "ai": { "binding": "AI" } in its wrangler.jsonc gives it env.AI.run(model, input) (see Backend Code), which calls the model as the app itself.
For Workers AI text-to-speech models such as @cf/deepgram/aura-2-en, send input: { text, speaker }. The HTTP response contains audio bytes and env.AI.run returns its readable stream. The space pays the published rate per input character. Workers AI pricing
To keep calls from the same conversation on the same cache-capable model worker, add a stable session_id beside model and input, or send the x-session-affinity header (the header takes precedence). An app's worker can use env.AI.run(model, input, {extraHeaders: {'x-session-affinity': session}}). Existing calls with only model and input keep working. Affinity is a routing hint: it does not guarantee a cache hit, and not every model supports it. Transcripts send their session id automatically; keep instructions and tools stable where their meaning has not changed.
The same people who may ask for a turn (see Who may call a model, below) may call it, and it spends the same space budget. A refusal uses the error format every endpoint uses, {error: {code, message}}: 400 for a model not offered here or an input the model refuses, 429 past the budget, with a message that says so, and 503 while the model is busy. Show the person error.message.
Speech with ./api/speech
ElevenLabs speaks text and transcribes recordings by default. A page or worker POSTs text to ./api/speech/speak and gets an MP3 back, or POSTs a recording to ./api/speech/hear and gets its words:
let spoken = await fetch('./api/speech/speak', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ text: 'Your table is booked for Friday.' }),
})
new Audio(URL.createObjectURL(await spoken.blob())).play()
let heard = await fetch('./api/speech/hear', {
method: 'POST',
headers: { 'content-type': recording.type },
body: recording,
})
let { text, turns, seconds } = await heard.json()text is up to 2,000 characters. voice defaults to ElevenLabs’ George and can also name a Deepgram Aura-2 voice (https://developers.deepgram.com/docs/tts-models), or one of OpenAI's (cedar, marin, alloy, ash, ballad, coral, echo, sage, shimmer, verse, fable, nova or onyx), spoken at $0.015 per thousand characters. A recording posted is up to 25 MB in any audio type a browser's MediaRecorder makes; a longer one is kept at ./api/blob and heard from there (below). turns are what each speaker said, {speaker, text, from, to}, with from and to its seconds in the recording and speaker numbering the voices from 0. The same people who may call a model may use speech, and it spends the same space budget. The ElevenLabs rates are $0.08 per thousand characters spoken and $0.20 per hour transcribed. A refusal is {error: {code, message}}: 402 past the budget, 413 a recording too large, 503 while speech is paused.
ElevenLabs voices: "provider": "elevenlabs"
ElevenLabs’ premade voices use the platform connection by default. To use voices in an account you connect, request provider: "elevenlabs" and the voice ID. Requests through that connection are billed to the connected account. Connect it at the space’s connections page in either of these ways:
- Its key, pasted as the space's connection, which the app uses.
- A sign-in to the person's own account, through ElevenLabs' MCP server (
https://api.elevenlabs.io/v1/mcp). An app speaks with it when the person connected it in the app's space for everyone there, or granted it to the app. The account's own voices, cloned, designed or added from ElevenLabs' library, are listed beside the premade ones, and the server's other tools reach the person's Operator.
An app lists the voices it may speak in, and speaks a line in one:
let voices = await (await fetch('./api/speech/voices?provider=elevenlabs')).json()
// {provider: 'elevenlabs', voices: [{id, name, about, sample}]}
let line = await fetch('./api/speech/speak', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({
provider: 'elevenlabs',
voice: voices.voices[0].id,
text: 'Ahoy! The tide waits for no one.',
}),
})
// Keep the voiced line as a file of the app's: POST it to ./api/blob.
let kept = await fetch('./api/blob', {
method: 'POST',
headers: { 'content-type': 'audio/mpeg' },
body: await line.blob(),
})A voice is designed from words saying how it sounds, each design a sample to audition, and the one picked is kept:
let { designs } = await (await fetch('./api/speech/design', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ description: 'an old sea captain, gravelly and warm' }),
})).json()
// designs: [{id, audio (base64 MP3), type, seconds}]
let { voice } = await (await fetch('./api/speech/voice', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ design: designs[0].id, name: 'Captain', description: 'gravelly, warm' }),
})).json()./api/speech/voice also clones a voice from recordings posted as a form: name, an optional description, and the recordings as files. Clone only a voice the person has the right to. ElevenLabs allows cloning on some plans and says so when the account's plan doesn't. Designing, keeping and cloning need the app's own ElevenLabs, a key or a sign-in, and are refused with 403 (speech_own) without one. ElevenLabs' own refusal of a request is 400 (speech_refused) with its reason. Recordings name the provider too: ./api/speech/hear?provider=elevenlabs hears with Scribe and tells the speakers apart.
The space's Operator speaks through the same connection: it lists the voices, voices a line as a file in the space's files (speech_new), designs voices and adds them to the account.
Hearing a long recording: {"blob"}
A recording the app keeps at ./api/blob is heard whole, up to the provider’s file limit. A two-hour meeting costs about $0.40 against the space budget through ElevenLabs. The page uploads it (upload on Files and Uploads, in parts and resumed for a large file), then POSTs its url as blob:
import { query, subscribe, upload } from './api/client.js'
let file = await upload(input.files[0])
let asked = await fetch('./api/speech/hear', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ blob: file.url }),
})
let { recording } = await asked.json()recording is the upload's own row, the one file.attachment names. Hearing outlasts the request: the door answers 202 at once, and the app's store hears the file and writes what it heard as rows, which a page subscribed to them receives:
heard_turn{recording, speaker, text, from, to}, one row a turn.heard{seconds, turns, speakers}on the recording once every turn is written: its length, how many turns, and whether they tell speakers apart.failed{reason}on the recording if it could not be heard, the budget spent meanwhile, say.
subscribe(`id=${recording}&?heard&?failed`, async ([r]) => {
if (r?.failed) return show(r.failed.reason)
if (!r?.heard) return show('Listening…')
let turns = (await query(`.heard_turn.recording=${recording}`))
.map((t) => t.heard_turn).toSorted((a, b) => a.from - b.from)
said(turns) // the app's own: written as its rows, say
})Asking again for a recording already heard answers 200 with its heard and charges nothing; one being heard answers 202 again; one that failed is heard again. The space pays for the minutes once the recording is transcribed through the platform connection. The endpoint returns 413 past the provider’s file limit, 404 for a missing file, and 402 if the budget cannot cover it. The rows read as the upload does, so whoever may read the file may read what it said, and deleting the upload deletes them.
Hearing as it is spoken: ./api/speech/listen
A page hears a microphone live through a WebSocket at ./api/speech/listen: it sends raw audio as binary messages and is told each turn as it ends, one speaker's words up to a pause or another voice. Deepgram's Nova-3 hears it and tells the speakers apart, at $0.0097 per minute heard, from the same space budget.
The query says what the audio is: encoding is linear16 (16-bit little-endian PCM, the default) or mulaw, rate its samples a second, 8000 to 48000 (16000 by default), one channel. at is the second of the recording the first audio sent starts at, 0 by default; every second the door tells is counted from the recording's start, so a stream opened again goes on counting.
The door sends JSON messages:
{"type": "ready", "at": 0, "speakers": true}: the stream is heard fromat.speakerssays whether its turns tell speakers apart. Audio sent before it waits and is heard.{"type": "turn", "speaker": 0, "text": "I move we adopt the budget.", "from": 12.5, "to": 15.1}: a turn that ended, with its seconds in the recording.speakernumbers the voices from 0 within one stream; a stream opened again numbers them afresh.{"type": "done", "at": 3612.4}: the page sent{"type": "end"}, every turn the audio held has been told, and the socket closes (code 1000).atis the second the recording reached.{"type": "error", "code": "limit", "message": "...", "at": 15.1}: the stream stopped, and the socket closes.limit(code 1008) is the space's budget spent;speech_failed(1011) is the provider lost;speech_offis speech paused here;bad_request(1008) is a query the door can't hear.
Ending a recording, or pausing it, is {"type": "end"}: the door tells what the audio still held, then done. Closing the socket instead drops what was not yet told.
Nothing is kept on the door's side, and a socket can drop at any time: a lost network, or a deploy. Nothing already heard is lost if the page keeps the audio since the last turn it was told: it opens the door again with at the to of that turn (or the at it last opened with) and sends its audio from that second on. at in an error says the same second. Audio after it is heard again, and charged again.
The microphone's samples come from an AudioWorklet, a file of the app's own (pcm.js) that hands on each tenth of a second as 16-bit PCM:
registerProcessor('pcm', class extends AudioWorkletProcessor {
held = []
process([input]) {
let samples = input[0]
if (samples) this.held.push(...samples)
if (this.held.length >= sampleRate / 10) {
let pcm = Int16Array.from(this.held, (x) =>
Math.max(-1, Math.min(1, x)) * 0x7fff)
this.held = []
this.port.postMessage(pcm.buffer, [pcm.buffer])
}
return true
}
})Request the microphone using the microphone and camera permissions flow. In the capture handler, mic is the granted MediaStream. The page streams it, keeps what was not yet told, and opens the door again where it stands:
let ctx = new AudioContext()
await ctx.audioWorklet.addModule('./pcm.js')
let node = new AudioWorkletNode(ctx, 'pcm')
// Connected on to the speakers, which it plays nothing to, so it runs.
ctx.createMediaStreamSource(mic).connect(node).connect(ctx.destination)
let rate = ctx.sampleRate, recorded = 0, kept = [], ws
let seconds = (chunk) => chunk.byteLength / 2 / rate
let listen = (at) => {
let url = new URL(`./api/speech/listen?rate=${rate}&at=${at}`, location.href)
url.protocol = url.protocol.replace('http', 'ws')
ws = new WebSocket(url)
ws.binaryType = 'arraybuffer'
ws.onopen = () => {
for (let c of kept) if (c.at >= at) ws.send(c.data)
}
ws.onmessage = ({ data }) => {
let m = JSON.parse(data)
if (m.type == 'turn') {
said(m) // the app's own: written as a row, say
kept = kept.filter((c) => c.at + seconds(c.data) > m.to)
}
// Only a lost stream is opened again.
if (m.type == 'done' || m.type == 'error' && m.code != 'speech_failed') {
ws.onclose = null
}
}
ws.onclose = () => setTimeout(() => listen(kept[0]?.at ?? recorded), 1000)
}
node.port.onmessage = ({ data }) => {
kept.push({ at: recorded, data })
recorded += seconds(data)
if (ws.readyState == 1) ws.send(data)
}
listen(0)The same people who may call a model may listen. One who may not is refused before the socket opens, with the HTTP refusal every endpoint uses.
Image input (vision models)
A transcript can send an image already in the app's store and retain the reply. Write an entry with attachment{blob, audience: 'model'} for each input image before the prompt entry in the same write. Set blob to the SHA-256 address returned as upload().eid. For an image generated by a model, set attachment.artifact to the reply's artifact address instead. Add a label in content.body. The model receives the images and their labels in entry order.
For example, in a new transcript, write the following entry with seq: 1 and the prompt entry with seq: 2 and using{provider, model} in the same batch:
{
entity: { eid: '$reference' },
entry: { session: transcript, seq: 1 },
attachment: { blob: uploaded.eid, audience: 'model' },
content: { body: 'Source scan' },
}The store reads the bytes from the app that owns the transcript. A missing, unsupported or oversized image writes a refusal entry before the provider call. Use PNG, JPEG or WebP and preserve enough resolution to read the print. To read a stored image into typed rows for review, see Document Processing Workflows.
Inline images in synchronous calls
For a synchronous call, send an image_url part whose URL is a data: URL containing the bytes. The example uses the vision-capable model at ./api/ai/run named @cf/meta/llama-4-scout-17b-16e-instruct.
Downscale the photo first, as for an upload (smaller() on Files and Uploads); 1024 pixels on its long side is enough for the model. Then send the same bytes to both endpoints in parallel: upload stores the image in the app, and the call asks the model about it.
import { apply, upload } from './api/client.js'
let dataUrl = (blob) => new Promise((ok, no) => {
let r = new FileReader()
r.onload = () => ok(r.result)
r.onerror = () => no(r.error)
r.readAsDataURL(blob)
})
let file = input.files[0]
let photo = await smaller(file, 1024)
let question = 'What is in this photo?'
let [kept, res] = await Promise.all([
upload(photo, { name: file.name }),
fetch('./api/ai/run', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({
model: '@cf/meta/llama-4-scout-17b-16e-instruct',
input: {
messages: [{ role: 'user', content: [
{ type: 'text', text: question },
{ type: 'image_url', image_url: { url: await dataUrl(photo) } },
] }],
max_tokens: 400,
},
}),
}),
])
let said = await res.json()
if (!res.ok) throw new Error(said.error.message)
await apply({ asked: { photo: kept.eid, question, answer: said.response } })The model's text answer is in response. The call stores nothing, so the last line stores the question and the answer with the image's eid, in asked, a component the app declares in its vocab.json the way photo is declared on the Files and Uploads page.
Send the image only as an image_url part. An image beside a prompt (the shape Llama 3.2 Vision takes) is ignored by this model, which then answers as if there were no image. Llama 3.2 Vision itself is not offered here: its license has not been accepted for the platform.
Commands a model may call
A model may call the app's own commands (see App Commands), but only the ones the app marks for it with "model": true. Those are the tools it is offered, and no others. A call runs as the person who asked for the turn, limited to exactly what they could write on the page themselves, and $session in its template is the transcript the turn is in, which no argument can change. What it writes is stamped created.via with that transcript, which a page's own write never is, so an app can check created.via on a row it should trust only when its model wrote it.
Who may call a model
A model's turn costs money, so by default only the space's members who may change the app can ask for one: an entry with using from anybody else is refused like any other write they may not make, and so is their call to ./api/ai/run. An app that wants its visitors to ask too says so at the top of its vocab.json:
{ "models": "open", "$defs": { … } }Then anyone who may write the app may ask, which on an open app is anyone with the link, and every turn they ask for spends the space's budget. Visitors together may spend 25% of the space's monthly budget; past that, the app tells them it answers visitors again on the 1st, while its members go on as before. The space's owner sets the share with space_set and visitors, a percent from 0 to 100. One visitor may ask for 50 model calls per day (UTC), so no one stranger spends the whole share; past it, the app tells them it answers them again tomorrow. The owner sets the number with space_set and visitor_calls.
Since every line after a using asks for a turn, a visitor to an open app writes entries only in transcripts they started; a line in a member's transcript is refused, whatever models says.
Models and pricing
These platform models spend the space's monthly yaks.app budget:
| model | for | per million tokens in | out |
|---|---|---|---|
@cf/deepseek-ai/deepseek-v4.1-flash-1017 | chat, and tools | $0.30 | $1.20 |
@cf/meta/llama-4-scout-17b-16e-instruct | pictures | $0.27 | $0.85 |
typesafe/jev | typed questions | $0.042 | free |
@cf/baai/bge-base-en-v1.5 | embeddings | $0.067 | — |
gpt-image-2.6-sunburst, -flare, and their 2.5 releases | images | $5 text, $8 image | $30 |
A GPT Image call holds twice what OpenAI's calculator says its image costs (the largest size and max quality when unset) and is charged what OpenAI reports it used: a 1024x1024 low image is about $0.025.
Every platform call is charged at its model's price against that budget, which belongs to the space the app is in. What one space spends never counts against another. The Operator and app voice calls spend it too. app_list shows what each space spent.
bytedance-seed/seed-audio-1-0 uses the app's connected OpenRouter account. OpenRouter bills that account for generated audio at its published rate; it does not spend the space's yaks.app budget.
A call that starts under the budget finishes even if it goes over. The next one is refused: the transcript gets a refusal { code: 'limit' } entry whose content.body says which limit it reached, and the transcript stays failed until a new entry asks again, on the 1st of the month or once the space's budget is raised. A refusal row is the platform's, so a listing leaves it out unless the filter names refusal or asks for transcript entry rows. Subscribe with &?refusal to show the message.
A model's rate limit is shared by every app on the platform. A turn that hits it is retried; after three failures in a row the transcript stays failed until a new entry asks.
Builder definition edits do not regenerate existing outputs. store_builder_build without redo flags builds only new bindings or changed inputs. outdated: true redoes selected bindings made under an older definition; rebuild: true redoes every selected binding, including unchanged ones. Both accept only and limit. Try an alternate template or model as a shadow first. .build.outdated=true finds older definitions; .built.current=true keeps selecting the chosen take until its binding disappears or another take is chosen. A successful redo adds takes, newest chosen by default; store_builder_choose chooses a retained earlier output without spending. List all takes with .built.build=<build>&*; .chosen shows the one in use.
