> ## Documentation Index
> Fetch the complete documentation index at: https://www.truefoundry.com/llms.txt
> Use this file to discover all available pages before exploring further.

# VS Code

> Use TrueFoundry AI Gateway models in VS Code's built-in chat and agent mode through a Custom Endpoint, with no GitHub sign-in or Copilot plan required.

This guide shows how to use models from the TrueFoundry AI Gateway in [Visual Studio Code](https://code.visualstudio.com/)'s built-in chat. VS Code's **Custom Endpoint** provider lets you bring your own models to chat, agent mode, and the model picker, and it can call the gateway over the OpenAI Chat Completions, OpenAI Responses, or Anthropic Messages API.

You don't need a GitHub account or a Copilot plan to use chat with your own models. If your organization already uses GitHub Copilot, see [GitHub Copilot](https://www.truefoundry.com/docs/ai-gateway/github-copilot.md) for organization-level BYOK and the Copilot CLI.

## Prerequisites

1. A TrueFoundry account with at least one model provider configured. See the [Gateway quick start](https://www.truefoundry.com/docs/ai-gateway/quick-start.md).
2. A TrueFoundry API key. See [Authentication](https://www.truefoundry.com/docs/ai-gateway/authentication.md).
3. A recent stable release of [VS Code](https://code.visualstudio.com/download).

Agent mode sends tool definitions on every request, so pick models that support tool calling and streaming. A context window of at least 128K tokens is recommended.

## Add the gateway as a Custom Endpoint

**1. Get your gateway base URL and model IDs**

Open the AI Gateway playground and copy the base URL and model IDs from the unified code snippet. Model IDs use the `provider-account/model` format, for example `openai-main/gpt-4o`. See [how to find the gateway base URL](https://www.truefoundry.com/docs/ai-gateway/quick-start.md#gateway-base-url).

![TrueFoundry playground showing the unified code snippet with the base URL and model name](https://mintcdn.com/truefoundry/n3EuZuJ0K8wBFp1G/images/new-code-snippet.png?fit=max\&auto=format\&n=n3EuZuJ0K8wBFp1G\&q=85\&s=3634c2dc8c3565fd77ab896d3fd07ed9)

**2. Open Manage Language Models**

Open the Command Palette (`Cmd+Shift+P` on macOS, `Ctrl+Shift+P` on Windows and Linux) and run **Chat: Manage Language Models**.

**3. Add a Custom Endpoint**

Click **Add Models** and choose **Custom Endpoint**. When prompted, enter:

* **Name**: a name for the group of models, for example `TrueFoundry`.
* **API key**: your TrueFoundry API key. VS Code keeps it in its secret storage, and the config file only holds a reference to it.
* **API type**: **Chat Completions**. You can change the API type per model in the next step.

VS Code then opens `chatLanguageModels.json` with an empty model entry.

**4. Add your models**

Fill in the `models` array. Each model has its own `url`, which is the full gateway endpoint for its API type. Replace `{GATEWAY_BASE_URL}` with your gateway base URL and the model IDs with your own:

```json chatLanguageModels.json theme={"dark"}
[
  {
    "name": "TrueFoundry",
    "vendor": "customendpoint",
    "apiKey": "${input:chat.lm.secret.-1dd2b023}",
    "apiType": "chat-completions",
    "models": [
      {
        "id": "openai-main/gpt-4o",
        "name": "GPT-4o (TrueFoundry)",
        "url": "{GATEWAY_BASE_URL}/chat/completions",
        "toolCalling": true,
        "vision": true,
        "maxInputTokens": 111616,
        "maxOutputTokens": 16384,
        "requestHeaders": {
          "X-TFY-METADATA": "{\"application\":\"vscode\"}"
        }
      },
      {
        "id": "anthropic-main/claude-sonnet-4-5",
        "name": "Claude Sonnet 4.5 (TrueFoundry)",
        "url": "{GATEWAY_BASE_URL}/messages",
        "apiType": "messages",
        "toolCalling": true,
        "vision": true,
        "thinking": true,
        "maxInputTokens": 136000,
        "maxOutputTokens": 64000,
        "requestHeaders": {
          "X-TFY-METADATA": "{\"application\":\"vscode\"}"
        }
      },
      {
        "id": "openai-main/gpt-5",
        "name": "GPT-5 (TrueFoundry)",
        "url": "{GATEWAY_BASE_URL}/responses",
        "apiType": "responses",
        "toolCalling": true,
        "vision": true,
        "thinking": true,
        "maxInputTokens": 272000,
        "maxOutputTokens": 128000,
        "requestHeaders": {
          "X-TFY-METADATA": "{\"application\":\"vscode\"}"
        }
      }
    ]
  }
]
```

Keep the `apiKey` value VS Code generated for you. It points to the key you entered in the previous step.

**5. Pick a model in chat**

Save the file, open the Chat view, and click the model picker. Your models appear under the **TrueFoundry** group. Select one and send a prompt in agent mode.

If the models don't appear, run **Developer: Reload Window** from the Command Palette.

### Model fields

| Field | Description |
| - | - |
| `id` | The gateway model ID, sent as `model` in each request. |
| `name` | The label shown in the model picker. |
| `url` | Full endpoint URL: `{GATEWAY_BASE_URL}/chat/completions`, `{GATEWAY_BASE_URL}/responses`, or `{GATEWAY_BASE_URL}/messages`. |
| `apiType` | `chat-completions`, `responses`, or `messages`. A model inherits the group's `apiType` unless it sets its own. |
| `toolCalling` | Must be `true` for the model to be available in agent mode. |
| `vision` | Set to `true` if the model accepts images. |
| `thinking` | Set to `true` for reasoning models. |
| `maxInputTokens`, `maxOutputTokens` | Token limits. The picker shows their sum as the context size, so set them to add up to the model's context window. |
| `requestHeaders` | Extra headers sent with every request. Use `X-TFY-METADATA` to tag requests for [metadata logging](https://www.truefoundry.com/docs/ai-gateway/log-custom-metadata.md). VS Code strips reserved and forwarding headers. |

## Route utility tasks through the gateway

Besides the main chat model, VS Code runs built-in utility flows on a separate utility model. When the main model is a Custom Endpoint model, utility flows default to GitHub Copilot's models, so if you aren't signed in to GitHub, VS Code shows a **Set BYOK utility models** notification in the Chat view.

To send them through the gateway as well, click **Configure** on the notification, or add this to your user `settings.json`:

```json settings.json theme={"dark"}
{
  "chat.byokUtilityModelDefault": "mainAgent"
}
```

| Value | Behavior |
| - | - |
| `copilot` | Default. Utility tasks use GitHub Copilot's models, which requires a GitHub sign-in. |
| `mainAgent` | Utility tasks use the model you selected in chat. |
| `none` | Utility tasks are turned off. |

To use a specific model for utility tasks instead, set **Chat: Utility Model** (`chat.utilityModel`) or **Chat: Utility Small Model** (`chat.utilitySmallModel`). Either one takes precedence over `chat.byokUtilityModelDefault`.

## Verify in request logs

Open **Request Logs** in the TrueFoundry AI Gateway. Each model call is one request, so an agent turn that reads a file shows a tool-call request followed by the final answer. Requests from VS Code carry the `application: vscode` metadata from `requestHeaders`. Their user agent is `GitHubCopilotChat`, because VS Code's built-in chat runs on the bundled Copilot Chat extension even when you aren't signed in. See [Request logging](https://www.truefoundry.com/docs/ai-gateway/request-logging.md).

## Limitations

* **Inline completions stay on GitHub.** Ghost-text completions as you type can't use a Custom Endpoint. They need a GitHub sign-in and always run on GitHub's models.
* **Some workspace features need GitHub.** Semantic codebase search and embeddings aren't covered by Custom Endpoint models.
* **Copilot Business and Enterprise policies apply.** If you sign in with a Copilot Business or Enterprise account, your admin can turn off bring-your-own-key models, and **Custom Endpoint** won't be offered.

## Connect MCP Gateway servers

VS Code reads remote MCP servers from `.vscode/mcp.json` in your workspace or from your user profile. To add servers from the TrueFoundry MCP Gateway, follow the VS Code tab in [Connect MCP from your IDE](https://www.truefoundry.com/docs/ai-gateway/mcp/connect-mcp-from-ide.md). MCP works the same whichever model you pick, so you can combine gateway models and gateway MCP servers in one agent session.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.