SpyBara
Go Premium

Documentation 2026-07-02 16:59 UTC to 2026-07-04 20:00 UTC

7 files changed +51 −72. View all changes and history on the product overview
2026
Sat 4 20:00 Thu 2 16:59 Wed 1 19:00
Details

972 972 

973| Event | Description |973| Event | Description |

974|-------|-------------|974|-------|-------------|

975| `audio.delta` | A chunk of base64-encoded audio in the codec specified at connection time. Decode and enqueue for playback. When the connection was opened with `with_timestamps=true`, also carries `audio_timestamps` (`graph_chars` + `graph_times`) and `audio_duration` for the characters in that chunk. See [Streaming timestamps](#streaming-timestamps). |975| `audio.delta` | A chunk of base64-encoded audio in the codec specified at connection time. Decode and enqueue for playback. When the connection was opened with `with_timestamps=true`, also carries `audio_timestamps` (`graph_chars` + `graph_times`) and `audio_duration` for the characters in that chunk. See [Character-level timestamps](#character-level-timestamps). |

976| `audio.done` | All audio for the current utterance has been sent. Includes a `trace_id` for debugging. |976| `audio.done` | All audio for the current utterance has been sent. Includes a `trace_id` for debugging. |

977| `audio.clear` | Confirms that the current utterance was cancelled in response to `text.clear`. The connection is ready for the next utterance. |977| `audio.clear` | Confirms that the current utterance was cancelled in response to `text.clear`. The connection is ready for the next utterance. |

978| `error` | An error occurred. The `message` field contains a human-readable description. |978| `error` | An error occurred. The `message` field contains a human-readable description. |

Details

77 messages: [77 messages: [

78 {78 {

79 role: "system",79 role: "system",

80 content: "You are Grok, a chatbot inspired by the Hitchhiker's Guide to the Galaxy."80 content: "You are Grok, a helpful and maximally truthful AI built by xAI."

81 },81 },

82 {82 {

83 role: "user",83 role: "user",

84 content: "What is the meaning of life, the universe, and everything?"84 content: "Explain how neural networks learn in two sentences."

85 },85 },

86 ],86 ],

87});87});


96const result = await generateText({96const result = await generateText({

97 model: xai('grok-4.3'),97 model: xai('grok-4.3'),

98 system:98 system:

99 "You are Grok, a chatbot inspired by the Hitchhiker's Guide to the Galaxy.",99 "You are Grok, a helpful and maximally truthful AI built by xAI.",

100 prompt: 'What is the meaning of life, the universe, and everything?',100 prompt: 'Explain how neural networks learn in two sentences.',

101});101});

102 102 

103console.log(result.text);103console.log(result.text);


112 "messages": [112 "messages": [

113 {113 {

114 "role": "system",114 "role": "system",

115 "content": "You are Grok, a chatbot inspired by the Hitchhiker'\''s Guide to the Galaxy."115 "content": "You are Grok, a helpful and maximally truthful AI built by xAI."

116 },116 },

117 {117 {

118 "role": "user",118 "role": "user",

119 "content": "What is the meaning of life, the universe, and everything?"119 "content": "Explain how neural networks learn in two sentences."

120 }120 }

121 ],121 ],

122 "model": "grok-4.3",122 "model": "grok-4.3",


144```javascript customLanguage="javascriptOpenAISDK"144```javascript customLanguage="javascriptOpenAISDK"

145{145{

146 role: 'assistant',146 role: 'assistant',

147 content: `Ah, the ultimate question! According to Douglas Adams' "The Hitchhiker's Guide to the Galaxy," the answer to the ultimate question of life, the universe, and everything is **42**. However, the guide also notes that the actual question to which this is the answer is still unknown. Isn't that delightfully perplexing? Now, if you'll excuse me, I'll just go ponder the intricacies of existence.`147 content: `Neural networks learn by adjusting connection weights to minimize prediction error. Through backpropagation, they propagate gradients backward through layers so each weight updates in the direction that improves accuracy on training data.`

148 refusal: null148 refusal: null

149}149}

150```150```


152```javascript customLanguage="javascriptAISDK"152```javascript customLanguage="javascriptAISDK"

153// result object structure153// result object structure

