How to Configure Custom LLM Providers in Continue: A Complete Guide
You configure custom LLM providers in Continue by editing the .continue/config.json file to add entries under the modelProviders array, following the LLMConfigSchema defined in packages/openai-adapters/src/types.ts, which the constructLlmApi factory uses at runtime to instantiate the appropriate API client.
The Continue open-source AI code assistant (continuedev/continue) ships with a flexible LLM-routing layer that lets you integrate any OpenAI-compatible API endpoint. By modifying your local configuration file, you can add self-hosted or third-party providers without touching the source code, leveraging the same validation schema that powers the built-in options.
Understanding the Provider Schema
The canonical structure for every provider entry is defined in packages/openai-adapters/src/types.ts at line 258. This TypeScript discriminated union specifies the exact fields required to validate a custom provider:
provider– A unique string identifier (e.g.,"openai","anthropic","vllm").apiBase– The base URL for the API endpoint (optional for built-in providers).apiKeyEnv– The name of the environment variable containing the API key.model– The default model identifier for completions.
Any object you add to your configuration must satisfy this LLMConfigSchema, which Continue uses for type safety and runtime validation.
Runtime Instantiation with constructLlmApi
When Continue loads your configuration, it invokes the constructLlmApi factory function located in packages/openai-adapters/src/index.ts at line 84. This function matches the provider key against the schema and returns a BaseLlmApi implementation configured to communicate with your specified endpoint. The factory abstracts the HTTP client setup, authentication header injection, and request formatting, allowing you to switch providers by changing JSON values rather than code.
Configure Custom LLM Providers in config.json
To configure custom LLM providers in Continue, edit the .continue/config.json file in your home directory or workspace root. Add a new object under the top-level modelProviders array using the schema fields described above.
Here is a complete example adding a self-hosted vLLM endpoint:
{
"modelProviders": [
{
"provider": "vllm",
"apiBase": "http://localhost:8000/v1",
"apiKeyEnv": "VLLM_API_KEY",
"model": "gpt-oss-120b"
}
]
}
If your server requires authentication, export the key in your shell or add it to a .env file in the same directory as your config:
export VLLM_API_KEY="your-secret-key"
Omit the apiKeyEnv field entirely if the endpoint is open.
Selecting Providers in the UI
After saving the configuration, open the Add New Model dialog under Settings → LLMs. Continue generates the provider list by iterating over the LLMConfigSchema and your custom entries, as implemented in gui/src/pages/AddNewModel/configs/providers.ts. Your custom provider appears immediately alongside built-in options like OpenAI and Anthropic, requiring no restart.
Programmatic Configuration with the SDK
If you embed Continue via its TypeScript SDK, you can pass the provider configuration programmatically. The SDK accepts the same modelProviders array defined in packages/continue-sdk/typescript/src/Continue.ts at line 72:
import { Continue } from "continue-sdk";
const continueClient = await Continue.initialize({
modelProviders: [
{
provider: "ollama",
apiBase": "http://localhost:11434/api",
model": "llama3.1"
}
]
});
This approach follows the identical validation rules as the JSON configuration.
Verifying the Configuration
Test your setup by opening a new chat session. The LLM Log panel displays the outgoing request to your apiBase URL and the response status. Schema validation errors—such as missing required fields—surface as friendly messages in the UI before any network request is attempted, preventing silent failures.
Summary
- Schema Location:
packages/openai-adapters/src/types.tsdefinesLLMConfigSchemaat line 258, specifying required fields likeprovider,apiBase, andmodel. - Factory Function:
constructLlmApiinpackages/openai-adapters/src/index.ts(line 84) instantiates the API client from your JSON configuration. - Config File: Edit
.continue/config.jsonto add custom entries undermodelProviders. - Environment Variables: Use
apiKeyEnvto reference secrets without hardcoding them. - UI Integration: Custom providers appear automatically in the model picker without restarting the IDE.
Frequently Asked Questions
Where is the Continue configuration file located?
Continue reads from .continue/config.json in your workspace root, falling back to ~/.continue/config.json for global settings. The file uses standard JSON syntax and supports comments for documentation purposes.
Do I need to restart VS Code after adding a custom provider?
No. Continue watches the configuration file for changes and hot-reloads the modelProviders array. New providers appear immediately in the Settings → LLMs dialog and are available for chat sessions without an IDE restart.
Can I use local models like Ollama with Continue?
Yes. Specify "provider": "ollama" and set apiBase to http://localhost:11434/api (or your custom port). Continue treats local endpoints identically to cloud APIs, routing requests through the same constructLlmApi factory.
What happens if my API key is missing?
If you define apiKeyEnv but the environment variable is unset, Continue catches this during schema validation and displays a clear error message in the UI. The request never reaches the network layer, preventing authentication failures against the remote endpoint.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →