Ravindra BagaleCourses & study guides Track your progress
AI CODING ASSISTANTS · CHAPTER 2 · SETUP

How to Use Grok for Coding in VS Code (Continue)

xAI’s Grok models do not ship a first-party VS Code coding extension like Copilot. The real bridge is the open-source Continue extension: you add an xai provider in ~/.continue/config.yaml and chat/edit from VS Code.

In short: create an xAI API key, install Continue (Continue.continue), set provider: xai with a current Grok model id from the xAI console, reload config, then chat. Model id strings change — copy them from the console, do not invent them.

Why Grok via Continue

WHY

You may already like Grok for reasoning, or your team standardised on xAI. Continue lets you keep VS Code and swap models without learning a new editor.

What you need

WHAT
  • xAI API key: from the xAI console. Store it as a secret, not in Git.
  • Continue: VS Code extension ID Continue.continue (also works in many VS Code forks).
  • config.yaml: usually ~/.continue/config.yaml (Continue gear → open config).
  • Model id: exact string from xAI docs/console (example ids in Continue docs have looked like grok-4-1-fast-non-reasoning — re-check before you paste).

How it connects

1 · Get xAI API key console 2 · Install Continue VS Code 3 · Edit config.yaml provider: xai 4 · Reload config pick Grok in Continue 5 · Chat / edit review every patch

Install steps

HOW
  1. Create an API key in the xAI console. Copy it once; you will not see it again.
  2. In VS Code: Ctrl+Shift+X → search Continue → install. Or: code --install-extension Continue.continue.
  3. Open the Continue panel from the Activity Bar.
  4. Open config (gear / “Open config.yaml”).
  5. Add an xAI model block (sample below). Prefer Continue secrets / env substitution over pasting the raw key into a committed file.
  6. Click Reload config. Select the Grok model in Continue’s model picker.

Configuration

~/.continue/config.yaml (sample — update model id)
name: Grok Coding
version: 0.0.1
schema: v1
models:
  - name: Grok (chat)
    provider: xai
    model: grok-4-1-fast-non-reasoning
    apiKey: ${{ secrets.XAI_API_KEY }}
    roles:
      - chat
      - edit
      - apply
  1. provider must be xai (Continue’s xAI provider id).
  2. roles: start with chat, edit, apply. Add autocomplete only if you pick a model Continue documents for that role.
  3. Agent / tools: needs a model that supports tool use; if Agent fails, stay on Chat/Edit.
  4. Same Continue install can also list Ollama or DeepSeek models — pick per task.

Settings tips

  1. Keep Continue’s context small: reference one file with @ instead of the whole repo.
  2. Turn off autocomplete if two AI completions fight (e.g. Copilot + Continue).
  3. Check Continue docs → Model Providers → xAI when model names change.

First task (5 minutes)

ASK GROK IN CONTINUE

Write a Python 3 function is_palindrome(s) that ignores case and spaces. Only return the code. Then wait — I will run tests myself.

  1. Paste the prompt in Continue Chat.
  2. Apply the edit to a new file only if the diff is small and clear.
  3. Write or ask for a tiny pytest; run pytest -q yourself.
  4. Reject any request to read .env.
PathNotes
Continue + xAI (this lesson)Official integration path for Grok inside VS Code
xAI / Grok web chat aloneFine for paste-code, weaker project context
Cursor model pickerSome AI-native editors also list Grok — separate product
Rule: never commit API keys. If a sample model id 404s, replace it with the current id from the xAI console — do not guess.
  • Company policy may ban third-party API keys on work laptops.
  • Billing is usage-based on xAI — watch the console.

Quick quiz

1. Which VS Code extension bridges Grok?

Continue (Continue.continue).

2. Which provider string?

xai.

3. Where is config?

Usually ~/.continue/config.yaml.

4. Model id wrong — what do you do?

Copy the current id from the xAI console / docs; reload config.

Save tokens and money

SMART AI USE

Grok API calls cost money. Use short prompts, one file at a time. Use local Ollama for practice drills; save Grok for harder coding.

Save these cards

INTERVIEW CARDAI Coding

How do you use Grok in VS Code?

Continue extension + xAI API key.
provider: xai in config.yaml.
Ravindra Bagale · ravindrabagale.com/ai-coding
COMPARISON CARDAI Coding

Grok via Continue vs Copilot

Grok/Continue: bring-your-own xAI key, flexible models.
Copilot: GitHub plan, deep IDE features.
Ravindra Bagale · ravindrabagale.com/ai-coding
REVISION CARDAI Coding

Grok Continue in 4

API key → install Continue.
config.yaml provider xai.
Reload → chat.
Never commit keys.
Ravindra Bagale · ravindrabagale.com/ai-coding