overview.md +6 −6
70 70
71You can also switch inside the TUI with `/model <name>`.71You can also switch inside the TUI with `/model <name>`.
72 72
7373## Use Grok 4.6 on the API## Use Grok 4.7 on the API
74 74
7575The same model that powers Grok Build, [`grok-4.6`](/developers/models/grok-4.6), is also available directly on the xAI API. Drop it into your own agent loop, IDE integration, or coding tool.[`grok-4.7`](/developers/models/grok-4.7), SpaceXAI's latest model, is available directly on the xAI API. Drop it into your own agent loop, IDE integration, or coding tool.
76 76
77```bash customLanguage="bash"77```bash customLanguage="bash"
78curl https://api.x.ai/v1/responses \78curl https://api.x.ai/v1/responses \
79 -H "Authorization: Bearer $XAI_API_KEY" \79 -H "Authorization: Bearer $XAI_API_KEY" \
80 -H "Content-Type: application/json" \80 -H "Content-Type: application/json" \
81 -d '{81 -d '{
8282 "model": "grok-4.6", "model": "grok-4.7",
83 "input": "Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}"83 "input": "Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}"
84 }'84 }'
85```85```
91 91
92client = Client(api_key=os.getenv("XAI_API_KEY"))92client = Client(api_key=os.getenv("XAI_API_KEY"))
93 93
9494chat = client.chat.create(model="grok-4.6")chat = client.chat.create(model="grok-4.7")
95chat.append(user("Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}"))95chat.append(user("Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}"))
96 96
97print(chat.sample().content)97print(chat.sample().content)
106)106)
107 107
108response = client.responses.create(108response = client.responses.create(
109109 model="grok-4.6", model="grok-4.7",
110 input="Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}",110 input="Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}",
111)111)
112 112
118import { generateText } from 'ai';118import { generateText } from 'ai';
119 119
120const { text } = await generateText({120const { text } = await generateText({
121121 model: xai.responses('grok-4.6'), model: xai.responses('grok-4.7'),
122 prompt: 'Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}',122 prompt: 'Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}',
123});123});
124 124