← Blog

How to Integrate Claude in VS Code: A Step-by-Step Guide

2026-09-09 · 5 min read · SubToAPI Team

There are three practical ways to integrate Claude in VS Code: install an official or third-party AI extension that connects to Claude, run Claude Code from the integrated terminal, or wire your own commands to a Claude-compatible API endpoint using VS Code's tasks and extensions API. Which one you pick depends on whether you want a chat sidebar, inline code completions, or programmatic access from scripts and tasks you already run inside the editor.

This guide walks through each approach with working setup steps, so you can pick the one that matches how your team actually works instead of installing three extensions and figuring it out by trial and error.

Option 1: Official Claude extensions for VS Code

Anthropic and several third-party maintainers publish VS Code extensions that connect to Claude for chat, inline suggestions, and code review. The setup pattern is consistent across most of them:

  1. Open the Extensions view (Cmd/Ctrl+Shift+X) and search for the Claude extension you want.
  2. Install it and reload the window.
  3. Open the extension's settings panel and paste in your API key.
  4. Reload again if the sidebar doesn't appear automatically.

This is the fastest path if you just want a chat panel next to your code. The tradeoff is that most of these extensions expect a raw Anthropic API key with usage billed per token, which is a different cost model than a Claude subscription and doesn't give you per-project usage breakdowns out of the box.

Option 2: Claude Code from the integrated terminal

If you already use Claude Code as a CLI tool, you don't need a dedicated extension — VS Code's integrated terminal runs it natively. Open a terminal (` Ctrl+ ``) inside your workspace and run Claude Code the same way you would outside the editor. It reads your open workspace as context, and you can pipe file contents or diffs directly into it:

git diff | claude "review this diff for bugs before I commit"

You can also bind this to a VS Code task so it runs with a keyboard shortcut instead of typing the command each time. Add this to .vscode/tasks.json:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Claude: Review Changes",
      "type": "shell",
      "command": "git diff | claude 'review for bugs and style issues'",
      "problemMatcher": []
    }
  ]
}

Bind it to a shortcut in keybindings.json and you have a one-key code review loop without leaving the editor.

Option 3: Direct API integration for custom workflows

If you want more control — custom prompts, structured JSON output, or Claude wired into a build task rather than a chat window — the cleanest route is calling the API directly from a small script or extension task. This is also the option to reach for if your team is already paying for Claude access and wants that same access exposed as a normal HTTPS API instead of juggling separate API keys and billing.

That's the gap SubToAPI fills: it turns your existing Claude access into a standard sub_live_... API key you can call from anywhere, including a VS Code task, without setting up separate token-based billing. You get streaming, tool use, and usage metadata in one dashboard, with per-teammate seats if more than one person on the team needs a key.

A minimal example — a Node script triggered from a VS Code task that sends the current file's contents to Claude for review:

const fs = require("fs");

async function reviewFile(path) {
  const code = fs.readFileSync(path, "utf8");

  const response = await fetch("https://api.subtoapi.app/v1/messages", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${process.env.SUBTOAPI_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      model: "claude-opus-4",
      max_tokens: 1024,
      messages: [
        { role: "user", content: `Review this file for bugs:\n\n${code}` },
      ],
    }),
  });

  const data = await response.json();
  console.log(data.content[0].text);
}

reviewFile(process.argv[2]);

Wire that into tasks.json the same way as the CLI example above, and you have a Claude-powered review step that runs on your account's existing access, billed under your SubToAPI plan instead of per-token API pricing. Setup takes about five minutes — grab a key after signing up at /signup, check /docs/quickstart for the full request format, and see /docs/messages for message structure details.

Streaming and tool use inside VS Code tasks

For longer completions, streaming responses back into an output channel instead of waiting for the full response feels much closer to a native extension. The API supports server-sent event streaming — see /docs/streaming for the format — so you can pipe tokens into a VS Code output panel as they arrive rather than blocking on the full response.

If your workflow needs Claude to call functions — running a linter, querying a local database, fetching a file — tool use lets you define those functions once and let Claude decide when to call them mid-conversation. That's documented at /docs/tools, and it's the same mechanism you'd use whether you're calling Claude from a VS Code task, a CI pipeline, or a standalone script.

Choosing the right approach

None of these are mutually exclusive. Plenty of teams run an extension for daily chat and a custom API task for CI-style checks that need structured JSON output an extension can't easily produce.

questions

Do I need a separate Anthropic API key to use Claude in VS Code? Not necessarily. Extensions typically expect a raw Anthropic API key billed per token, but if you already have Claude access, a service like SubToAPI exposes that access as a standard API key you can use in scripts and tasks instead.

Can Claude read my whole VS Code workspace automatically? Most chat extensions and Claude Code read open files and the current workspace context. Direct API calls only see what you explicitly send in the request, so you control exactly what context gets included.

Is streaming supported when calling Claude from a VS Code task? Yes, if you're calling the API directly. Server-sent events let you stream tokens into a terminal or output panel as they generate instead of waiting for the full response — see /docs/streaming for the format.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →