Meta Model API cookbook

Ship on Muse Spark with recipes that run the first time you copy them. Each recipe solves one focused problem, shows working code, and points to what's next. Start with API fundamentals to nail the primitives, then layer on agent loops and full use cases.

API fundamentals

Validate one building block at a time and walk away with a starter you can extend.

Quickstart: chat completions Point the OpenAI SDK at a new base URL and make your first Muse Spark call.
Streaming responses Stream tokens as they generate and read usage in the final chunk.
Tool and function calling Detect a tool call, execute it, and feed the result back into the loop.
Structured output Return JSON that matches your schema and parses on the first try.
Prompt caching Reuse a stable prompt prefix and measure cached tokens.
Reasoning and thinking tokens Set reasoning effort and replay reasoning across turns.
Vision input Send images by URL or base64 and get structured analysis back.
Long context Pack repo-scale context into a single context window.
Error handling and retry Back off with jitter and skip retries on client errors.
Search grounding Ground answers in live web search with inline citations.

Agent patterns

Turn a model into an agent. These loops handle planning, self-correction, and staying coherent across long runs.

Basic agent loop Wire up the core perceive-decide-act loop.
Interleaved reasoning and tool use Interleave reasoning with tool calls in a single turn.
Multi-turn context management Keep context under control across a long agent run.
Search-and-replace edits Make exact-match file edits that stay reviewable.
Alert fatigue copilot Pull grounded patterns from noisy alerts, then probe, chat, and self-assess with strict JSON.

Use cases

Build end-to-end: multimodal perception, orchestration, and complete apps you can adapt.

Chart analysis Read charts and extract structured data from images.
Error screenshot fix Diagnose a bug from a screenshot and ship the fix.
Smart glasses with OpenClaw Look, ask out loud, and hear the answer — hands-free on Ray-Ban Meta glasses.
Generating slides Generate a slide deck from a prompt or source content.
Browser-verified web design Build a website with a coding agent that checks its own work in a real browser.
Iterative game dev Build a browser game end-to-end with a coding agent, verified in a real browser.
Sandboxed execution Execute model-generated code in a sandbox.
Multi-agent orchestration Orchestrate a team of specialists that coordinate through a shared Kanban board.
One-shot game dev Build a complete 3D browser game in one pass — one structured prompt, no iteration loop.
Perception grounding Pin interactive dots at object pixel locations and generate a self-contained HTML overlay.
GitHub agent Run an autonomous GitHub Actions bot for triage, PR review, and bug-fix PRs on OpenCode and Muse Spark.
Computer use Control a desktop from screenshots with a computer-use agent.
Computer use on macOS Drive a real Mac from screenshots with native mouse and keyboard events.

Building with Muse Code

Build durable, auditable agents with Muse Code — the harness building blocks for safety, recovery, and orchestration.

Audit and resume agent sessions Replay any session exactly as it ran from an append-only event log, show who authorized each action, then kill the run mid-task and resume with no duplicate side effects.
Deterministic replay in CI Turn recorded events into a golden fixture and replay its model-context projection as a merge-blocking CI check.
Staged approvals Split a compound shell command into stages so safe ones auto-resolve while risky ones hold for review.
Contained execution Run every command in an OS sandbox that refuses to proceed unless containment is proven live.
Immutable guardrails The agent can't rewrite its own rules: guardrail edits stop for review and a shell write to the same path fails read-only at the sandbox.
Subagent fanout Fan one job out to parallel subagents, each in its own isolated git worktree.
Goal tracking Pin an objective once and the harness audits the work against acceptance checks before the goal can close.
Bundled skills Drive the built-in /plan, /grilling, /grill-with-docs, and /taste skills to plan, pressure-test, and build.
Loop and cron Schedule recurring or one-time agent work in natural language, then view, change, or cancel it from the same chat.
Side chats Branch off the main thread for a side conversation that never enters the main history.

Muse Image

Use Muse Image to generate, edit, or combine images. Choose a recipe based on whether you need web grounding, consistency across a series, or multi-turn editing.

Generate, edit, and compose images Generate an image, refine it across turns, or combine it with new reference images.
Ground image generation with web search Use web references when an image should reflect current products, places, or styles. Verify factual details independently.
Keep an image series consistent Use reference images to improve character, style, and setting consistency across a series. Compare each output with the references.
Edit image details across turns Edit one part of a photo, then refine the result across turns. Check that unchanged areas still match the source.

Muse Voice Transcribe

Use Muse Voice Transcribe to turn speech into text — streaming over a WebSocket while the speaker is still talking, or in one HTTP request for a recording you already have. The model handles punctuation, speech-boundary detection, and speaker attribution itself.

Speech to text Transcribe a recording or a live microphone over the streaming WebSocket, get speaker-attributed turns with diarization, or post a whole recording in one HTTP request.
Control Apple Chess with voice Turn exact spoken chess moves into locally validated Apple Chess actions with a passive HUD, calibrated grid, dry-run mode, and fail-closed native input.