English Arabic 简体中文 繁體中文 Français Deutsch 日本語 한국어 Português Русский Español
No other translations yet

How to Use Claude Code in VS Code: LLM Backend, Model Selection, and Agent Sandbox

How to Use Claude Code in VS Code: LLM Backend, Model Selection, and Agent Sandbox

Claude Code lands in VS Code as a full coding agent in the sidebar — not a completion tool, but a multi-step problem-solver that reads your project, edits files, and runs commands. The VS Code extension shares its engine with the CLI, so slash commands, CLAUDE.md awareness, and MCP tool calls all work the same way you’d use them in the terminal. What makes the setup worth understanding is the backend layer: every inference call goes through an endpoint you control, and routing that endpoint to Novita AI opens up access to Claude models plus a broader catalog of open-source coding alternatives — at pricing that makes high-volume agent tasks practical.

What Claude Code Does in VS Code

The Claude Code VS Code extension is a sidebar panel, not an inline autocomplete engine. Open it, describe a task, and Claude Code executes multi-step work: reading files, writing changes, running shell commands, and waiting for your approval on diffs before applying them. The distinction matters because developers often search for “claude code vs code” expecting a Copilot-style experience — single-line suggestions that complete as you type. That’s not what this is. For completions, other tools fill that role. Claude Code in VS Code is for tasks: write tests for this module, refactor the auth handler, explain why this query is slow, create a pull request with today’s changes.

Concrete capabilities inside the extension:

  • Multi-file edits with inline diffs. Claude Code proposes changes across multiple files and shows diffs you can accept or reject without leaving the editor.
  • Slash commands. /compact, /clear, /init, /memory, and custom slash commands you’ve defined all work identically to the CLI.
  • Context pinning. The # prefix attaches specific files, symbols, or folders to a request. Typing #src/auth/handler.ts fix the race condition gives Claude Code the right context immediately.
  • CLAUDE.md awareness. Project coding standards, architecture notes, preferred libraries — anything in CLAUDE.md loads at session start. You write it once; the agent respects it every session.
  • MCP tool calls. MCP servers registered in your Claude Code config are available inside the extension panel.

What the extension does not do: replace your existing editor keybindings, modify your syntax highlighting, or add per-keystroke completions. It’s an agent interface layered over your normal VS Code workflow.

How to Add Claude Code to VS Code

Open the Extensions panel (Ctrl+Shift+X on Windows/Linux, Cmd+Shift+X on macOS). Search Claude Code and look for the publisher Anthropic. Click Install.

If you prefer the command line:

code --install-extension Anthropic.claude-code

After installation, the Claude icon appears in the Activity Bar on the left side of VS Code. Click it to open the agent panel.

First-launch authentication. The extension prompts you to sign in on first open. Two paths:

  • Anthropic account: Browser OAuth flow — works if you have an Anthropic Console API key or an active Claude subscription.
  • Novita AI API key: Set ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN in your shell environment before launching VS Code from that terminal. The extension reads these at startup and bypasses Anthropic login entirely. Details in the next section.

VS Code updates the extension automatically in the background. You don’t need to track versions manually.

How the LLM API Backend Works

Understanding the three-layer architecture makes every configuration decision clearer:

  1. UI layer: The VS Code extension (or the CLI, or the desktop app — they’re interchangeable surfaces).
  2. Agent logic layer: The Claude Code engine — tool definitions, session management, file reading, command execution.
  3. LLM API layer: The inference endpoint that handles every language model call.

By default, the LLM API layer points to api.anthropic.com. Claude Code sends requests using the Anthropic Messages API format. The critical detail: ANTHROPIC_BASE_URL redirects all of those requests to any Anthropic-compatible endpoint. Novita AI exposes the same Messages API format at https://api.novita.ai/anthropic, so the switch is transparent to the agent logic layer — Claude Code doesn’t know or care whether the response came from Anthropic’s servers or Novita’s.

Three more environment variables complete the configuration:

  • ANTHROPIC_AUTH_TOKEN — your API key for the chosen provider.
  • ANTHROPIC_MODEL — the model ID to use for primary tasks.
  • ANTHROPIC_SMALL_FAST_MODEL — the model ID for quick background tasks like summarization and context compression.

Set these before launching VS Code, and the extension inherits them from the shell environment.

Connecting Claude Code to Novita AI

Step 1: Get a Novita AI API key

Sign up at novita.ai and navigate to the Key Management page. Generate a new key and copy it immediately — it won’t be shown again.

Step 2: Set environment variables

On macOS or Linux, export the variables in your terminal before launching VS Code:

export ANTHROPIC_BASE_URL="https://api.novita.ai/anthropic"
export ANTHROPIC_AUTH_TOKEN="<your-novita-api-key>"
export ANTHROPIC_MODEL="zai-org/glm-4.6"
export ANTHROPIC_SMALL_FAST_MODEL="zai-org/glm-4.6"

On Windows (Command Prompt):

set ANTHROPIC_BASE_URL=https://api.novita.ai/anthropic
set ANTHROPIC_AUTH_TOKEN=<your-novita-api-key>
set ANTHROPIC_MODEL=zai-org/glm-4.6
set ANTHROPIC_SMALL_FAST_MODEL=zai-org/glm-4.6

Then launch VS Code from that same terminal session:

code .

Step 3: Verify the connection

