Grok Web Search
VS Code / GitHub Copilot extension that contributes a Language Model Tool for real-time web search via the xAI OpenAI-compatible Responses API, with the server-side web_search tool enabled.
Features
- Copilot Agent tool:
grok_web_search (reference as #grokSearch)
- Calls
POST {endpoint}/responses with tools: [{ "type": "web_search" }]
- Configurable endpoint (for local proxies / debugging), model, and Grok system instructions
- xAI API key stored in VS Code Secret Storage (not in
settings.json)
- Enhanced Chat tool-row UI via the
chatParticipantPrivate proposed API (dual-path; see below)
Requirements
- VS Code
^1.125.0 with GitHub Copilot Chat
- An xAI API key
Setup
- Install / open this extension in an Extension Development Host (
F5) or package and install the VSIX.
- Run command palette: Grok Search: Set xAI API Key
- (Optional) Adjust settings under Grok Search:
grokSearch.endpoint — default https://api.x.ai/v1
grokSearch.model — default grok-4.5
grokSearch.instructions — system prompt sent as Responses API instructions
- In Copilot Chat / Agent mode, enable Grok Web Search, or type
#grokSearch in the prompt.
When package.json declares enabledApiProposals: ["chatParticipantPrivate"] and the host enables that proposal for this extension, tool calls get richer Chat UI:
| Phase |
UI |
| Running |
Searching the web for \query`` |
| Completed (no citations) |
Searched the web for \query`` |
| Completed (with citations) |
Found N sources for \query`` + expandable source URIs |
Model-facing content is unchanged: answer text plus a ## Sources section when citations exist.
Dual-path / distribution
| Channel |
How |
| Development (F5) |
Proposal listed in package.json; launch config passes --enable-proposed-api=codehz.grok-search |
| VSIX / Insiders |
Keep enabledApiProposals, install VSIX, then start with --enable-proposed-api=codehz.grok-search or add the id to argv.json → enable-proposed-api |
| Marketplace / stable-only |
Remove enabledApiProposals before publish (or run npm run package:stable). Runtime then uses only stable invocationMessage / LanguageModelToolResult fields |
Proposed APIs are unstable and should not be published on the Marketplace while still proposed. See Using Proposed API.
Extension Settings
| Setting |
Default |
Description |
grokSearch.endpoint |
https://api.x.ai/v1 |
OpenAI-compatible base URL (include /v1). Requests go to {endpoint}/responses. |
grokSearch.model |
grok-4.5 |
Model id for the Responses API. |
grokSearch.instructions |
research assistant prompt |
Instructions guiding how Grok answers with web search. |
Commands
- Grok Search: Set xAI API Key — store API key in Secret Storage
- Grok Search: Clear xAI API Key — remove stored key
Development
npm install
npm run compile
# or: npm run watch
Press F5 to launch the Extension Development Host (proposal enabled via .vscode/launch.json).
npm test
Optional scripts:
npm run package:stable — temporary strip of enabledApiProposals, production build, then restore package.json
npm run dts:update — reminder about the local minimal proposed .d.ts (full upstream file needs extra proposals)
How it works
Copilot Agent
→ language model tool grok_web_search(query)
→ extension reads settings + SecretStorage API key
→ POST {endpoint}/responses
{ model, instructions, input, tools: [{ type: "web_search" }] }
→ returns answer text (+ Sources list when citations are present)
→ (optional) ExtendedLanguageModelToolResult for Chat tool-row UI
Known Issues
- First version only enables
web_search (no x_search / domain filters).
- Streaming progress is not surfaced in the Chat UI; the tool waits for a full response.
- Expandable
toolResultDetails for external https URIs depends on Chat UI support; if links do not render usefully, the result message and model-facing Sources section still work.
- Enhanced UI requires the proposed API to be enabled on the host; without it, keep dual-path stable builds (no
enabledApiProposals).
Release Notes
0.0.1
Initial release: Grok web search tool, configurable endpoint/model/instructions, SecretStorage API key commands.