Four worked examples
Examples
Complete, runnable requests for the four most common integration shapes.
01 — Summarize a document set
The bread-and-butter call: attach the documents context, constrain the output, keep the step ceiling low.
[ typescript ]ts
import { Mynd } from "@mynd/sdk";
const mynd = new Mynd(); // reads MYND_API_KEY
const run = await mynd.runs.create({
model: "y0-fast",
prompt: "Brief me on every contract expiring this quarter.",
context: ["documents"],
max_steps: 3,
});
console.log(run.result.summary);02 — Structured extraction with a schema
Define the shape you want and the run is graded against it — invalid JSON is retried inside the run, not returned to you.
[ typescript ]ts
const run = await mynd.runs.create({
model: "y0-text-fast",
prompt: "Extract vendor, amount, and due date from the attached invoice.",
files: ["file_8c21aa04"],
output_schema: {
type: "object",
properties: {
vendor: { type: "string" },
amount: { type: "number" },
due_date: { type: "string", format: "date" },
},
required: ["vendor", "amount", "due_date"],
},
});03 — An agent with an approval gate
The agent can draft and read freely, but the consequential step — sending email — halts for human sign-off.
[ typescript ]ts
const run = await mynd.runs.create({
model: "y0-agent",
prompt: "Chase the three unpaid invoices over 30 days.",
tools: ["email.send", "finance.read"],
approval: { required_for: ["email.send"] },
max_steps: 8,
});
if (run.status === "awaiting_approval") {
// surface run.pending_actions to a human, then:
await mynd.runs.approve(run.id, { action_ids: ["act_01"] });
}04 — Polling a deep run
y0-deep runs return status "running". Poll with exponential backoff or register a webhook for run.completed.
[ typescript ]ts
let run = await mynd.runs.create({
model: "y0-deep",
prompt: "Plan the Q3 contractor budget against these invoices.",
context: ["finance", "documents"],
max_steps: 12,
});
while (run.status === "running") {
await new Promise((r) => setTimeout(r, 2000));
run = await mynd.runs.get(run.id);
}
console.log(run.trace);