API / run-multi-agent-research

API

Run multi-agent research on grok-4.20-multi-agent

Run multi-agent research on grok-4.20-multi-agent

Set model to grok-4.20-multi-agent. The server launches a team of agents that search, analyze, and synthesize in parallel; a leader agent returns the final answer. The feature is in beta. The API interface may change.

xAI SDK uses agent_count (4 or 16). OpenAI SDK, REST, and Vercel AI SDK map the same two setups through reasoning.effort: "low" / "medium" → 4 agents, "high" / "xhigh" → 16 agents. Built-in tools (web_search, x_search, code_execution, collections_search) run server-side when you enable them. Built-in tool calls bill extra.

Only the leader's tool calls and final response come back by default. Sub-agent reasoning, tool calls, and outputs stay encrypted unless you set use_encrypted_content=True on the xAI SDK.

xAI SDK

import os

from xai_sdk import Client
from xai_sdk.chat import user
from xai_sdk.tools import web_search, x_search

client = Client(api_key=os.getenv("XAI_API_KEY"))
chat = client.chat.create(
    model="grok-4.20-multi-agent",
    tools=[web_search(), x_search()],
    include=["verbose_streaming"],
)

chat.append(user("Research the latest breakthroughs in quantum computing and summarize the key findings."))

is_thinking = True
for response, chunk in chat.stream():
    if response.usage.reasoning_tokens and is_thinking:
        print(f"\rThinking... ({response.usage.reasoning_tokens} tokens)", end="", flush=True)
    if chunk.content and is_thinking:
        print("\n\nFinal Response:")
        is_thinking = False
    if chunk.content and not is_thinking:
        print(chunk.content, end="", flush=True)

print("\n\nUsage:")
print(response.usage)

4 agents (xAI SDK)

import os

from xai_sdk import Client
from xai_sdk.chat import user

client = Client(api_key=os.getenv("XAI_API_KEY"))
chat = client.chat.create(
    model="grok-4.20-multi-agent",
    agent_count=4,
)

chat.append(user("What are the key differences between TCP and UDP?"))
for response, chunk in chat.stream():
    if chunk.content:
        print(chunk.content, end="", flush=True)

OpenAI SDK (Responses)

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("XAI_API_KEY"),
    base_url="https://api.x.ai/v1",
)

response = client.responses.create(
    model="grok-4.20-multi-agent",
    reasoning={"effort": "low"},
    input=[
        {
            "role": "user",
            "content": "What are the key differences between TCP and UDP?",
        },
    ],
)

print(response.output_text)

curl

curl https://api.x.ai/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $XAI_API_KEY" \
  -d '{
  "model": "grok-4.20-multi-agent",
  "reasoning": {"effort": "low"},
  "input": [
    {
      "role": "user",
      "content": "What are the key differences between TCP and UDP?"
    }
  ]
}'

Vercel AI SDK

import { xai } from "@ai-sdk/xai";
import { generateText } from "ai";

const { text } = await generateText({
  model: xai.responses("grok-4.20-multi-agent"),
  prompt: "What are the key differences between TCP and UDP?",
  providerOptions: {
    xai: { reasoningEffort: "low" },
  },
});

console.log(text);

Pass agent_count=16 (xAI SDK) or reasoning.effort "high" / "xhigh" (REST / OpenAI / Vercel) for the 16-agent setup. Docs recommend 4 agents for focused queries and 16 for multi-faceted research. 16 agents use significantly more tokens.

Follow-ups use previous_response_id the same way as other Responses models. Watch usage and server_side_tool_usage: every leader and sub-agent token, plus every server-side tool call, is billed.

Pitfalls

  • Beta. Expect breaking API changes.
  • Chat Completions is unsupported. Use the xAI SDK or Responses (POST /v1/responses).
  • Client-side function calling and custom tools are unsupported. Built-in tools and remote MCP are supported.
  • max_tokens is unsupported on this model.
  • Default responses hide sub-agent state. Set use_encrypted_content=True when you need that context for multi-turn work.
  • Console API credits are separate from SuperGrok's weekly pool on grok.com.