Grok Chat for Visual Studio Code
A focused Grok coding workspace, directly inside VS Code.
Chat about code with Grok or optional OpenRouter models, connect your project to Grok Bot through custom connectors, and create images or videos with Grok Imagine without leaving the editor.
[!IMPORTANT]
Grok Chat is an independent, unofficial extension. It is not affiliated with, endorsed by, or sponsored by xAI. Grok, xAI, and related names belong to their respective owners.
[!TIP]
New: Grok Bot connector support. Connect Grok Bot to selected project files, review proposed changes in VS Code, and approve project tasks. Start from Grok Chat → Settings → MCP / Grok Bot → Grok Bot. See the setup guide below.
[!TIP]
Experimental feature: Grok Imagine can use the active SuperGrok OAuth session when no xAI API key is configured. This route is enabled by default, is identified before generation, and may still be rejected or limited by xAI. An xAI API key remains the stable alternative.
Why install Grok Chat?
Explain code, fix bugs, write tests, and refactor with project-aware conversations directly in VS Code.
- Connect your way: Grok OAuth, an xAI API key, or optional OpenRouter models such as Claude, GPT, Gemini, DeepSeek, and Llama.
- Work with your project: attach files, choose automatic context, and let the agent search code and propose edits.
- Keep conversations organized: use multiple chats in the sidebar or open chat in an editor tab.
- Speak your prompts: use local Windows voice input or opt-in xAI transcription.
- Create with Imagine: generate and edit images or create videos without leaving the editor.
- Connect Grok Bot: share selected project files through a visual connector setup.
- Stay in control: choose approval settings and keep credentials in VS Code Secret Storage.
- Use your language: follow VS Code’s display language or select a language in Settings.
Preview
Get started
- In VS Code, open Extensions, search for Grok Chat by AnUnknownArtist, and select Install. You can also open the Marketplace listing.
- Open a folder in VS Code.
- Select the Grok Chat icon in the Activity Bar.
- Connect with Grok OAuth, an xAI API key, or the optional OpenRouter provider.
- Choose a model and start a conversation.
Grok / xAI is always the initial provider. OpenRouter is optional and can be connected later from the same panel without changing an existing Grok setup.
The first-run experience can prepare a new project, integrate guidance into an existing project, or skip setup and open chat immediately.
Try a first prompt: “Explain how this project is organized”, “Help me fix this error”, or “Write tests for the attached file.”
If you received a trusted .vsix file, use Extensions → … → Install from VSIX… instead.
Connect your account
Grok OAuth and xAI API keys use separate account access and billing.
Mode 1 — Grok OAuth
- Opens the browser so you can sign in with your Grok account.
- Uses the subscription and access available to that account.
- Does not require an xAI API key.
- Stores the resulting OAuth session in VS Code Secret Storage.
Mode 2 — xAI API
- Requires an API key created for
api.x.ai.
- Uses the xAI API independently from the OAuth subscription mode.
- May consume paid credits or generate costs according to the xAI account.
- Stores the API key in VS Code Secret Storage.
If both credentials exist, Settings clearly shows which method is active. Switching methods does not silently delete the other credential.
Optional provider — OpenRouter
Grok / xAI remains the default experience, but OpenRouter provides an optional route to a broader model catalog—including Claude, GPT, Gemini, DeepSeek, Llama, and other families—without replacing your Grok connection.
- Connect through OpenRouter's browser authorization flow or enter an OpenRouter API key.
- Start with Free Auto ⚡, or choose catalog entries marked
FREE / :free when available.
- Free models use OpenRouter's account quotas and provider rate limits. They are useful for trying models and lighter work, but they are not guaranteed to be unlimited or continuously available.
- Paid models are clearly separated and show input/output pricing whenever OpenRouter supplies it.
- Switch between xAI and OpenRouter from the composer; each provider keeps an independent connection state and model list.
OpenRouter credentials are stored in VS Code Secret Storage. Requests made with this provider are sent directly to OpenRouter and are subject to its current quotas, pricing, availability, and privacy terms.
Grok Imagine: images and video
Choose Imagine from the mode selector at the bottom of the chat panel. The experimental xgrok.experimentalImagineOAuth setting allows an active SuperGrok OAuth session to enable Imagine when no xAI API key is saved.
- Generate or edit images with Standard or Quality models, 1K/2K resolution, configurable aspect ratio, and up to four variations.
- Attach up to three PNG, JPEG, or WebP reference images for image editing and composition.
- Generate videos from text or animate a source image, with 1–15 second duration and supported 480p/720p/1080p choices depending on the selected model.
- Use multiple references with compatible video models; invalid model/input combinations are disabled.
- Review the estimated output cost before higher-cost requests. Video and multi-image requests require confirmation.
- Results are downloaded from xAI's temporary URL into private extension storage and can be opened, exported, or deleted from the Imagine gallery.
The experimental OAuth route is enabled by default and asks for confirmation before generation. If it fails, connect an xAI API key. Turn off xgrok.experimentalImagineOAuth in VS Code Settings to use only API-key authentication for Imagine.
Models
Choose your provider and model from the chat composer. Grok / xAI ★ appears first; OpenRouter is optional.
- Grok / xAI: the list includes built-in models and models discovered for your connected account. Add custom model IDs in Settings if needed. If discovery fails, the built-in list remains available; sending requests still requires internet access and account permissions.
- OpenRouter: browse models by family or start with Free Auto ⚡. Free choices are labeled separately from paid models, which show pricing when supplied by OpenRouter.
- Independent connections: switching providers or disconnecting one preserves the other connection and your conversations. If an OpenRouter model disappears, the selector falls back to Free Auto.
Workspace context
| Mode |
What it includes |
Best for |
| Min |
Conversation and manually attached files or folders |
Quick questions and maximum context control |
| Smart |
A focused project tree plus a small set of relevant files |
Everyday coding; recommended |
| Deep |
A broader tree and more key-file content |
Architecture reviews and larger tasks |
Automatic context excludes common credential-bearing files such as .env, private keys, and cloud credential files. Regular files can still be attached manually when appropriate.
Grok Chat can detect a project inside a subfolder of your workspace. File access stays within the opened workspace, and project context refreshes when you switch workspaces.
Code search and MCP servers
Ask Grok to find files, search text, or locate functions and other code symbols in your workspace. Searches respect local ignore files and exclude common credential files. You can cancel a search in progress.
MCP servers let you add tools from an external service. To connect a compatible Streamable HTTP MCP server, open MCP servers in panel Settings or run Grok Chat: Manage MCP Servers. Connections are opt-in, credentials stay in Secret Storage, and external tools require approval even in Full Access. External tools are unavailable in Plan Mode.
See the MCP and Grok Bot setup guide for advanced connection options and limits.
Grok Bot: connect your project through connectors
Grok Chat now supports connecting Grok Bot to your VS Code project through a custom MCP connector. Share selected files so Bot can explain code, propose changes for review in the editor, and request project tasks such as tests or builds. Configure the connection from the extension's visual Settings screen; no JSON editing or terminal commands are required.
Set up from extension Settings
- Open your project folder in VS Code and trust the workspace. Open Grok Chat, select Settings, and find MCP / Grok Bot → Grok Bot. You can also use Grok Chat: Manage Grok Bot Bridge from the Command Palette.
- Select Choose files… and pick the files Bot may read. Only selected files are shared; reading is the default permission.
- Optionally enable Let Bot propose changes and select the Tasks Bot may request. Each proposed change opens a diff for your approval; each task run also requires approval and may access the whole project.
- Select Grok Bot in the cloud and press Prepare connection. The extension prepares a temporary HTTPS address using Cloudflare and downloads its verified official component on first use. You can also use your own HTTPS connection. Only on this computer is for local MCP clients; a cloud Bot cannot reach that local address.
- When Your connection is ready appears, select Open Grok connectors. Create a custom connector in Grok and use the copy buttons in the extension to fill its MCP address and OAuth fields using the table below.
- Save and connect in Grok, then approve access in VS Code. Ask Bot to list the shared files and review one of them to check the connection.
Connector fields
| Field in the custom connector |
Value from the extension's Grok Bot screen |
| MCP address |
Connection address → Copy address |
| Client ID |
Client ID → Copy |
| Client secret |
Leave empty when using none (PKCE only) |
| Authorization endpoint |
Authorization endpoint → Copy |
| Token endpoint |
Token endpoint → Copy |
| Scopes |
workspace |
| Token authentication method |
none (PKCE only), recommended |
If you choose client_secret_post or client_secret_basic, use Copy secret for the client secret field instead. The manual Bearer key shown for other MCP clients is a separate credential. Your xAI and OpenRouter keys are not shared with the connector.
Keep VS Code open while Bot works. Test connection checks the address and authentication; activity in the setup screen shows when a client uses the connection. To change shared files or permissions, select Disconnect, update your choices, and prepare a new connection. Update the connector's address and OAuth credentials after restarting the connection. Disconnecting revokes its access; switching workspaces also stops it, and it never starts automatically when VS Code opens.
Custom connector availability depends on your Grok account; compatibility with every account is not guaranteed. Use Test connection during setup. See the detailed setup guide and OAuth field mapping for connection options and verification steps.
Permissions and user control
| Mode |
Reads |
Protected actions |
| Ask Before Changes |
Allowed automatically inside the workspace |
File changes and protected terminal, network, and commit actions require approval |
| Accept Edits |
Allowed automatically inside the workspace |
Workspace file writes and deletes are automatic in a trusted workspace; terminal, network, and commit actions still require approval |
| Full Workspace Access |
Allowed automatically inside the workspace |
Allowed workspace tools run automatically in a trusted workspace; terminal, network, and commit actions still require session-scoped approval |
All permission modes retain these controls:
- Paths are constrained to the open workspace.
- Absolute paths and traversal outside the workspace are rejected.
- Symlink and junction escapes are checked against canonical paths.
- Terminal commands are restricted by allowlist and denylist policies.
- Full Workspace Access requires VS Code Workspace Trust.
- A repository cannot grant itself Full Workspace Access through workspace settings.
Grok Chat cannot use its agent file tools to browse or change arbitrary locations outside the open workspace. Full Workspace Access is not an operating-system sandbox; enable it only for workspaces and tasks you trust.
Privacy
Grok Chat does not include advertising, analytics, or behavioral telemetry, and it does not sell personal data.
When you send a model request, the payload can include:
- Your prompt and conversation messages.
- Files or folders you attached.
- Project context produced by the selected context mode.
- Tool definitions and tool results required to complete the conversation.
Additional network activity occurs only for the feature being used:
- OAuth communicates with xAI authentication services.
- API chat communicates with the allowlisted
api.x.ai endpoint.
- OpenRouter model discovery and selected OpenRouter chat requests communicate directly with
https://openrouter.ai/api/v1; no project-owned proxy is used.
- Imagine sends prompts and explicitly attached reference images to the official xAI image/video endpoints. Generated media is downloaded from allowlisted xAI media hosts into extension-owned local storage.
- SuperGrok usage refresh performs a separate authenticated usage request.
- Local voice stays on the device.
- Opt-in xAI voice sends microphone audio to xAI for transcription while the microphone session is active.
OAuth tokens, xAI/OpenRouter API keys, and a dedicated voice key are persisted only through VS Code Secret Storage. Chat history stores the provider/model choice locally in VS Code workspace storage after secret redaction; embedded image data is not retained in persisted history. Temporary xAI voice recordings are deleted on a best-effort basis after transcription.
Imagine assets are stored separately under VS Code's extension global storage until deleted or exported. They are not written into the opened repository automatically. Imagine generation is metered by xAI and may consume API credits; cancellation after a request starts does not guarantee that xAI will not charge it.
Local history storage does not mean inference requests are zero-retention. According to xAI's API data policy, API inputs and outputs are normally retained encrypted for up to 30 days for abuse and security auditing and are not used for training without explicit permission. Teams enrolled in xAI Zero Data Retention have different behavior, but some server-side features such as stateful Responses, Files, and Collections are unavailable. Grok Chat continues to work with local history and Chat Completions when those features are unavailable.
Security
- OAuth authorization code flow with PKCE, state, and nonce validation.
- OS-backed VS Code Secret Storage for persisted credentials.
- Strict allowlist before authentication headers can be sent.
- Webview Content Security Policy and validated message types.
- Escaped model output; raw model HTML is not executed.
- Secret redaction in errors, history, and tool activity.
- Workspace Trust, path protection, and protected tool approval.
- Exact command/URL previews with session-scoped terminal, network, and commit approval.
- Patched PDF parsing with generated-code evaluation disabled and bounded resource use.
The microphone communicates its current state: ready, opening, listening, processing, or error.
- Local: private Windows speech recognition with system dictation fallback.
- xAI: opt-in cross-platform transcription; requires explicit consent, FFmpeg, and may be metered.
- Auto: selects local voice on Windows and xAI voice on macOS or Linux.
The phrase grok send can submit the final transcript hands-free. If a response is already running, the prompt joins the existing queue.
VS Code Chat
Use @grok in the built-in Chat view:
/explain
/fix
/tests
/refactor
Commands
| Command |
Purpose |
| Grok Chat: Open Grok Chat |
Focus the sidebar |
| Grok Chat: Open Grok Chat in Editor |
Open the complete chat in an editor tab |
| Grok Chat: Sign in with SuperGrok |
Start OAuth login |
| Grok Chat: Sign out |
Clear the session and local secrets |
| Grok Chat: Open Connect Screen |
Manage authentication |
| Grok Chat: Clear API Key only |
Remove only the stored API key |
| Grok Chat: Open VS Code Chat with @grok |
Open the built-in Chat view |
Requirements
- Visual Studio Code 1.104 or later, or a compatible host.
- A Grok account with applicable access, an xAI API key, or an OpenRouter account/key.
- An open workspace folder for project context and file tools.
- Microphone permission for voice input.
- FFmpeg only when using xAI voice capture.
Updates
Use the VS Code Extensions view to check for updates. The Marketplace badge above shows the published version; see the changelog for release notes.
FAQ
Is this an official xAI extension?
No. Grok Chat is independent and is not affiliated with, endorsed by, or sponsored by xAI.
Does OAuth use my API credits?
OAuth and API key mode are separate. OAuth uses access associated with the signed-in Grok account. API key mode uses api.x.ai and may consume paid API credits.
Can a project enable Full Workspace Access itself?
No. The extension accepts Full Workspace Access only from the user's global configuration and only after VS Code trusts the workspace.
Are my credentials stored in the project?
No. Persisted credentials use VS Code Secret Storage, not project files or normal workspace settings.
Why do some models appear or disappear?
Dynamic models reflect what the active account reports. The built-in fallback remains available when discovery cannot be completed, and custom model IDs can be added in Settings.
Are OpenRouter free models unlimited?
No. OpenRouter may offer free model variants and the Free Auto ⚡ route, but they remain subject to account quotas, provider rate limits, capacity, and catalog changes. Grok Chat labels free and paid choices separately; always review the selected model before sending a request.
Troubleshooting
Login does not complete
- Finish the browser authorization and return to VS Code.
- Retry Sign in with SuperGrok from the Command Palette.
- Check whether a firewall is blocking the temporary localhost OAuth callback.
API key validation fails
- Confirm the key belongs to xAI and has access to the chosen model.
- Check account credits and endpoint permissions.
- Save without validation only when you understand that the first real request may still fail.
- Open a folder rather than an empty VS Code window.
- Trust the workspace for protected actions.
- Check whether Ask Before Changes is waiting for an approval card.
- Allow microphone access for the VS Code host application in operating-system privacy settings.
- For xAI voice, install FFmpeg or configure its machine-specific path.
- Select a microphone device if automatic detection chooses the wrong input.
Try LocalMan
Looking for another way to improve your local development workflow? Discover LocalMan, a companion VS Code extension from An Unknown Artist. Give it a try and bring more of your everyday tools directly into the editor.
License
This project is source-available under the PolyForm Noncommercial License 1.0.0. You may use, modify, and distribute it for noncommercial purposes. Commercial use, sale, monetization, sublicensing, and transfer of rights are not permitted without prior written authorization.
Created by An Unknown Artist.
Questions or feedback? Contact the developer.