Set Up an AI Extension in VS Code: 4 Settings and a Fix Table (2026)
Using AI to write code in VS Code takes two steps: install an extension that supports a custom endpoint, then fill in four settings correctly: API type, base URL, API key and model name. If all four are right, the extension works. When it errors out, the cause is almost always one of these four.
This article covers the general approach to configuring a VS Code AI extension and is not tied to any one extension. Menu locations and field names differ between extensions, so treat the names below as approximate and check each extension's own documentation.
What kinds of AI extensions does VS Code have?
Sort them by type first, or you may end up installing several without knowing what each one does.
| Type | What it does | Custom endpoints common? |
|---|---|---|
| Completion | Inline suggestions at the cursor | Depends on the extension |
| Chat and agent | Sidebar chat that can read files, edit files and run commands | Common, for example Cline, Roo Code, Kilo Code |
| Vendor-bound | Tied to one vendor's account and subscription | Usually not supported; check the official docs |
If you want to choose your own model and control your own spending, look in the second group for extensions that let you enter a base URL and a key. For how the three kinds of tools divide the work in daily development, see How to choose an AI coding tool: CLI, editor extension or AI IDE.
Which four settings do you need to fill in?
Whatever the extension's UI looks like, these four settings are behind it:
- API type: the two common ones are the OpenAI-compatible format and the Anthropic format. The extension may call this Provider, API Protocol or something similar. Pick the wrong type and neither the request path nor the request body will match.
- Base URL: the entry address your service provider gives you. Some extensions require it to end in
/v1, others append that themselves. Check the extension's docs and your provider's docs. - API key: the key you create in the provider's console. Enter it only in the extension's settings. Do not write it into project files, and never commit it to a repository.
- Model name: it must match a name the provider supports exactly, including case and hyphens. Use the provider's model list as the source of truth.
How do you configure it step by step?
- Search the extension marketplace, install the extension, and confirm it supports custom endpoints. Look in its description or docs for phrases like "OpenAI Compatible" or "Custom Base URL".
- Open the extension's own settings page and find the model provider (Provider) option.
- Choose the API type. If your provider supports both formats, pick the one the extension supports more completely.
- Enter the base URL and API key.
- Enter the model name. Some extensions can fetch a model list; others need you to type it in.
- Send the shortest possible message in the chat box, such as "reply with just ok", to confirm the connection works before asking it to edit code.
If you want different models for different tasks, see How to use Roo Code configuration profiles, which covers binding models and endpoints per mode and confirming where requests actually go. For the same kind of configuration in command-line tools, see Custom API endpoints for Claude Code, Codex and OpenCode.
What if you have no overseas account or credit card?
Using an overseas vendor's API directly usually means dealing with account sign-up, payment methods and supported regions, all of which are governed by each vendor's official policy. Another route is an aggregating gateway, where one base URL gives you access to many models.
AGI Plan is one such service, and it is a commercial partner of cdnping. It is billed monthly, paid in RMB, and needs no overseas credit card. It is compatible with both the OpenAI and Anthropic API formats, so either "API type" choice above works. Any extension that accepts a base URL and an API key, including Cline, Roo Code and Kilo Code, can connect to it. Two caveats: the site states clearly that it is not an officially authorized channel, and some models are marked "overseas only", so check agiplan.dev/models for specifics. The setup guide is at agiplan.dev/startup: register with an email verification code, pick a plan and create a key, then change one configuration entry.
Whether to use a gateway depends on your needs. When deciding, compare options along the six dimensions in How to choose an LLM API.
It is configured but still errors. How do you check each item?
Work through the list below in order. It is usually faster than reinstalling the extension over and over.
| Symptom | Check first |
|---|---|
| 401 / authentication failed | Whether the key was copied in full, with no extra spaces or line breaks; whether the key has been deleted or has expired |
| 404 / path not found | Whether the base URL has an extra or missing /v1; whether the API type is wrong |
| Model does not exist | Spelling of the model name; whether it is a name from the provider's list |
| 429 | Quota used up or too many requests; check usage in the provider's console and retry later |
| Timeout or endless spinner | A network problem or a server-side fluctuation; see below |
| Chat works but it cannot edit files | Whether the extension's agent mode is on and whether the chosen model supports tool calling; check the extension's docs |
The exact meaning of each error code is defined in the provider's docs; the table only lists common directions to investigate.
For timeouts, first work out whether the problem is your own network or the server. You can use the cdnping online speed test to measure first-connection and round-trip times to each API endpoint, then look at that service's recent probe results on the API status page. For what causes latency and how to judge it, see How to read latency when accessing AI APIs from China.
What else should you watch for once it is running?
- Try it first in a small project or a new branch, and with agent-type extensions make sure you can see the diff before files are changed, then decide whether to accept it.
- Keep an eye on usage. Agents read files repeatedly and make many calls over several turns, so they consume much more than plain chat. For estimating costs, see How much does AI coding cost per month: three tiers by intensity.
- Use each key in only one place, so that if one leaks you can delete and recreate just that one.
Next step
If you just want to get something running, pick an extension that supports custom endpoints, fill in the four settings, and verify with "reply with just ok". If you need an endpoint that can be paid for from China and entered directly into an extension, see the setup guide at agiplan.dev/startup. If you already have a provider, go straight to the troubleshooting table above.