SpyBara
Go Premium

Documentation 2026-07-12 00:02 UTC to 2026-07-14 21:01 UTC

5 files changed +25 −19. View all changes and history on the product overview
2026
Tue 14 21:01 Sun 12 00:02 Thu 9 13:03 Wed 8 18:58 Mon 6 22:58 Sat 4 20:00 Thu 2 16:59 Wed 1 19:00
Details

4 4 

5The Batch API lets you process large volumes of requests asynchronously with reduced pricing and higher rate limits. For pricing details, see [Batch API Pricing](/developers/pricing#batch-api-pricing). If you need lower latency on real-time requests instead, see [Priority Processing](/developers/advanced-api-usage/priority-processing).5The Batch API lets you process large volumes of requests asynchronously with reduced pricing and higher rate limits. For pricing details, see [Batch API Pricing](/developers/pricing#batch-api-pricing). If you need lower latency on real-time requests instead, see [Priority Processing](/developers/advanced-api-usage/priority-processing).

6 6 

7> [!WARNING]

8> Model support

9>

10> `grok-4.5` is not currently supported for Batch API requests and will be rejected.

11 

7## What is the Batch API?12## What is the Batch API?

8 13 

9When you make a standard API call to Grok, you send a request and wait for an immediate response. This approach is perfect for interactive applications like chatbots, real-time assistants, or any use case where users are waiting for a response.14When you make a standard API call to Grok, you send a request and wait for an immediate response. This approach is perfect for interactive applications like chatbots, real-time assistants, or any use case where users are waiting for a response.


111 116 

112# Chat completion with tools117# Chat completion with tools

113chat = client.chat.create(118chat = client.chat.create(

114 model="grok-4.5",119 model="grok-4.3",

115 batch_request_id="chat_001",120 batch_request_id="chat_001",

116 tools=[web_search(), x_search()],121 tools=[web_search(), x_search()],

117)122)


165 170 

166# Remote MCP171# Remote MCP

167mcp_chat = client.chat.create(172mcp_chat = client.chat.create(

168 model="grok-4.5",173 model="grok-4.3",

169 batch_request_id="mcp_001",174 batch_request_id="mcp_001",

170 tools=[mcp(server_url="https://mcp.deepwiki.com/mcp")],175 tools=[mcp(server_url="https://mcp.deepwiki.com/mcp")],

171)176)


191 {"role": "system", "content": "Classify the sentiment as positive, negative, or neutral."},196 {"role": "system", "content": "Classify the sentiment as positive, negative, or neutral."},

192 {"role": "user", "content": "The product exceeded my expectations!"}197 {"role": "user", "content": "The product exceeded my expectations!"}

193 ],198 ],

194 "model": "grok-4.5"199 "model": "grok-4.3"

195 }200 }

196 }201 }

197 },202 },


203 {"role": "system", "content": "Classify the sentiment as positive, negative, or neutral."},208 {"role": "system", "content": "Classify the sentiment as positive, negative, or neutral."},

204 {"role": "user", "content": "Shipping took way too long."}209 {"role": "user", "content": "Shipping took way too long."}

205 ],210 ],

206 "model": "grok-4.5"211 "model": "grok-4.3"

207 }212 }

208 }213 }

209 }214 }


219 batch_request_id: "chat_001",224 batch_request_id: "chat_001",