Open the Claude Code panel and send a short test message. If the extension returns a response, the routing is working. You’re now billed through Novita AI — your Anthropic account is not charged.

To make the configuration permanent, add the exports to your shell profile (~/.zshrc, ~/.bashrc, or equivalent) or use a project-level .env file managed by direnv for per-project model switching.

Open-Source Models That Match Closed-Source Coding Performance

Once you’re routing through Novita AI, you’re not limited to Claude models. Novita’s LLM catalog includes open-source coding models that compete directly with closed-source alternatives on the benchmarks that matter for agentic coding tasks.

GLM-4.6 from Zhiyu AI is a practical example. It carries a 200K token context window and achieves a 48.6% win rate against Claude Sonnet 4 in real-world coding evaluations. For agentic workflows where long context matters (debugging across large codebases, reading full test suites), that context window is a practical advantage, not just a spec sheet number. The Novita model ID is zai-org/glm-4.6.

Other models on Novita’s platform worth evaluating for coding workloads include DeepSeek R1 and Qwen 3 Coder, both of which have demonstrated competitive performance on code generation and instruction-following benchmarks. The same ANTHROPIC_MODEL environment variable switches between them — no reinstall, no new integration.

The cost argument for open-source: teams running Claude Code at scale — large numbers of agent runs in CI pipelines, multi-developer setups with shared Novita API keys, or long agentic sessions that consume significant tokens — find that open-source models at Novita’s pricing create meaningful room in the infrastructure budget. A model that performs at 90% of Claude Sonnet 4’s level at 40% of the cost changes the economics of running agents continuously.

Novita Agent Sandbox as the Execution Environment

Claude Code in VS Code can run shell commands locally — it will build your project, run tests, install packages, and create files on your machine. For most day-to-day tasks, that’s fine. But some agentic tasks are better handled in isolated compute: heavy test suites that block your machine, build steps that install system packages, commands that modify system configuration, or parallel agent runs where you need reproducibility.

Novita Agent Sandbox provides cloud execution environments purpose-built for this use case. A sandbox is a microVM that starts in milliseconds, runs code in isolation from your host system, and terminates cleanly when the task is done. No leftover state, no impact on your local environment, no waiting for your machine’s CPU to recover.

For Claude Code users, the practical workflow is: route inference to Novita AI’s LLM endpoint for language model calls, and for heavy execution tasks — builds, test runs, code evaluation — spin up an Agent Sandbox instance via the Novita Agent Sandbox API. The two services share authentication (same Novita API key), so there’s no separate credential management.

Teams building automated code review pipelines or CI-integrated Claude Code agents find this combination particularly useful: the LLM cost stays predictable on Novita’s per-token pricing, and the compute cost stays predictable on Agent Sandbox’s per-second billing.

Daily VS Code Workflow Tips

A few patterns that make the extension practical rather than a curiosity:

Start new projects with /init. Running /init in a new repository generates a CLAUDE.md starter file. It’s the most efficient way to tell Claude Code about your project’s conventions before it starts editing.

Pin context with #. Instead of describing what file to look at, type #filename to attach it directly. For refactoring work, #src/components/Button.tsx update the onClick handler to use the new event type is faster than “look at the Button component and…”

Use /compact proactively. In a long session, Claude Code accumulates context. /compact summarizes the conversation and reduces token overhead. Run it after a major task is done, before starting the next one.

Accept or reject diffs inline. Before Claude Code edits a file, it shows the diff in the panel. You don’t have to accept every change — reject partial diffs and ask for a revised approach. Treating every response as a starting point rather than a final answer produces better results.

Separate project instructions from session instructions. CLAUDE.md is for stable project context (build commands, architecture, code style). Temporary instructions for the current task belong in the session prompt. Don’t clutter CLAUDE.md with single-task guidance.

FAQ

Where is the Claude Code VS Code extension documentation?

The official extension documentation is maintained by Anthropic at claude.ai/code. Release notes and changelog are visible in the VS Code Extensions panel under the Claude Code listing.

Is the Claude Code VS Code extension free?

The extension itself is free to install. Usage costs depend on your backend configuration. With an Anthropic account, you pay per token or use subscription credits. With Novita AI routing, you pay Novita’s per-token rate and no Anthropic charges apply. New Novita accounts receive free trial credits on sign-up.

Can I use the VS Code extension and the Claude Code CLI at the same time?

Yes, but they run as separate sessions. The VS Code extension does not share a live session with an open CLI instance. If you need session continuity between the two, use claude -c in the CLI to resume the most recent session from that directory.

What’s the difference between Claude Code and Cline in VS Code?

Cline is a VS Code extension that routes agent work through any OpenAI-compatible backend — it gives you maximum provider flexibility but requires more configuration. Claude Code is Anthropic’s own agent with a tightly integrated tool set. The ANTHROPIC_BASE_URL redirect gives Claude Code similar backend flexibility in practice. If you already have Novita AI set up for Claude Code, you don’t need a separate Cline installation to access Novita’s model catalog.

Can I use different models for different projects?

Yes. Use direnv with project-level .env files to scope ANTHROPIC_MODEL to a specific directory. When you open that project in VS Code from a terminal with direnv active, the extension inherits the project-specific model setting.

Novita AI is an AI cloud platform that offers developers an easy way to deploy AI models using our simple API, while also providing affordable and reliable GPU cloud for building and scaling.