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
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
- 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
Install steps
- Create an API key in the xAI console. Copy it once; you will not see it again.
- In VS Code: Ctrl+Shift+X → search Continue → install. Or:
code --install-extension Continue.continue. - Open the Continue panel from the Activity Bar.
- Open config (gear / “Open config.yaml”).
- Add an xAI model block (sample below). Prefer Continue secrets / env substitution over pasting the raw key into a committed file.
- 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- provider must be
xai(Continue’s xAI provider id). - roles: start with
chat,edit,apply. Addautocompleteonly if you pick a model Continue documents for that role. - Agent / tools: needs a model that supports tool use; if Agent fails, stay on Chat/Edit.
- Same Continue install can also list Ollama or DeepSeek models — pick per task.
Settings tips
- Keep Continue’s context small: reference one file with @ instead of the whole repo.
- Turn off autocomplete if two AI completions fight (e.g. Copilot + Continue).
- Check Continue docs → Model Providers → xAI when model names change.
First task (5 minutes)
Write a Python 3 function is_palindrome(s) that ignores case and spaces. Only return the code. Then wait — I will run tests myself.
- Paste the prompt in Continue Chat.
- Apply the edit to a new file only if the diff is small and clear.
- Write or ask for a tiny pytest; run
pytest -qyourself. - Reject any request to read
.env.
| Path | Notes |
|---|---|
| Continue + xAI (this lesson) | Official integration path for Grok inside VS Code |
| xAI / Grok web chat alone | Fine for paste-code, weaker project context |
| Cursor model picker | Some AI-native editors also list Grok — separate product |
- 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
Grok API calls cost money. Use short prompts, one file at a time. Use local Ollama for practice drills; save Grok for harder coding.