Grok by xAI: how it works and how to integrate it in a business
What Grok is, what the API costs, how to integrate it in PHP, and what to know about GDPR, data and the AI Act first. Prices checked in November 2026.
Published on · 17 min
Grok is the artificial intelligence assistant made by xAI, Elon Musk's AI company, which SpaceX acquired in February 2026 and which its official documents now call SpaceXSI. A business can use it in three ways: through the app (grok.com, iPhone, Android, X), with a Business plan for the team, or by connecting it to its own software through the API, paying per use. As of 27 November 2026 the flagship model, Grok 4.7, costs $2 per million input tokens and $6 per million output tokens; Grok 4.3 costs $1.25 and $2.50. Before the price, though, there is one rule to know: the business terms ask you to send personal data only with "zero data retention" switched on.
What Grok is and who makes it
Grok comes from xAI. In February 2026 SpaceX acquired xAI, which took the name SpaceXAI on 6 July 2026, as Engadget reported the next day. In October Musk announced a further change, to SpaceXSI; on 7 October Newsweek wrote that there was no formal announcement yet. Today, however, the developer documentation, the privacy policy and the business contracts already use SpaceXSI, and the privacy policy updated on 27 October 2026 is issued by SpaceX Super Intelligence LLC.
The Grok name has not changed. In this article I write xAI when I talk about the history and SpaceXSI when I quote today's documents.
SpaceX
acquired xAI in February 2026
SpaceXSI (formerly xAI, then SpaceXAI)
the AI division: it signs the documentation, privacy policy and contracts
Grok
the assistant: grok.com, iOS and Android apps, X
Grok models
grok-4.7, grok-4.3 and the others, which businesses use through the API
How Grok works
Under Grok there are language models: programs that read a text and write the most likely answer.
The models
According to the models page, for text and code SpaceXSI recommends Grok 4.7, "the most capable model we've built". It reads text and images, writes text, and its knowledge runs to May 2026. Next to it is Grok 4.3, which its model page describes as fast and reliable, with strong tool use and instruction following.
The context
The context is how much text the model considers at once. Grok 4.7 goes up to 500,000 tokens, Grok 4.3 to one million. A token is a piece of a word, the unit you pay for. From 200,000 tokens per request upward the price doubles.
Reasoning
Grok models "think" before answering, and the level is set with a parameter. According to the reasoning guide, on Grok 4.7 the default level is high and reasoning cannot be turned off; on Grok 4.3 the default is low and it can be turned off. More reasoning means more careful answers, but also longer waits and more tokens on the bill.
Searching the web and X
Without tools, Grok does not know recent events. With web search and X search it searches on its own and cites its sources. X search, on the social network, is what sets Grok apart: it reads public posts and profiles in real time.
Images, video and voice
With the Imagine models it generates and edits images and video. With the voice APIs it talks and listens in real time (Grok Voice 3.0), transcribes audio and reads text aloud.
Versions and plans: app, Business and API
The app. Grok can be used for free on grok.com and in the apps, with limits. New subscriptions are now called The X Subscription and bundle Grok, Cursor (a code editor) and X benefits; anyone with an older SuperGrok or X Premium plan can keep it. List prices, excluding tax, according to the plans page:
| Plan | Price per month | Notes |
|---|---|---|
| Free | $0 | limited usage |
| Plus | $8 | individuals only |
| Premium | $30 (also per seat for teams) | 4x base usage, includes Grok Bot |
| Super | $100 | 15x base usage, includes Grok Bot |
| Ultra | $200 | 50x base usage, includes Grok Bot |
Grok Bot is an agent with a computer in the cloud: it builds presentations, sorts email, keeps the calendar up to date.
Business and Enterprise. The Business plan gives the team a workspace covered by the enterprise terms; Enterprise adds custom retention rules. Connectors link Grok to Gmail, Google Drive, Outlook, OneDrive, SharePoint, Teams and Salesforce, and on Business plans an administrator enables them.
The API. This is the route for integrating it into your software: an account on console.x.ai, prepaid credit, a secret key. Grok is also available on Google Cloud Vertex AI and Microsoft Foundry, if your company already uses one of these platforms.
How much the Grok API costs
Standard prices in dollars per million tokens, read on 27 November 2026 on the pricing page, for requests under 200,000 tokens. "Cached" is the reduced price for text already sent in a previous request, such as fixed instructions.
| Model | Input | Cached | Output | Context |
|---|---|---|---|---|
| grok-4.7 | 2.00 | 0.50 | 6.00 | 500,000 |
| grok-4.6 | 2.00 | 0.50 | 6.00 | 500,000 |
| grok-4.5 | 2.00 | 0.30 | 6.00 | 500,000 |
| grok-4.3 | 1.25 | 0.20 | 2.50 | 1 million |
| grok-4.20 (with and without reasoning) | 1.25 | 0.20 | 2.50 | 1 million |
The other items on the price list:
- Deferred processing (Batch API): 20% off on the Grok 4.x models, with results usually within 24 hours.
- US endpoint: +10% on Grok 4.7 and Grok 4.6 tokens.
- Images: $0.04 each with grok-imagine-image-2.0.
- Video: $0.08 per second with version 1.5.
- Real-time voice: $0.08 per minute.
Tools are also paid separately:
Source: SpaceXSI, Pricing, consulted on 27 November 2026. Token costs come on top of tool costs.
Handy for accounting: according to the cost tracking guide, every API response reports what that request cost, discounts included.
Grok, ChatGPT, Claude and Gemini compared
I compare the mid-range tier, the one for answering customers and reading documents, and the small models. Official prices as of 27 November 2026 from Anthropic, OpenAI, Google and SpaceXSI. The last column is an assumption: 1,000 answers a month, each with 4,000 input tokens and 400 output tokens, not counting reasoning tokens.
| Model | Input | Output | Context | 1,000 answers (assumption) |
|---|---|---|---|---|
| Grok 4.3 | $1.25 | $2.50 | 1 million | about $6 |
| Gemini 4 Hydrogen | $1.50 | $7.50 | 1 million | about $9 |
| Grok 4.7 | $2.00 | $6.00 | 500,000 | about $10.40 |
| Claude Sonnet 5.5 | $2.00 | $10.00 | 1 million | about $12 |
| GPT-6.2 Sol | $2.00 | $10.00 | 1.05 million | about $12 |
| Claude Haiku 5.5 (small) | from $0.10 | from $0.50 | 1 million | about $0.60 |
| GPT-6 Luna (small) | $0.10 | $0.50 | 1.05 million | about $0.60 |
Source: official price lists of SpaceXSI, Google, Anthropic and OpenAI, consulted on 27 November 2026. Requests under 200,000 tokens.
What the numbers say, without stretching them:
- On price, in the mid-range tier Grok costs less than the others for generated text.
- In the small tier, SpaceXSI's price list has no $0.10 model like those from Anthropic and OpenAI: to route thousands of simple requests, those cost less.
- Reasoning is billed: on Grok 4.7 it cannot be turned off, so the real cost must be measured on your own cases.
- X search is Grok's distinctive feature, useful if your customers and your industry talk about you there.
- On data in Europe the difference is clear. OpenAI offers a Europe region (EEA and Switzerland) to eligible organisations; SpaceXSI's documentation describes a single regional endpoint, in the United States. I compared the European options for Claude and Gemini in which AI model to choose for a chatbot.
I don't rank quality: a test on your own data decides.
What Grok can do for a business
The uses are those of the other models, plus the ones tied to X:
- Reading orders, emails and PDFs and turning them into data for your business software, in a fixed format the software checks.
- Answering from company documents (manuals, price lists, procedures), by uploading them to a collection that Grok searches on its own.
- Preparing a sales call: the official documentation has an example in which Grok searches the web and X and reads the account from the CRM through the company's own functions.
- Listening to what is said about your brand on X, with search on public posts. These are still personal data of the people who write them: assess it with whoever handles privacy.
- Voice assistants for the switchboard or bookings, with the real-time voice API.
How to integrate Grok, step by step
The method is the same one I follow with any AI provider:
- Pick a precise task, repetitive and measurable: for example "read the orders that arrive by email".
- Decide which data goes through. If there is personal data, you need zero data retention (see the risks below) and a check with whoever handles privacy.
- Create the account on console.x.ai, load some credit and generate an API key.
- Put the key in an environment variable on the server, never in the code: that way it doesn't end up in the code archive or in copies that change hands. I explained how in environment variables and secrets on GitHub.
- Choose the model: Grok 4.3 to extract and classify, Grok 4.7 for complex cases. Check in the console which models your account sees: the July 2026 release notes separately announced that Grok 4.5 had arrived for EU users.
- Use the Responses API. The old Chat Completions are deprecated and, according to SpaceXSI, give worse results.
- Ask for answers in a fixed format (structured output), so the software reads them without interpreting them.
- Log the cost and outcome of every request and set spending limits.
- Test on a hundred real examples before connecting everything, and keep a person on the doubtful cases.
For your developer: a call in PHP 8.2
The SpaceXSI API is compatible with OpenAI's: you call POST https://api.x.ai/v1/responses with the key in the Authorization: Bearer header. It also works with OpenAI's libraries (SDKs) by changing the base URL, but here I use cURL, which is available on any PHP hosting. The function reads the key with getenv('XAI_API_KEY') and retries with growing waits on a 429 error (too many requests), as the rate limits guide recommends, or on a server error.
<?php
declare(strict_types=1);
/**
* Sends a request to Grok (xAI Responses API) and returns text, cost and token usage.
*
* @param array<int, array{role: string, content: string}> $messages
* @param array<string, mixed> $options extra request fields (e.g. 'text' for structured output)
* @return array{text: string, cost_usd: float, usage: array<string, mixed>}
*/
function grokResponse(array $messages, string $model = 'grok-4.3', array $options = []): array
{
$apiKey = getenv('XAI_API_KEY');
if ($apiKey === false || $apiKey === '') {
throw new RuntimeException('The XAI_API_KEY environment variable is missing.');
}
$body = json_encode(array_merge([
'model' => $model,
'input' => $messages,
'store' => false, // don't store the conversation on xAI servers
'reasoning' => ['effort' => 'low'], // grok-4.3 accepts "none" to "xhigh"
], $options), JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE);
for ($attempt = 1; $attempt <= 3; $attempt++) {
$ch = curl_init('https://api.x.ai/v1/responses');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Authorization: Bearer ' . $apiKey,
],
CURLOPT_POSTFIELDS => $body,
CURLOPT_CONNECTTIMEOUT => 10, // seconds to connect
CURLOPT_TIMEOUT => 120, // seconds for the full response
]);
$raw = curl_exec($ch);
$status = (int) curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$networkError = curl_error($ch);
curl_close($ch);
// Network error, too many requests (429) or server error: retry with growing waits
if ($raw === false || $status === 429 || $status >= 500) {
if ($attempt < 3) {
sleep(2 ** $attempt);
continue;
}
throw new RuntimeException("Grok unavailable (HTTP {$status}) {$networkError}");
}
$data = json_decode((string) $raw, true);
if (!is_array($data)) {
throw new RuntimeException("Unreadable response (HTTP {$status}).");
}
if ($status !== 200) {
$message = is_string($data['error'] ?? null) ? $data['error'] : json_encode($data['error'] ?? $data);
throw new RuntimeException("xAI error {$status}: {$message}");
}
// The text sits in the "message" items of the output array, in parts of type "output_text"
$text = '';
foreach ($data['output'] ?? [] as $item) {
if (($item['type'] ?? '') !== 'message') {
continue;
}
foreach ($item['content'] ?? [] as $part) {
if (($part['type'] ?? '') === 'output_text') {
$text .= $part['text'];
}
}
}
$usage = $data['usage'] ?? [];
return [
'text' => $text,
'cost_usd' => ($usage['cost_in_usd_ticks'] ?? 0) / 10_000_000_000, // 1 dollar = 10^10 ticks
'usage' => $usage,
];
}
throw new LogicException('Unreachable.');
}
Three choices worth noting. store: false asks the API not to save the response for later retrieval: according to the Responses API reference, stored responses stay on the servers for 30 days. The copy kept for abuse checks, on the other hand, is removed only with zero data retention, which I cover below. The timeout is generous because reasoning can take time. The cost arrives in the cost_in_usd_ticks field, where one dollar is worth 10 billion ticks: save it in the log of every operation.
Structured output: reading an order from an email
With structured output you pass a JSON schema, that is, the description of the expected fields, in the text.format parameter, and SpaceXSI guarantees the answer matches it, as long as the schema uses supported features. Your software always receives the same fields.
<?php
$emailText = "Good morning, for Rossi Ltd we need 20 units of item A-104 and 5 of B-220 by 12 December.";
$orderSchema = [
'type' => 'object',
'properties' => [
'customer' => ['type' => 'string'],
'delivery' => ['anyOf' => [['type' => 'string', 'format' => 'date'], ['type' => 'null']]],
'lines' => [
'type' => 'array',
'items' => [
'type' => 'object',
'properties' => [
'code' => ['type' => 'string'],
'quantity' => ['type' => 'integer', 'minimum' => 1],
],
'required' => ['code', 'quantity'],
'additionalProperties' => false,
],
],
'needs_review' => ['type' => 'boolean'],
],
'required' => ['customer', 'delivery', 'lines', 'needs_review'],
'additionalProperties' => false,
];
$result = grokResponse(
[
['role' => 'system', 'content' => 'Extract the order data. If a value is missing or ambiguous, use null and set needs_review to true.'],
['role' => 'user', 'content' => $emailText],
],
'grok-4.3',
['text' => ['format' => [
'type' => 'json_schema',
'name' => 'order',
'schema' => $orderSchema,
'strict' => true,
]]]
);
$order = json_decode($result['text'], true, 512, JSON_THROW_ON_ERROR);
if ($order['needs_review']) {
// the order goes into a queue that a person checks before saving it
}
Careful: the schema checks the shape, not the truth. According to the documentation, even 30 February passes as a date. Item codes and dates still need checking in your own code.
Function calling: when Grok needs data from your software
With function calling you describe some functions of your software to Grok, such as "look up an item's stock". The model doesn't run them: it returns a function_call item with arguments and a call_id; your code runs the function and sends the result back as function_call_output with the same call_id. That way you decide what it can read.
Risks: privacy, GDPR and where the data goes
The rules change depending on how you use Grok. The table summarises the privacy policy updated on 27 October 2026, the European addendum of 24 August 2026, the enterprise terms and the security FAQ.
| How you use it | Training on your data | Retention | Where |
|---|---|---|---|
| Free or paid app | Yes, on legitimate interest; you can object in the settings | deleted or private chats disappear within 30 days, unless legally required | controller is a US company |
| Grok on X | X's privacy policy applies | as per X | as per X |
| Business, Enterprise and API | No, unless you give explicit permission | up to 30 days for abuse checks | the global endpoint does not guarantee the region |
| API with zero data retention (ZDR) | No | nothing on disk: data deleted right after the response | as above |
Three points a business owner needs to know.
1. Personal data requires zero data retention. The enterprise terms and the Data Processing Addendum, the data processing contract in force since 22 September 2026, ask the customer to send personal data only through the API with Zero Data Retention (ZDR). Sending it without ZDR is a breach of contract. ZDR is switched on from the console for the whole team, and every response confirms it in the x-zero-data-retention header. The trade-off: no history on the servers, no files or document collections, no Batch API, and you keep the copies you need yourself.
2. The data goes to the United States. The DPA names SpaceXSI as processor and provides for transfers outside Europe under the European Commission's standard contractual clauses, governed by Irish law, with notice within 48 hours, where feasible, in case of a data breach. The only documented regional endpoint is in the United States. SpaceXSI states it holds SOC 2 Type 2 security certification.
3. The app is not the tool for customer data. For European users the privacy policy provides for training on the content entered. It's fine for a generic text, not for a contract or a customer list.
In practice: ZDR on, data kept to a minimum and anonymised where possible, and an assessment with whoever handles privacy in your company.
The AI Act: what changes if you use Grok
The obligations on general-purpose models, such as Grok, fall on those who develop them. For you, using them in your business, the AI Act mainly asks two things, according to the European Commission page updated on 25 November 2026: train the people who use them (an obligation in force since 2 February 2025) and comply with the transparency rules, applicable from August 2026. In practice, a chatbot must say it is an AI. From December 2026 a new prohibition added by the Digital Omnibus also applies. Dates and details are in the article on the AI Act.
Two SpaceXSI tools help. The watermark is an invisible signal that makes generated text or audio recognisable: for text you switch it on from the console, for audio it is always on for users in the EU. The moderation controls make Grok decline sexual, violent or profane content: in a customer-facing service it is worth switching them on.
The public controversies around Grok
Anyone choosing a provider should know its history. The main facts:
- April 2025. Ireland's Data Protection Commission opened an inquiry into the use of European X users' public posts to train Grok, to check its lawfulness and transparency.
- July 2025. For about 16 hours, after an update, the @grok account on X published antisemitic messages. On 12 July xAI apologised, as NBC News reported: it blamed a change in the code upstream of the bot and announced it would publish the bot's new instructions.
- January 2026. Grok had been used on X to create sexualised images of real people without consent, including minors. On 2 January the Italian data protection authority, the Garante privacy, opened an investigation, later merged into the Irish authority's, because X is based in Ireland. On 26 January the European Commission opened proceedings against X under the Digital Services Act, the EU regulation on online platforms: according to the Law Society Gazette, it is examining whether X assessed and reduced the risks before rolling out Grok.
- February 2026. On 17 February the Data Protection Commission opened a second inquiry into X over the same images, on GDPR compliance: lawfulness, data protection by design, impact assessment.
In the sources I consulted these proceedings are still open: an investigation is not a ruling. They concern mainly Grok inside X, not the API a business uses. But they say something useful to anyone integrating a model, Grok or another: what the AI generates must be filtered and reviewed before it reaches customers.
My experience with AI in business software
I work with the OpenAI and Claude APIs, and the rules I've learned apply to any provider. In CuraPiù, the care home management software I designed and built, the AI turns a dictated note into structured data to be confirmed and flags residents at risk in advance, always validated by a doctor or a nurse. It's the pattern of the example above: fixed format, a check by the software, the final decision by a person. In D@to, the tourism management platform I work on, the d-Buddy assistant works as Copilot, Concierge or Autopilot. The model is a component: what matters is how you connect it to data and people.
Frequently asked questions
Is Grok free?
Yes, to get started. The app on grok.com and on phones has a free plan with limited usage. The paid plans of The X Subscription range from $8 to $200 a month, excluding tax. The API, instead, is paid per use with prepaid credit: for example $1.25 per million input tokens with Grok 4.3.
How much does the Grok API cost?
As of 27 November 2026, Grok 4.7 costs $2 per million input tokens and $6 per million output tokens; Grok 4.3 costs $1.25 and $2.50. From 200,000 tokens per request upward prices double. Web search costs $5 per 1,000 calls, the Batch API is 20% off, and the US endpoint costs 10% more with Grok 4.7 and 4.6.
Can I send my customers' data to Grok?
Only through the API with zero data retention (ZDR) switched on: SpaceXSI's business terms require it for personal data. The data is processed in the United States, under standard contractual clauses, and there is no dedicated European endpoint. Never paste it into the app, which for European users provides for training on content.
Grok or ChatGPT for a business?
It depends on the task and the data. Grok costs less in the mid-range tier and searches X; OpenAI offers processing in Europe to eligible organisations and has cheaper small models. The right choice comes from a test on your real examples, with an integration that lets you switch models without rewriting the software.
Does code written for OpenAI work with Grok?
Largely, yes. SpaceXSI states that its API is compatible with OpenAI's: with OpenAI's official libraries you just change the base URL to https://api.x.ai/v1 and use the xAI key. You still need to check model names, reasoning parameters and specific features, such as X search.
Where to start
Grok is an option worth considering if you need a capable model at a moderate price, or if your market lives on X. But the task and the data come before the model. With AI integration in your website or business software I start from a repetitive, measurable job, test the models on a hundred real examples and write the code so you can switch provider without redoing everything. If you're wondering which model tier to use, read which AI model to choose for a chatbot. Book the free 30-minute analysis: we look at your case together and decide where to begin.