
Muse Wonder 1.0: Build a Cited Research Agent in Python
Summary
Meta's new Muse Wonder API: web-search citations, a cost meter and an audit pass.
Meta shipped Muse Wonder on October 12, and for the first time its top model is something you can call from the same OpenAI-style client you already use. The API model is muse-wonder-1.0, with a 1M-token context window, $4 per million input tokens, $20 per million output tokens and built-in web search at $2.50 per 1,000 queries. The bigger sibling, Muse Wonder Full, is not in the API at all. It only exists inside Muse Code subscriptions.
That pricing split is the interesting part for builders. Wonder costs roughly three times what Muse Spark 1.3 does ($1.25 in, $4.25 out), so you do not want to point every request at it. A research agent is a good fit for the expensive model: few calls, lots of reasoning, and the output is only useful if you can trust it. So this guide builds exactly that, a research agent that answers with numbered citations, plus a second pass that re-reads every cited page and grades each claim.
You will end up with two small Python files, a cost meter that matches Meta's price list, and a list of the traps I hit reading the docs. One honest caveat up front: I do not have a Meta API key in the environment I wrote this in. I ran both files against a local mock server that speaks the Responses API shape from Meta's docs, so the parsing, footnote and tool-loop logic is verified, but the sample output below comes from that mock and your live answers will read differently.
What you need first
- Python 3.10+ and
pip install openai requests(I used openai 3.29.0 for the mock run; any recent SDK withclient.responses.createworks) - A Model API key from dev.meta.ai, exported as
MODEL_API_KEY. The OpenAI SDK will not pick this variable up on its own, so the code passes it explicitly - Standard mode. The docs list
muse-wonder-1.0as Standard only, so there is no-contributordiscount variant like Spark has - About $1 of credit. A full research plus audit run on a medium question should cost cents, and the meter in step 4 will tell you exactly how many
Step 1: Point the OpenAI client at Meta
Meta's API is OpenAI-compatible, so setup is a base URL and a key. The base URL is https://api.meta.ai/v1. Everything below uses the Responses API, because that is where search grounding lives. Chat Completions has no web search tool at all.
I made the base URL and model ID environment variables. That is not decoration: Meta's own cookbook examples still say muse-spark-1.3, and being able to flip one variable to compare Wonder against Spark on the same question is how you decide whether the extra money is worth it.
Step 2: One grounded call, parsed properly
Add tools=[{"type": "web_search"}] and the model decides whether to search, runs the search on Meta's side, and returns citations as annotations on the answer text. search_context_size takes low, medium or high and trades latency and tokens for more sources. Reasoning depth is a separate dial: on the Responses API it is the nested reasoning.effort.
The output is a list of items, not a single string. You can get reasoning items, one web_search_call per search, and a final message. Meta's docs say to filter by item.type and never rely on position, and they are right to, because a question the model answers from memory produces no search item at all.
Here is the whole of agent.py. The sections below walk through the parts that are easy to get wrong.
import json, os, sys
from openai import OpenAI
BASE_URL = os.environ.get("META_BASE_URL", "https://api.meta.ai/v1")
MODEL = os.environ.get("META_MODEL", "muse-wonder-1.0")
client = OpenAI(base_url=BASE_URL, api_key=os.environ["MODEL_API_KEY"])
# Standard-mode list prices, USD per 1M tokens (launch post, Oct 12 2026)
PRICE_IN, PRICE_CACHED, PRICE_OUT, PRICE_SEARCH = 4.00, 0.20, 20.00, 2.50 / 1000
def research(question: str, effort: str = "medium", context: str = "medium"):
"""One grounded call. Returns (response, answer_text, sources)."""
resp = client.responses.create(
model=MODEL,
input=question,
reasoning={"effort": effort},
tools=[{"type": "web_search", "search_context_size": context}],
)
text_parts, anns = [], []
for item in resp.output:
if item.type != "message":
continue
for block in item.content:
if block.type != "output_text":
continue
text_parts.append(block.text)
for a in (block.annotations or []):
if a.type == "url_citation":
anns.append((len("".join(text_parts[:-1])), a))
return resp, "".join(text_parts), anns
def footnote(text: str, anns):
"""Insert [n] markers. Offsets are per text block, so we shift by block start
and walk from the highest end_index down so earlier offsets stay valid."""
order, numbered = {}, []
for base, a in anns:
if a.url not in order:
order[a.url] = len(order) + 1
numbered.append((order[a.url], a.title, a.url))
out = text
for base, a in sorted(anns, key=lambda x: x[0] + x[1].end_index, reverse=True):
pos = base + a.end_index
out = out[:pos] + f"[{order[a.url]}]" + out[pos:]
return out, numbered
def cost(resp) -> float:
u = resp.usage
cached = getattr(getattr(u, "input_tokens_details", None), "cached_tokens", 0) or 0
fresh = u.input_tokens - cached
searches = sum(1 for i in resp.output if i.type == "web_search_call")
return (fresh * PRICE_IN + cached * PRICE_CACHED + u.output_tokens * PRICE_OUT) / 1e6 + searches * PRICE_SEARCH
if __name__ == "__main__":
q = sys.argv[1]
resp, text, anns = research(q)
body, sources = footnote(text, anns)
print(body, "\n")
for n, title, url in sources:
print(f"[{n}] {title} - {url}")
rt = getattr(getattr(resp.usage, "output_tokens_details", None), "reasoning_tokens", 0)
print(f"\nreasoning_tokens={rt} cost=${cost(resp):.4f}")
Step 3: Footnotes without corrupting the text
Each url_citation annotation has start_index and end_index as character offsets into that content block's text. If you insert [1] at the first citation, every later offset is now off by three characters. The fix is to walk the annotations from the highest end_index downward so earlier positions stay valid, which is what footnote() does.
Two more details in there. The numbering is assigned in reading order and de-duplicated by URL, so a source cited three times is still [2] everywhere. And the base offset handles the case where the answer is split across several output_text blocks, since indices restart at zero in each one.
Run it on a question:
export MODEL_API_KEY=...
python agent.py "How much does Muse Wonder cost and what is its context window?"
With the mock server standing in, the output looks like this. Treat it as the shape of the result, not as Meta's wording:
Muse Wonder costs $4 per million input tokens.[1] It has a 1M token window.[2]
[1] Muse Wonder - https://dev.meta.ai/models/muse-wonder
[2] VentureBeat - https://venturebeat.com/x
reasoning_tokens=500 cost=$0.0287
A message with no url_citation annotations is a valid answer. It means the model chose not to search. For a research agent that is a signal worth acting on, so add a guard that retries once with a prompt telling it to search, rather than shipping an uncited answer.
Step 4: A cost meter that matches the price list
The cost() function in the file above does the arithmetic from the response's own usage block: fresh input at $4, cached input at $0.20, output at $20 (reasoning tokens are already included in output tokens), plus $2.50 per thousand searches counted from the web_search_call items. On my mock run, 3,000 input tokens with 1,000 cached, 900 output tokens and one search came to $0.0287. Check it by hand: 2,000 x $4 + 1,000 x $0.20 + 900 x $20 is $26,200 per million, so $0.0262, plus $0.0025 for the search.
The thing to watch is output. At $20 per million, a high effort run that burns 20,000 reasoning tokens costs 40 cents before a single word of answer. That is why the default in research() is medium, and why you should log reasoning tokens (usage.output_tokens_details.reasoning_tokens) on every call for the first week.
Step 5: The audit pass with a function tool
Citations prove the model looked at something. They do not prove the page says what the answer claims. So the second file hands the finished answer and its source list to a fresh request and gives it one function tool, fetch_page(url), with instructions to grade each claim SUPPORTED, PARTIAL or UNSUPPORTED.
I kept this as a separate request on purpose. Meta's docs describe built-in tools and function tools separately and say nothing about mixing web_search with your own functions in one call, so I did not assume it works. Two phases also give you a cheap place to swap models: research on Wonder, audit on a cheaper Spark if the grades hold up.
import json, os
import requests
from agent import client, MODEL
TOOLS = [{
"type": "function",
"name": "fetch_page",
"description": "Download a web page and return its visible text (first 6000 chars).",
"parameters": {
"type": "object",
"properties": {"url": {"type": "string"}},
"required": ["url"],
},
}]
def fetch_page(url: str) -> str:
r = requests.get(url, timeout=15, headers={"User-Agent": "audit-agent/1.0"})
r.raise_for_status()
return r.text[:6000]
def audit(answer: str, sources, max_turns: int = 6) -> str:
listing = "\n".join(f"[{n}] {t} - {u}" for n, t, u in sources)
prompt = (
"Audit this answer. For each numbered claim, fetch the cited page and say "
"SUPPORTED, PARTIAL or UNSUPPORTED with one sentence of evidence.\n\n"
f"ANSWER:\n{answer}\n\nSOURCES:\n{listing}"
)
resp = client.responses.create(
model=MODEL, input=prompt, tools=TOOLS, reasoning={"effort": "low"},
)
for _ in range(max_turns):
calls = [i for i in resp.output if i.type == "function_call"]
if not calls:
return resp.output_text
results = []
for c in calls: # parallel_tool_calls defaults to true: answer EVERY call
try:
out = fetch_page(**json.loads(c.arguments))
except Exception as e: # return errors as data, not exceptions
out = f"ERROR: {e}"
results.append({"type": "function_call_output", "call_id": c.call_id, "output": out})
resp = client.responses.create(
model=MODEL, previous_response_id=resp.id, input=results, tools=TOOLS,
)
return "Stopped: max_turns reached"
The tool rules on the Responses API are specific. A function tool has name, description and a JSON Schema parameters object at the top level of the tool, not nested under a function key (that nesting is Chat Completions). You return results as function_call_output items carrying the matching call_id, along with previous_response_id. Skip that ID and you must rebuild the whole history yourself.
The model can emit several calls in one turn because parallel_tool_calls defaults to true. The loop answers every call it finds, not just the first. If you leave one unanswered, the next request has a dangling call ID and you will get an error instead of a result. Failures from fetch_page go back as an ERROR: string so the model can mark that claim unverifiable instead of the whole run crashing.
Worked example: checking a launch-day claim
Here is the full flow on a question where the sources disagree on detail, which is the case this pattern exists for. Launch-day coverage of a model often mixes the vendor's numbers with third-party ones.
from agent import research, footnote, cost
from audit import audit
q = "What are the rate limits and data-handling terms for Muse Wonder in the API?"
resp, text, anns = research(q, effort="medium")
body, sources = footnote(text, anns)
print(body)
print(audit(body, sources))
print(f"research cost: ${cost(resp):.4f}")
What you should expect from a live run, based on what the sources say today: VentureBeat reports limits of 3,000 requests and 4 million tokens per minute and says API usage is Standard mode, meaning your content is not used for training. Meta's pricing page lists exactly those limits for the Standard tier, but at the time I read it the page did not yet mention muse-wonder-1.0 by name. A good audit pass will mark the Wonder-specific limit as PARTIAL, because the vendor page supports the tier but not the model. That is the right grade, and it is the kind of nuance a plain citation hides.
The audit output in my mock run was a single line, [1] SUPPORTED: page says Muse Wonder $4 input. A real run gives you one line per footnote. Parse the leading label if you want to fail a CI job on any UNSUPPORTED claim.
Gotchas I would rather you not rediscover
- Search grounding is Responses-only. Send
tools=[{"type":"web_search"}]to Chat Completions and you will not get citations. Usereasoning={"effort": ...}there too, because the Chat Completions spelling is the top-levelreasoning_effort. - tool_choice only accepts auto.
none,requiredand named functions return HTTP 400. You cannot force the model to search or force a function call, so every code path must handle both a tool call and plain text. - Effort
noneis a 400 on the Muse family, and settingmaxonmuse-wonder-1.0does not upgrade you to Wonder Full. Valid values for Wonder run fromminimaltomax. - Zero data retention drops built-in search. VentureBeat reports that qualified customers can request ZDR, but that configuration does not support server-side conversation state, background requests, file uploads or built-in web search. If your compliance team insists on ZDR, this agent's research phase does not run as written.
- The docs lag the launch. The pricing page I read still listed only Spark rows, and the cookbook samples use
muse-spark-1.3. Take Wonder's $4/$20 from the launch post and model page, and re-check before you budget. - Wonder is labelled preview on the models page. Pin the exact ID, log it with every answer, and expect behaviour to shift.
- Reasoning does not carry over on Chat Completions. The
reasoning_contentfield comes back redacted, so each turn thinks from scratch. On Responses, chain turns withprevious_response_id, or go stateless by requestingreasoning.encrypted_contentinincludeand passing the reasoning item back. - Annotations can be None. The code uses
block.annotations or []. Drop that and the first uncited answer raises a TypeError. - Call IDs are 1 to 64 characters and function names may contain at most one dot, so skip clever namespacing like
search.web.fetch.
Using the Anthropic SDK instead
If your codebase already speaks Anthropic's Messages format, Meta exposes that too, at base URL https://api.meta.ai (no /v1), path /v1/messages, bearer auth. In the Python SDK that means Anthropic(base_url="https://api.meta.ai", auth_token=os.environ["MODEL_API_KEY"]). It is stateless, max_tokens is required, effort goes in output_config.effort (low to xhigh), and thinking: {type: "disabled"} is rejected. web_search works there but without allowed_domains, blocked_domains or max_uses. Meta's example uses muse-spark-1.3, so confirm Wonder is accepted on that route before relying on it.
Quick reference
| Thing | Value |
|---|---|
| Base URL (OpenAI style) | https://api.meta.ai/v1 |
| Base URL (Anthropic style) | https://api.meta.ai, POST /v1/messages |
| Auth | Bearer token from MODEL_API_KEY |
| Model ID | muse-wonder-1.0 (Standard mode, preview) |
| Context window | 1,048,576 tokens |
| Price per 1M tokens | $4.00 input, $0.20 cached, $20.00 output |
| Web search | $2.50 per 1,000 queries, Responses API only |
| Rate limit (Standard) | 3,000 requests/min, 4M tokens/min per team |
| Reasoning effort (Responses) | reasoning.effort: minimal, low, medium, high, xhigh, max |
| Reasoning effort (Chat) | reasoning_effort, same values; none returns 400 |
| tool_choice | auto only |
| Reasoning summary | reasoning.summary: auto, concise, detailed (may be empty) |
| Not in the API | Muse Wonder Full (Muse Code Power $50/mo, Maximum $200/mo) |
Where to go next
- Run the same ten questions on
muse-wonder-1.0andmuse-spark-1.3by flippingMETA_MODEL, then compare audit grades and cost per supported claim. That number, not a benchmark table, tells you whether Wonder earns its price - Turn on
reasoning.summaryand log it next to each answer so you can see why the model searched or skipped searching - Add the retry guard for answers with zero citations, and fail the job when the audit returns any UNSUPPORTED line
- Move the audit pass to
previous_response_idchaining plusinclude: ["reasoning.encrypted_content"]if you want the auditor to keep its reasoning across turns - Read the Meta cookbook recipes for search grounding, tool calling and reasoning tokens in the meta-models GitHub repo, then verify every parameter against the live API reference, since the Wonder docs were still catching up on launch week
Sources: Meta developer docs (dev.meta.ai/models/muse-wonder, /docs/models, /docs/reasoning, /docs/tool-calling, /docs/pricing-rate-limits, /docs/protocols/messages, the search-grounding cookbook recipe) and VentureBeat's October 12 launch coverage of Muse Wonder and Muse Wonder Full.
Comments
Be the first to comment
Found this useful?
Get new AI guides for builders by email. Free.
Join 3,617 newsletter subscribers.