# Configure GitHub Copilot in VS Code (/docs/develop/developer-tools/github-copilot)















Use GitHub Copilot's Bring Your Own Key (BYOK) support to connect VS Code to a model through the BSQAI API.

## Prepare the connection [#prepare-the-connection]

Before you add the model, prepare the following:

* VS Code 1.142 or later, with GitHub Copilot Chat enabled. The screenshots use VS Code 1.143.1.
* Your deployment's HTTPS API URL, such as `https://api.<platform-domain>/v1/responses`.
* A BSQAI API key with `chat.message.create`. Include `tenant.read` if you use the key to list models.
* A model name from `/v1/models` that your key's owner can invoke. Choose a model with tool calling enabled.
* The model's input and output token limits, supplied by your platform operator.

For a new key, follow [Create and use an API key](/docs/develop/use-local-models-via-api#option-2-create-and-use-an-api-key).
If the model is absent from `/v1/models`, ask your Tenant Administrator to grant [model access](/docs/use/portal/ai-hub#model-access).

VS Code supports BYOK without a GitHub account or Copilot plan.
For an organization-managed setup, confirm that your administrator permits custom endpoints before you continue.

## Add the Custom Endpoint provider [#add-the-custom-endpoint-provider]

Add the provider through the VS Code prompts:

1. Open the Command Palette and run **Chat: Manage Language Models**.

   <img alt="VS Code Command Palette with Chat: Manage Language Models selected" src="__img0" />

2. Select **Add Models**, then **Custom Endpoint**.

   <img alt="Add Models menu with Custom Endpoint selected" src="__img1" />

3. In **Group Name**, enter `BullSequana AI` and press Enter.

   <img alt="Group Name prompt with BullSequana AI entered" src="__img2" />

4. Enter your BSQAI API key in the masked **API Key** prompt and press Enter.

   <img alt="BullSequana AI API Key prompt with the key masked" src="__img3" />

5. Select **Responses** as the API type.

   <img alt="API Type prompt with Responses selected" src="__img4" />

6. In the `chatLanguageModels.json` file that VS Code opens, keep the generated provider entry and its `apiKey` line.

   <img alt="chatLanguageModels.json with a generated secret reference and stateless Responses settings" src="__img5" />

The configuration screenshot uses example token limits and enables image input.
Use your deployed model's limits and capabilities instead of copying those values.
The generated `apiKey` reference belongs to your VS Code profile. Do not copy the screenshot's reference.

## Configure stateless Responses requests [#configure-stateless-responses-requests]

In your provider entry, keep `apiType` set to `"responses"`.
Inside `models`, set the following fields in each BullSequana AI model entry.
This fragment belongs inside a model entry, not in place of the complete configuration file.

```json
{
	"id": "<model-name-from-/v1/models>",
	"url": "https://api.<platform-domain>/v1/responses",
	"toolCalling": true,
	"streaming": true,
	"statefulResponses": false,
	"zeroDataRetentionEnabled": true,
	"requestHeaders": {
		"X-Api-Key": "${apiKey}"
	}
}
```

Before you save, complete the model entry:

1. Replace `id` with the model name from `/v1/models`.
2. Replace `url` with your deployment's full `/v1/responses` URL. Keep `url` at model level, not at provider level.
3. Set `name` to the label you want in the model picker.
4. Set `maxInputTokens` and `maxOutputTokens` to your deployed model's limits.
5. Set `vision` to `true` only if the model accepts image input. Otherwise, set it to `false`.
6. If the model entry has an `apiType` override, remove it or set it to `"responses"`.
7. Save `chatLanguageModels.json`.

Keep `${apiKey}` unchanged in `requestHeaders`. VS Code substitutes the key from its secret storage.
Do not put the key itself in the JSON file or a shared workspace.

Keep both `statefulResponses: false` and `zeroDataRetentionEnabled: true`.
Copilot then resends the conversation with `store: false`, without `previous_response_id`.
The BSQAI API does not restore earlier turns from `previous_response_id`, so Copilot must resend the conversation.
These settings do not disable platform logs, usage records, or Copilot's local chat history.

## Verify a file tool call [#verify-a-file-tool-call]

Use a folder with no private files for the check:

1. Create a folder containing one file named `fixture.txt` with this content:

   ```text
   BSQAI_COPILOT_FILE_OK
   ```

2. Open that folder in VS Code.

3. Start a new Copilot chat in **Agent** mode.

4. Select your BullSequana AI model from the model picker.

5. Send this prompt:

   > Read fixture.txt with a file tool and quote its contents. Do not modify any files.

If VS Code asks for permission, approve only the file read.
The chat must show a file-read tool action and an answer containing `BSQAI_COPILOT_FILE_OK`.
An answer without a visible tool action does not verify the tool call.

In the same chat, send a second prompt:

> Read fixture.txt again with a file tool and tell me whether its contents changed. Do not modify any files.

Require a second file-read action and a completed answer without `user_message_missing`.
After any configuration change, start a new chat instead of reusing a conversation that began in stateful mode.

## Resolve setup failures [#resolve-setup-failures]

### Restore an unavailable model [#restore-an-unavailable-model]

If the model does not appear, run **Developer: Reload Window** and select the model again.

If Copilot reports that it cannot obtain a Copilot token, use a Copilot-enabled account.
For an organization-managed account, ask your administrator to check the BYOK policy.
For a personal setup not subject to organization policy, sign out of GitHub through VS Code's **Accounts** menu.
Then reload the window and start a new chat.

For a personal account, signing out restores provider registration in VS Code 1.143.1 when the account cannot obtain a Copilot token.
The API connection still needs the file-read check.
Do not sign out to work around an organization's BYOK policy.

### Fix a tool-result continuation error [#fix-a-tool-result-continuation-error]

If a tool-result continuation fails with `user_message_missing`, check both stateless settings in the selected model entry.
Set `statefulResponses` to `false` and `zeroDataRetentionEnabled` to `true`.
Save the file.
Start a new chat before you repeat the file-read check.

### Report an invalid tool definition [#report-an-invalid-tool-definition]

If `invalid_tool_definition` names `tools[N].name`, ask your platform operator to check the deployed API's tool-name limit.
Some VS Code extensions generate long tool names.
Report the VS Code version, the tool name, the error code, and `param`.
Do not send your API key or a workspace transcript.

### Check an empty reply [#check-an-empty-reply]

If the reply is empty, check that the selected model uses `apiType: "responses"` and `streaming: true`.
Then start a new chat and repeat the file-read check.

## Related pages [#related-pages]

* [Developer tools](/docs/develop/developer-tools)
* [Use local models via API](/docs/develop/use-local-models-via-api)
* [VS Code custom endpoint configuration](https://code.visualstudio.com/docs/copilot/customization/language-models#_add-a-custom-endpoint-model)
* [VS Code stateless Responses configuration](https://code.visualstudio.com/docs/copilot/customization/language-models#_stateful-responses-api-endpoints)
