SuperGrok.info
Steps/Code examples

This quickstart keeps the first call small. The aim is not to build a full app in one page. It is to prove your key, endpoint, model name and request shape are correct.

Once that works, slow down before adding real users. Add logging, timeout handling, rate-limit handling and a way to hide or redact sensitive prompt content. A successful demo request proves connectivity. It does not prove the workflow is ready for customer data, large files, long conversations or predictable billing.

  1. 1

    Create an API key

    Sign in to the official xAI developer console, add billing if required and create a key. Copy it once and store it securely.

  2. 2

    Set an environment variable

    Set XAI_API_KEY in your terminal, deployment platform or secret manager. Do not hard-code it in source files.

  3. 3

    Make a small request

    Use a short prompt first. Once the call works, add larger context, streaming, tools or your own application logic.

  4. 4

    Read errors calmly

    A 401 usually means a missing or wrong key. A 429 usually means rate limiting. A 400 usually means the request body is malformed.

curl

curl https://api.x.ai/v1/chat/completions \
  -H "Authorization: Bearer $XAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-4.5",
    "messages": [
      { "role": "system", "content": "You are concise." },
      { "role": "user", "content": "Explain API keys in one sentence." }
    ]
  }'

Node 18 or newer

const response = await fetch("https://api.x.ai/v1/chat/completions", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.XAI_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "grok-4.5",
    messages: [{ role: "user", content: "Say hello in one sentence." }],
  }),
});

if (!response.ok) {
  throw new Error(await response.text());
}

const data = await response.json();
console.log(data.choices[0].message.content);

If you receive a response with a choices array, the basic loop works. Next, read the limits guide and estimate cost.

Frequently asked questions

Estimate real usage next

A working request is step one. Cost control comes from measuring token volume.

supergrok.info is an independent guide and resource site. It is not xAI, Grok, X, or an official login, billing, API, app, or support channel. For passwords, subscriptions, API keys, billing, app downloads, account access, incidents and support, use official xAI and Grok links. Grok and xAI are trademarks of their respective owners. This site uses those names only to describe and reference the product.