220 batch_request: {225 batch_request: {

221 responses: {226 responses: {

222 model: "grok-4.5",227 model: "grok-4.3",

223 tools: [{ type: "web_search" }, { type: "x_search" }],228 tools: [{ type: "web_search" }, { type: "x_search" }],

224 input: [229 input: [

225 { role: "system", content: "Analyze market sentiment from recent news and posts." },230 { role: "system", content: "Analyze market sentiment from recent news and posts." },


293 batch_request_id: "mcp_001",298 batch_request_id: "mcp_001",

294 batch_request: {299 batch_request: {

295 responses: {300 responses: {

296 model: "grok-4.5",301 model: "grok-4.3",

297 tools: [{ type: "mcp", server_label: "deepwiki", server_url: "https://mcp.deepwiki.com/mcp" }],302 tools: [{ type: "mcp", server_label: "deepwiki", server_url: "https://mcp.deepwiki.com/mcp" }],

298 input: [{ role: "user", content: "What does the xai-sdk-python repo do?" }],303 input: [{ role: "user", content: "What does the xai-sdk-python repo do?" }],

299 },304 },


710batch_requests = []715batch_requests = []

711for item in feedback_data:716for item in feedback_data:

712 chat = client.chat.create(717 chat = client.chat.create(

713 model="grok-4.5",718 model="grok-4.3",

714 batch_request_id=item["id"],719 batch_request_id=item["id"],

715 )720 )

716 chat.append(system(721 chat.append(system(


793 batch_request_id: item.id,798 batch_request_id: item.id,

794 batch_request: {799 batch_request: {

795 chat_get_completion: {800 chat_get_completion: {

796 model: "grok-4.5",801 model: "grok-4.3",

797 messages: [802 messages: [

798 {803 {

799 role: "system",804 role: "system",

Details

390 user(390 user(

391 "Based on the attached care guide, do you have any advice about the pictured cat?",391 "Based on the attached care guide, do you have any advice about the pictured cat?",

392 file(url="https://docs.x.ai/assets/api-examples/documents/cat-care.txt"),392 file(url="https://docs.x.ai/assets/api-examples/documents/cat-care.txt"),

393 image("https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg"),393 image("https://media.x.ai/v1/docs/example-cat-in-tree-8e9ac3e0.png"),

394 )394 )

395)395)

396 396 


421 { type: "input_file", file_url: "https://docs.x.ai/assets/api-examples/documents/cat-care.txt" },421 { type: "input_file", file_url: "https://docs.x.ai/assets/api-examples/documents/cat-care.txt" },

422 {422 {

423 type: "input_image",423 type: "input_image",

424 image_url: "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg",424 image_url: "https://media.x.ai/v1/docs/example-cat-in-tree-8e9ac3e0.png",

425 },425 },

426 ],426 ],

427 },427 },

rate-limits.md +2 −2

Details

37| grok-4.20-0309-reasoning | T0: 37, T1: 50, T2: 75, T3: 125, T4: 208 | T0: 10M, T1: 15M, T2: 25M, T3: 45M, T4: 85M |37| grok-4.20-0309-reasoning | T0: 37, T1: 50, T2: 75, T3: 125, T4: 208 | T0: 10M, T1: 15M, T2: 25M, T3: 45M, T4: 85M |

38| grok-4.20-0309-non-reasoning | T0: 37, T1: 50, T2: 75, T3: 125, T4: 208 | T0: 10M, T1: 15M, T2: 25M, T3: 45M, T4: 85M |38| grok-4.20-0309-non-reasoning | T0: 37, T1: 50, T2: 75, T3: 125, T4: 208 | T0: 10M, T1: 15M, T2: 25M, T3: 45M, T4: 85M |

39| grok-build-0.1 | T0: 37, T1: 50, T2: 75, T3: 125, T4: 208 | T0: 10M, T1: 15M, T2: 25M, T3: 45M, T4: 85M |39| grok-build-0.1 | T0: 37, T1: 50, T2: 75, T3: 125, T4: 208 | T0: 10M, T1: 15M, T2: 25M, T3: 45M, T4: 85M |

40| grok-4.5 | T0: 150, T1: 172, T2: 208, T3: 312, T4: 500 | T0: 50M, T1: 53M, T2: 60M, T3: 74M, T4: 100M |

41| grok-4.20-multi-agent-0309 | T0: 9, T1: 12, T2: 18, T3: 31, T4: 56 | T0: 2.5M, T1: 3.7M, T2: 6.2M, T3: 11M, T4: 21M |40| grok-4.20-multi-agent-0309 | T0: 9, T1: 12, T2: 18, T3: 31, T4: 56 | T0: 2.5M, T1: 3.7M, T2: 6.2M, T3: 11M, T4: 21M |

41| grok-4.5 | T0: 150, T1: 172, T2: 208, T3: 312, T4: 500 | T0: 50M, T1: 53M, T2: 60M, T3: 74M, T4: 100M |

42| grok-imagine-image-quality | 5 | — |42| grok-imagine-image-quality | 5 | — |

43| grok-imagine-image | 5 | — |43| grok-imagine-image | 5 | — |

44| grok-imagine-video-1.5 | 10 | — |

45| grok-imagine-video | 10 | — |44| grok-imagine-video | 10 | — |

45| grok-imagine-video-1.5 | 10 | — |

46 46 

47### What counts toward TPM47### What counts toward TPM

48 48 

Details

53 53 

54#### Enabled (default for Responses API; opt-in for xAI Python SDK)54#### Enabled (default for Responses API; opt-in for xAI Python SDK)

55 55 

56```bash customLanguage="bash" highlightedLines="9"56```bash customLanguage="bash" highlightedLines="10"

57# Inline citations are enabled by default for the Responses API

57curl https://api.x.ai/v1/responses \58curl https://api.x.ai/v1/responses \

58 -H "Content-Type: application/json" \59 -H "Content-Type: application/json" \

59 -H "Authorization: Bearer $XAI_API_KEY" \60 -H "Authorization: Bearer $XAI_API_KEY" \


62 "input": [63 "input": [

63 {"role": "user", "content": "What is xAI?"}64 {"role": "user", "content": "What is xAI?"}

64 ],65 ],

65 "tools": [{"type": "web_search"}] // inline citations are enabled by default66 "tools": [{"type": "web_search"}]

66}'67}'

67```68```

68 69 

Details

149 tools: {149 tools: {

150 getTemperature: tool({150 getTemperature: tool({

151 description: 'Get current temperature for a location',151 description: 'Get current temperature for a location',

152 parameters: z.object({152 inputSchema: z.object({

153 location: z.string().describe('City name'),153 location: z.string().describe('City name'),

154 unit: z.enum(['celsius', 'fahrenheit']).default('fahrenheit'),154 unit: z.enum(['celsius', 'fahrenheit']).default('fahrenheit'),

155 }),155 }),


451 tools: {451 tools: {

452 getCurrentTemperature: tool({452 getCurrentTemperature: tool({

453 description: 'Get current temperature for a location',453 description: 'Get current temperature for a location',

454 parameters: z.object({454 inputSchema: z.object({

455 location: z.string().describe('City and state, e.g. San Francisco, CA'),455 location: z.string().describe('City and state, e.g. San Francisco, CA'),

456 unit: z.enum(['celsius', 'fahrenheit']).default('fahrenheit'),456 unit: z.enum(['celsius', 'fahrenheit']).default('fahrenheit'),

457 }),457 }),


463 }),463 }),

464 getCurrentCeiling: tool({464 getCurrentCeiling: tool({

465 description: 'Get current cloud ceiling for a location',465 description: 'Get current cloud ceiling for a location',

466 parameters: z.object({466 inputSchema: z.object({

467 location: z.string().describe('City and state'),467 location: z.string().describe('City and state'),

468 }),468 }),

469 execute: async ({ location }) => ({469 execute: async ({ location }) => ({


484 process.stdout.write(chunk.text);484 process.stdout.write(chunk.text);

485 break;485 break;

486 case 'tool-call':486 case 'tool-call':

487 console.log(`Tool call: ${chunk.toolName}`, chunk.args);487 console.log(`Tool call: ${chunk.toolName}`, chunk.input);

488 break;488 break;

489 case 'tool-result':489 case 'tool-result':

490 console.log(`Tool result: ${chunk.toolName}`, chunk.result);490 console.log(`Tool result: ${chunk.toolName}`, chunk.output);

491 break;491 break;

492 }492 }

493}493}