Skip to content

feat: Better Custom Endpoint BYOK#325468

Open
GujjetiMokshith wants to merge 2 commits into
microsoft:mainfrom
GujjetiMokshith:feature/better-custom-endpoint-byok
Open

feat: Better Custom Endpoint BYOK#325468
GujjetiMokshith wants to merge 2 commits into
microsoft:mainfrom
GujjetiMokshith:feature/better-custom-endpoint-byok

Conversation

@GujjetiMokshith

@GujjetiMokshith GujjetiMokshith commented Jul 12, 2026

Copy link
Copy Markdown

Fixes #325237

Description

This PR enhances the Better Custom Endpoint BYOK (Bring Your Own Key) feature by adding more flexibility to how models are configured and mapped in VS Code.

Key Changes

  1. Global Configuration & Root URL Support:

    • The customendpoint schema now accepts a root-level url and a global settings block. This allows users to configure standard defaults once (such as vision, toolCalling, and token limits) which are inherited by all explicit or auto-fetched models.
  2. Auto-Fetch Integration:

    • Added autoFetch support (enabled by default when the models array is empty). It correctly merges dynamically fetched models from the endpoint with the global settings and specific explicit overrides provided by the user.
  3. Intelligent API Type Inference:

    • createOpenAIEndPoint now dynamically infers apiType (e.g., chat-completions, responses, messages) from explicitly provided URL paths (e.g., /v1/chat/completions or /v1/messages). This reduces boilerplate configuration, allowing users to simply paste their full endpoint URL.
  4. Rich Model Metadata:

    • Introduced configuration properties for description, icon, maxTokens, and credits (input, output, cacheRead).
    • Mapped description to the model picker tooltip and maxTokens to contextWindow.
    • Propagated model credits into VS Code's internal billing.token_prices.default API structure to appropriately track costs in the UI.

This makes the customendpoint provider significantly more powerful while reducing the repetitive configuration needed for OpenRouter-style or standard OpenAI-compatible endpoints.

Copilot AI review requested due to automatic review settings July 12, 2026 06:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds richer BYOK custom-endpoint configuration and model discovery.

Changes:

  • Adds auto-fetching and global/per-model overrides.
  • Adds descriptions, icons, token limits, and pricing metadata.
  • Expands the custom-endpoint configuration schema.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 11 comments.

File Description
customEndpointProvider.ts Implements discovery, merging, URL resolution, and capabilities.
byokProvider.ts Adds model metadata and pricing support.
package.json Expands the custom-endpoint schema and normalizes Unicode escapes.


let fetchedModels: OpenAICompatibleLanguageModelChatInformation<CustomEndpointModelProviderConfig>[] = [];
if (autoFetch && configuration?.url) {
fetchedModels = await super.getAllModels(silent, apiKey, configuration);
const autoFetch = configuration?.autoFetch ?? (!configuration?.models || configuration.models.length === 0);

let fetchedModels: OpenAICompatibleLanguageModelChatInformation<CustomEndpointModelProviderConfig>[] = [];
if (autoFetch && configuration?.url) {
Comment on lines +164 to +168
for (const modelConfig of explicitModels) {
const mergedConfig = { ...globalConfig, ...modelConfig } as CustomEndpointModelConfig;
models.push({
...byokKnownModelToAPIInfoWithEffort(this._name, mergedConfig.id, mergedConfig),
url: mergedConfig.url || configuration?.url || ''
Comment on lines +150 to +156
const explicitModels = configuration?.models || [];
const explicitIds = new Set(explicitModels.map(m => m.id));
const globalConfig = configuration?.global || {};

for (const model of fetchedModels) {
if (!explicitIds.has(model.id)) {
const mergedConfig = { ...globalConfig, id: model.id, name: model.name, url: configuration!.url! } as CustomEndpointModelConfig;
const mergedConfig = { ...globalConfig, ...modelConfig } as CustomEndpointModelConfig;
models.push({
...byokKnownModelToAPIInfoWithEffort(this._name, mergedConfig.id, mergedConfig),
url: mergedConfig.url || configuration?.url || ''
name: model.name,
maxInputTokens: modelConfiguration.maxInputTokens ?? model.maxInputTokens,
maxOutputTokens: modelConfiguration.maxOutputTokens ?? model.maxOutputTokens,
contextWindow: modelConfiguration.contextWindow ?? modelConfiguration.maxTokens,
Comment on lines +195 to +196
toolCalling: modelConfiguration.toolCalling ?? !!model.capabilities?.toolCalling ?? false,
vision: modelConfiguration.vision ?? !!model.capabilities?.imageInput ?? false,
inputCost: capabilities.credits?.input,
outputCost: capabilities.credits?.output,
cacheCost: capabilities.credits?.cacheRead,
...(capabilities.icon ? { icon: capabilities.icon } : {}) as any,
Comment on lines +142 to +146
const autoFetch = configuration?.autoFetch ?? (!configuration?.models || configuration.models.length === 0);

let fetchedModels: OpenAICompatibleLanguageModelChatInformation<CustomEndpointModelProviderConfig>[] = [];
if (autoFetch && configuration?.url) {
fetchedModels = await super.getAllModels(silent, apiKey, configuration);
reasoningEffortFormat?: 'chat-completions' | 'responses' | 'messages';
description?: string;
icon?: string;
maxTokens?: number;
@GujjetiMokshith

GujjetiMokshith commented Jul 12, 2026 via email

Copy link
Copy Markdown
Author

@GujjetiMokshith

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@hzmm79668-cloud hzmm79668-cloud left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better Custom Endpoint BYOK

5 participants