1 / 6

Lesson · 12 min

Models and the Console

What you are actually calling, and where the key lives.

The xAI API is OpenAI-compatible at https://api.x.ai/v1. You authenticate with a bearer key from the Console. That key is a secret. It belongs on a server, in an environment variable, never in a Vite frontend, never in a git repo, never in a VITE_ prefix.

  • Chat / reasoning / code — the Grok flagship line (Grok 4.6 as of this writing).
  • Imagine — image and video model families, different pricing.
  • Voice — TTS (and related audio) on their own endpoints.

Create the key in the Console, restrict it if the Console allows, store it in your host's secret manager. Rotate it if it leaks. Treat 'it was only a demo' as not a defense.