meta-models/meta-model-cookbook
À propos
Developer recipes for Meta Model API — agentic workflows, multi-agent orchestration patterns, and use case examples with cost comparisons. Colab notebooks + standalone Python files.
Apprentissage et éducationProgression mesurée des étoiles
- in 24h
- 0
- in 7 days
- +4
- in 15 days
- +13
- in 1 month
- Historique en cours
Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.
README.md
OriginalMeta Model API cookbook
Recipes for building agents and coding tools on the Meta Model API, covering API fundamentals, agent patterns, and end-to-end use cases.
Meta Model API lets you build with Muse Spark using the tools you already run: it's drop-in compatible with the OpenAI SDK, the Anthropic SDK, and agent CLIs like OpenCode and Claude Code.
Point your client at
the Model API base URL, set your key, and keep the rest of your code. Each recipe is a
self-contained, copy-paste starting point that proves a capability and gives you something to build
on. The default model is Muse Spark (muse-spark-1.3), which has a 1,048,576-token context
window; the preview is free.
Getting started
You need a Model API account and an API key. Store the key as an environment variable so it stays out of your code:
export MODEL_API_KEY="LLM|{numeric_id}|{secret}"
pip install openai
import os
from openai import OpenAI
# The OpenAI SDK does not auto-read MODEL_API_KEY, so pass it explicitly.
client = OpenAI(
base_url="https://api.meta.ai/v1",
api_key=os.environ["MODEL_API_KEY"],
)
response = client.chat.completions.create(
model="muse-spark-1.3",
messages=[{"role": "user", "content": "Hello, world!"}],
)
print(response.choices[0].message.content)
Recipes
This cookbook mirrors the three sections of the Meta Model API cookbook website. Each recipe is a self-contained, copy-paste starting point. Start with API fundamentals to learn the API primitives, then move into agent patterns and end-to-end use cases.
1. API fundamentals
Prove each API primitive works and get a starting point you can build on.
| # | Recipe | What it does |
|---|---|---|
| 01 | Quickstart: chat completions | Make your first Muse Spark call by pointing the OpenAI SDK at one new base URL. |
| 02 | Streaming responses | Render tokens as they generate and read the final usage chunk. |
| 03 | Tool and function calling | Detect tool calls and run the execute-and-feed-back loop. |
| 04 | Structured output | Get schema-guaranteed JSON that parses on the first try. |
| 05 | Prompt caching | Reuse a stable prompt prefix and track cached tokens. |
| 06 | Reasoning and thinking tokens | Control reasoning effort and replay reasoning across turns. |
| 07 | Vision input | Send images by URL or base64 and get structured analysis back. |
| 08 | Long context | Pack repo-scale context into the context window. |
| 09 | Error handling and retry | Back off with jitter and skip retries on client errors. |
| 10 | Search grounding | Ground responses in live web search results with inline citations. |
2. Agent patterns
Build the loops that turn a model into an agent: planning, parallel work, and self-correction.
| # | Recipe | What it does |
|---|---|---|
| 01 | Basic agent loop | Wire up the core perceive-decide-act agent loop. |
| 02 | Interleaved reasoning and tool use | Interleave reasoning with tool calls in a single turn. |
| 03 | Multi-turn context management | Manage growing context across a long agent run. |
| 04 | Validated in-place edits | Validated search-and-replace edits with a coding agent. |
| 05 | Alert fatigue copilot | Extract grounded patterns from a noisy alert feed, then probe → chat → self-assess with strict-JSON output. |
3. Use cases
End-to-end patterns: multimodal perception, orchestration, and full applications.
| # | Recipe | What it does |
|---|---|---|
| 01 | Chart analysis | Read charts and extract structured data from images. |
| 02 | Error screenshot fix | Diagnose a bug from an error screenshot and fix it. |
| 03 | Smart glasses with OpenClaw | Hands-free look-and-ask on Ray-Ban Meta glasses. |
| 04 | Generating slides | Generate a slide deck from a prompt or source content. |
| 05 | Browser-verified web design | Build a website with a coding agent that checks its own work in a real browser. |
| 06 | Iterative game dev | Build a browser game end-to-end with a coding agent, verified in a real browser. |
| 07 | Sandboxed execution | Execute model-generated code in a sandbox. |
| 08 | Multi-agent product studio | Orchestrate a four-profile Hermes team (PM, backend, frontend, tech writer) that coordinates through a shared Kanban board. |
| 09 | One-shot game dev | Build a complete 3D browser game in a single pass — an AGENTS.md plus one structured prompt, no iteration loop. |
| 10 | Perception grounding | Identify food items in a fridge photo, pin interactive health-score dots at their pixel locations, and generate a self-contained HTML overlay. |
| 11 | GitHub repo agent | Autonomous GitHub Actions bot — triage, PR review, AI-slop detection, and bug-fix PRs — built on OpenCode + Muse Spark. |
| 12 | Computer use | Drive a Linux desktop from screenshots — the agent finds an app, opens it, and plays it, clicking through a Cua sandbox. |
| 13 | macOS computer use | Drive a real Mac from screenshots with metacua, a native computer-use agent (Swift + Python) that clicks, types, and works out a GUI app on its own. |
| 14 | Muse robotics | Orchestrate Muse Voice, Muse Spark, a full-mesh MuJoCo Panda, hosted SAM preview, Reachy Mini camera/audio/reactions, Muse Image, a kiosk, and file-first QR postcards. |
| 15 | Local agent that asks before calling Muse Spark | Run Muse Glimmer locally with Hermes and require approval before selected questions are sent to Muse Spark. |
4. Muse Code
Build agents with sessions you can audit, safety that fails closed, and an agent team you can steer — each recipe ends with a proof point you can replay.
| # | Recipe | What it does |
|---|---|---|
| 01 | Append-only audit log and crash-safe resume | Export the append-only session log and walk the exact sequence of actions and approvals as replayable evidence, then kill the harness mid-task and resume where it stopped with no duplicate side effects. |
| 02 | Deterministic Replay in CI | Turn recorded Muse Code events into a focused golden fixture and replay its model-context projection as a merge-blocking check. |
| 03 | Staged approvals for compound shell commands | Decompose a compound shell command into stages, auto-clear the safe ones, and hold the dangerous or unparseable ones for review — trust scoped per action and per workspace, failing closed. |
| 04 | Contained execution you can prove | Run shell commands inside an OS-level sandbox that live-probes its own enforcement and refuses to run when containment is not actually enforcing. |
| 05 | The agent can't rewrite its own rules | Ask the agent to edit the guardrail file it runs under; the write stops for human review with no standing grant on offer, and a shell write to the same path fails read-only at the sandbox. |
| 06 | Subagent fanout across isolated worktrees | Fan one job out to parallel subagents, each in its own git worktree, steered or stopped from a single command center. |
| 07 | Goal tracking with a judge | Declare a goal once; a judge decides whether the work is actually done and refuses to close the turn until every acceptance check passes. |
| 08 | Bundled skills: a paved road from idea to shipped | Drive the built-in /plan, /grilling, /grill-with-docs, and /taste skills end to end — plan a change, stress-test it, record the decisions, and build UI that does not look AI-made. |
| 09 | Loop and cron: scheduled agent work | Schedule recurring or one-time agent work in natural language, then view, change, or cancel it from the same chat surface. |
| 10 | Multi-turn side chats | Branch a multi-turn side conversation off a busy main thread with /side (or its alias /btw), isolated from the main transcript. |
| 11 | Muse Code for Security Research | Wire Burp Suite, Meta’s bug bounty research toolkit, headless Ghidra and LLDB into Muse Code over MCP, then point it at PortSwigger’s deliberately vulnerable demo site, a real bounty programme, and a real CVE buried in a stripped binary. |
5. Muse Image
Generate and edit images through the conversational Responses API, driving each task end to end in one chained conversation.
| # | Recipe | What it does |
|---|---|---|
| 01 | Generate, edit, and compose images | Drive Muse Image through the Responses API: generate an image from a prompt, refine it over chained turns, and attach reference images to steer or compose several into one scene. |
| 02 | Ground image generation in web search | Let the model search the live web mid-generation, so it renders from furniture actually sold today, then place a coordinated outdoor set into a photo of a real backyard. |
| 03 | Consistency across an image series | Anchor a whole series on a small reference set and carry it through the conversation, so the character, style, and setting stay on-model from one image to the next. |
| 04 | Editing with image understanding and reasoning | Edit a specific part of an image by describing it, letting the model reason over the frame and refine the same image across turns, changing what you ask for while preserving the rest. |
6. Muse Voice Transcribe
Turn speech into text as it is spoken. Muse Voice Transcribe is the one part of the Model API that is not an HTTP endpoint — real-time transcription needs a bidirectional connection, so these recipes use a WebSocket client rather than the OpenAI SDK.
| # | Recipe | What it does |
|---|---|---|
| 01 | 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. |
| 02 | Voice-controlled Apple Chess | 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. |
7. SAM 3
Turn segmentation masks and video tracks into finished applications.
| # | Recipe | What it does |
|---|---|---|
| 01 | SAM API basics | Segment images and videos in Python or TypeScript with the official meta-sam parsers. |
| 02 | Video to animated sticker pack | Track an animal through a video and export transparent, messaging-ready animated stickers. |
| 03 | Multi-speaker headlocked captions | Upload a conversation, map diarized voices to SAM-tracked people, and download the captioned video. |
8. Muse Ember
Pair Muse Ember with a larger model that plans, and let Muse Ember run the high-volume work: parallel subagents and batch jobs.
| # | Recipe | What it does |
|---|---|---|
| 01 | Port Python to Rust with Muse Wonder and Muse Ember | Muse Wonder plans and checks the work; Muse Ember workers port 16 Pygments lexers from Python to Rust in parallel. |
| 02 | Organizing images with subagents | One prompt in Muse Code: Muse Wonder writes the photo pipeline, and 16 Muse Ember subagents run it to caption, rename and sort a 10,000-photo camera roll. |
License
See LICENSE for details.
Explorer des projets similaires
Chargement…