154{154{

155 text: "Ah, the ultimate question! As someone...",155 text: "Neural networks learn by adjusting connection weights...",

156 finishReason: "stop",156 finishReason: "stop",

157 usage: {157 usage: {

158 inputTokens: 716,158 inputTokens: 716,


175 "index": 0,175 "index": 0,

176 "message": {176 "message": {

177 "role": "assistant",177 "role": "assistant",

178 "content": "The meaning of life, the universe, and everything is a question that has puzzled philosophers, scientists, and hitchhikers alike. According to the Hitchhiker's Guide to the Galaxy, the answer to this ultimate question is simply \"42\". However, the exact nature of the question itself remains unknown. So, while we may have the answer, the true meaning behind it is still up for debate. In the meantime, perhaps we should all just enjoy the journey and have a good laugh along the way!",178 "content": "Neural networks learn by adjusting connection weights to minimize prediction error. Through backpropagation, they propagate gradients backward through layers so each weight updates in the direction that improves accuracy on training data.",

179 "refusal": null179 "refusal": null

180 },180 },

181 "finish_reason": "stop"181 "finish_reason": "stop"

Details

544 544 

545* **Only leader agent output is exposed:** Only the leader agent's output is returned, including its tool calls and response content. Sub-agent state is encrypted and only included when `use_encrypted_content` is enabled — see [Output Behavior](#output-behavior) for details.545* **Only leader agent output is exposed:** Only the leader agent's output is returned, including its tool calls and response content. Sub-agent state is encrypted and only included when `use_encrypted_content` is enabled — see [Output Behavior](#output-behavior) for details.

546* **No client-side or custom tools:** Client-side tools (function calling) and custom tools are not currently supported by the multi-agent model variant. We do support a set of built-in tools (e.g., `web_search`, `x_search`) and remote MCP tools. See our [built-in tool docs](/developers/tools/overview) for more details.546* **No client-side or custom tools:** Client-side tools (function calling) and custom tools are not currently supported by the multi-agent model variant. We do support a set of built-in tools (e.g., `web_search`, `x_search`) and remote MCP tools. See our [built-in tool docs](/developers/tools/overview) for more details.

547* **Chat Completions API not supported:** The multi-agent model does **not** work with the OpenAI Chat Completions API. Use the [xAI SDK](/developers/sdk) or the [Responses API](/developers/responses-api) instead.547* **Chat Completions API not supported:** The multi-agent model does **not** work with the OpenAI Chat Completions API. Use the [xAI SDK](https://github.com/xai-org/xai-sdk-python) or the [Responses API](/developers/model-capabilities/text/generate-text) instead.

548* **`max_tokens` is not supported:** The `max_tokens` parameter is not currently supported by the multi-agent model variant.548* **`max_tokens` is not supported:** The `max_tokens` parameter is not currently supported by the multi-agent model variant.

Details

28 28 

29chat = client.chat.create(model="grok-4.3")29chat = client.chat.create(model="grok-4.3")

30chat.append(30chat.append(

31 system("You are Grok, a chatbot inspired by the Hitchhiker's Guide to the Galaxy."),31 system("You are Grok, a helpful and maximally truthful AI built by xAI."),

32)32)

33chat.append(33chat.append(

34 user("What is the meaning of life, the universe, and everything?")34 user("Explain how neural networks learn in two sentences.")

35)35)

36 36 

37for response, chunk in chat.stream():37for response, chunk in chat.stream():


55stream = client.chat.completions.create(55stream = client.chat.completions.create(

56 model="grok-4.3",56 model="grok-4.3",

57 messages=[57 messages=[

58 {"role": "system", "content": "You are Grok, a chatbot inspired by the Hitchhiker's Guide to the Galaxy."},58 {"role": "system", "content": "You are Grok, a helpful and maximally truthful AI built by xAI."},

59 {"role": "user", "content": "What is the meaning of life, the universe, and everything?"},59 {"role": "user", "content": "Explain how neural networks learn in two sentences."},

60 ],60 ],

61 stream=True # Set streaming here61 stream=True # Set streaming here

62)62)


76const stream = await openai.chat.completions.create({76const stream = await openai.chat.completions.create({

77 model: "grok-4.3",77 model: "grok-4.3",

78 messages: [78 messages: [

79 { role: "system", content: "You are Grok, a chatbot inspired by the Hitchhiker's Guide to the Galaxy." },79 { role: "system", content: "You are Grok, a helpful and maximally truthful AI built by xAI." },

80 {80 {

81 role: "user",81 role: "user",

82 content: "What is the meaning of life, the universe, and everything?",82 content: "Explain how neural networks learn in two sentences.",

83 }83 }

84 ],84 ],

85 stream: true85 stream: true


97const result = streamText({97const result = streamText({

98 model: xai.responses('grok-4.3'),98 model: xai.responses('grok-4.3'),

99 system:99 system:

100 "You are Grok, a chatbot inspired by the Hitchhiker's Guide to the Galaxy.",100 "You are Grok, a helpful and maximally truthful AI built by xAI.",

101 prompt: 'What is the meaning of life, the universe, and everything?',101 prompt: 'Explain how neural networks learn in two sentences.',

102});102});

103 103 

104for await (const chunk of result.textStream) {104for await (const chunk of result.textStream) {


115 "messages": [115 "messages": [

116 {116 {

117 "role": "system",117 "role": "system",

118 "content": "You are Grok, a chatbot inspired by the Hitchhiker'\\''s Guide to the Galaxy."118 "content": "You are Grok, a helpful and maximally truthful AI built by xAI."

119 },119 },

120 {120 {

121 "role": "user",121 "role": "user",

122 "content": "What is the meaning of life, the universe, and everything?"122 "content": "Explain how neural networks learn in two sentences."

123 }123 }

124 ],124 ],

125 "model": "grok-4.3",125 "model": "grok-4.3",


156Example streaming responses in Python/Javascript:156Example streaming responses in Python/Javascript:

157 157 

158```158```

159Ah, the ultimate question! According to Douglas Adams, the answer is **42**. However, the trick lies in figuring out what the actual question is. If you're looking for a bit more context or a different perspective:159Neural networks learn by adjusting connection weights to minimize prediction error. Through backpropagation, they propagate gradients backward through layers so each weight updates in the direction that improves accuracy on training data.

160 

161- **Philosophically**: The meaning of life might be to seek purpose, happiness, or to fulfill one's potential.

162- **Biologically**: It could be about survival, reproduction, and passing on genes.

163- **Existentially**: You create your own meaning through your experiences and choices.

164 

165But let's not forget, the journey to find this meaning might just be as important as the answer itself! Keep exploring, questioning, and enjoying the ride through the universe. And remember, don't panic!

166```160```

quickstart.md +26 −41

Details

44 44 

45## Step 4: Make your first request45## Step 4: Make your first request

46 46 

47Send a prompt to Grok and get a response:47Send a coding prompt to [Grok Build](/build/overview) (`grok-build-0.1`) and get a response. The same model powers agentic coding in Grok Build and is available on the API in early access:

48 

49```bash

50curl https://api.x.ai/v1/responses \

51 -H "Authorization: Bearer $XAI_API_KEY" \

52 -H "Content-Type: application/json" \

53 -d '{

54 "model": "grok-build-0.1",

55 "input": "Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}"

56 }'

57```

48 58 

49```python customLanguage="pythonXAI"59```python customLanguage="pythonXAI"

50import os60import os

51from xai_sdk import Client61from xai_sdk import Client

52from xai_sdk.chat import user, system62from xai_sdk.chat import user

53 63 

54client = Client(api_key=os.getenv("XAI_API_KEY"))64client = Client(api_key=os.getenv("XAI_API_KEY"))

55 65 

56chat = client.chat.create(model="grok-4.3")66chat = client.chat.create(model="grok-build-0.1")

57chat.append(system("You are Grok, a highly intelligent, helpful AI assistant."))67chat.append(user("Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}"))

58chat.append(user("What is the meaning of life, the universe, and everything?"))

59 68 

60response = chat.sample()69print(chat.sample().content)

61print(response.content)

62```70```

63 71 

64```python customLanguage="pythonOpenAISDK"72```python customLanguage="pythonOpenAISDK"

65import os

66from openai import OpenAI73from openai import OpenAI

67 74 

68client = OpenAI(75client = OpenAI(

69 api_key=os.getenv("XAI_API_KEY"),76 api_key="<YOUR_XAI_API_KEY_HERE>",

70 base_url="https://api.x.ai/v1",77 base_url="https://api.x.ai/v1",

71)78)

72 79 

73completion = client.responses.create(80response = client.responses.create(

74 model="grok-4.3",81 model="grok-build-0.1",

75 input=[82 input="Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}",

76 {"role": "system", "content": "You are Grok, a highly intelligent, helpful AI assistant."},

77 {"role": "user", "content": "What is the meaning of life, the universe, and everything?"},

78 ],

79)83)

80 84 

81print(completion.output_text)85print(response.output_text)

82```86```

83 87 

84```javascript customLanguage="javascriptAISDK"88```javascript customLanguage="javascriptAISDK"

85import { createXai } from '@ai-sdk/xai';89import { xai } from '@ai-sdk/xai';

86import { generateText } from 'ai';90import { generateText } from 'ai';

87 91 

88const xai = createXai({ apiKey: process.env.XAI_API_KEY });

89 

90const { text } = await generateText({92const { text } = await generateText({

91 model: xai.responses('grok-4.3'),93 model: xai.responses('grok-build-0.1'),

92 system: 'You are Grok, a highly intelligent, helpful AI assistant.',94 prompt: 'Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}',

93 prompt: 'What is the meaning of life, the universe, and everything?',

94});95});

95 96 

96console.log(text);97console.log(text);


105});106});

106 107 

107const response = await client.responses.create({108const response = await client.responses.create({

108 model: 'grok-4.3',109 model: 'grok-build-0.1',

109 input: [110 input: 'Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}',

110 { role: 'system', content: 'You are Grok, a highly intelligent, helpful AI assistant.' },

111 { role: 'user', content: 'What is the meaning of life, the universe, and everything?' },

112 ],

113});111});

114 112 

115console.log(response.output_text);113console.log(response.output_text);

116```114```

117 115 

118```bash116For multi-turn chat, reasoning, and [structured outputs](/developers/model-capabilities/text/structured-outputs), see the [Text Generation Guide](/developers/model-capabilities/text/generate-text). For agentic coding workflows, see the [Grok Build overview](/build/overview).

119curl https://api.x.ai/v1/responses \

120 -H "Content-Type: application/json" \

121 -H "Authorization: Bearer $XAI_API_KEY" \

122 -d '{

123 "model": "grok-4.3",

124 "input": [

125 {"role": "system", "content": "You are Grok, a highly intelligent, helpful AI assistant."},

126 {"role": "user", "content": "What is the meaning of life, the universe, and everything?"}

127 ]

128 }'

129```

130 

131Certain models also support [Structured Outputs](/developers/model-capabilities/text/structured-outputs), which allows you to enforce a schema for the LLM output. For an in-depth guide about using Grok for text responses, check out the [Text Generation Guide](/developers/model-capabilities/text/generate-text).

132 117 

133## Step 5: Generate an image118## Step 5: Generate an image

134 119 

rate-limits.md +2 −2

Details

38| grok-4.20-0309-non-reasoning | T0: 30, T1: 40, T2: 60, T3: 100, T4: 166 | T0: 10M, T1: 15M, T2: 25M, T3: 45M, T4: 85M |38| grok-4.20-0309-non-reasoning | T0: 30, T1: 40, T2: 60, T3: 100, T4: 166 | T0: 10M, T1: 15M, T2: 25M, T3: 45M, T4: 85M |

39| grok-build-0.1 | T0: 30, T1: 40, T2: 60, T3: 100, T4: 166 | T0: 10M, T1: 15M, T2: 25M, T3: 45M, T4: 85M |39| grok-build-0.1 | T0: 30, T1: 40, T2: 60, T3: 100, T4: 166 | T0: 10M, T1: 15M, T2: 25M, T3: 45M, T4: 85M |

40| grok-4.20-multi-agent-0309 | T0: 7, T1: 10, T2: 15, T3: 25, T4: 45 | T0: 2.5M, T1: 3.7M, T2: 6.2M, T3: 11M, T4: 21M |40| grok-4.20-multi-agent-0309 | T0: 7, T1: 10, T2: 15, T3: 25, T4: 45 | T0: 2.5M, T1: 3.7M, T2: 6.2M, T3: 11M, T4: 21M |

41| grok-imagine-image | 5 | — |

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

43| grok-imagine-video-1.5 | 1 | — |42| grok-imagine-image | 5 | — |

44| grok-imagine-video | 1 | — |43| grok-imagine-video | 1 | — |

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

45 45 

46### What counts toward TPM46### What counts toward TPM

47 47 

Details

236 236 

237### Request Body237### Request Body

238 238 

239* `duration` (integer | null) — Duration of the extension segment to generate in seconds (1-10).239* `duration` (integer | null) — Duration of the extension segment to generate in seconds (2-10).

240 Defaults to 6 seconds if not specified.240 Defaults to 6 seconds if not specified.

241 241 

242* `model` (string | null) — Model to be used.242* `model` (string | null) — Model to be used.