More tools · Cursor and Grok
Grok, the xAI API and Grok bots
What it is
Grok is xAI's assistant, at grok.com and in the iOS and Android apps, with chat, voice, image and video generation, file uploads and connectors. It's free to start, with paid SuperGrok plans. Developers reach the same models through the xAI API.
When to pick it
When you want Grok's models, or you're building on the API and want to use the OpenAI SDK you already know.
Setup in the app
- Sign in at grok.com or in the app.
- Attach files with the + next to the message box.
- To link your X account: Settings, Account, Connect your X Account.
Setup for the API
- Create an account at console.x.ai, add credits, and create a key on the API Keys page. Keep it in an environment variable,
XAI_API_KEY. - Point the OpenAI SDK at xAI:
import os
from openai import OpenAI
client = OpenAI(api_key=os.environ["XAI_API_KEY"], base_url="https://api.x.ai/v1")
reply = client.responses.create(model="grok-4.7", input="Explain MCP in two sentences.")
print(reply.output_text)
xAI's models page lists grok-4.7 as its most capable model today; check it before you pick one.
A first real task
Run the script above, then change the question to one about your own business and compare the answer with what you'd write.
Connect it to your site or data
- Function calling: describe your own functions with a name, a description and JSON Schema parameters. The model asks for a call, your code runs it and sends back the result.
- Remote MCP: pass an MCP server as a tool, and Grok calls it for you:
tools=[{"type": "mcp", "server_url": "https://academy.memberpress.ai/mcp", "server_label": "academy"}]
About Grok bots
Grok Bot is xAI's own product: you set up a bot by messaging it, and on X you mention @bot in a post or reply to give it a task. It needs an X account connected to Grok, and isn't in every region. xAI's docs don't describe building your own reply bot for X. To build your own bot, use the API: the script above, plus function calling or remote MCP for your data.
Checked against xAI's docs on 2026-10-14: Grok overview, Grok FAQ, API overview, quickstart, models, function calling, remote MCP, Grok Bot.
Try these prompts
- Write a short Python script that asks Grok one question through the xAI API using the OpenAI SDK, reading the key from XAI_API_KEY.Open in ChatGPT (new tab)Open in Claude (new tab)
- I want a bot that answers questions about my site using my MCP server. Sketch it with the xAI API and remote MCP tools.Open in ChatGPT (new tab)Open in Claude (new tab)
Ask me about this lesson
I'll answer from "Grok, the xAI API and Grok bots" and the rest of the academy.
I keep this chat with your account, so it's here on any lesson.
Sign in to keep your place and tick off lessons. Reading stays open either way.