English
[!IMPORTANT]
This is not affiliated with, officially maintained by, or endorsed by B.AI (b.ai).
Integrate B.AI models into GitHub Copilot Chat as a VS Code extension.
B.AI is an AI API gateway providing access to 38 models (OpenAI GPT-5.x, Anthropic Claude, Google Gemini, DeepSeek, Qwen, Kimi, GLM, MiniMax, etc.) through OpenAI-compatible (/v1/chat/completions) and Anthropic-compatible (/v1/messages) endpoints. This extension registers a LanguageModelChatProvider so you can use all of them directly in Copilot Chat.
Usage
- Create an API Key: sign in at chat.b.ai, go to the API page (
/key), and create a key (official full-access tier covers all 38 models)
- Set API Key:
Ctrl+Shift+P → BAI: Set BAI API Key
- Show Models: Click the settings icon in the model picker → Language Models panel → set your desired models to Visible
- Select Model: In the Copilot Chat bottom model picker, choose a "BAI" model
- Start chatting
Features
- Multi-API-Key management — sticky / rotation / single modes, automatic key rotation on 401/403 (insufficient balance) / 429 / 502 / 503, per-key availability persistence and transient cooldown, whole-round auto-retry on transient failures with exponential backoff
- Cookie-based balance pre-check — bind the
__Secure-authjs.session-token cookie (from browser DevTools) to a key to skip exhausted keys proactively via the usage.points tRPC endpoint; falls back to passive detection (403) when the cookie is missing
- Dual-protocol — OpenAI-compatible and Anthropic Messages;
bai.apiMode = auto / openai / anthropic. Note: B.AI has no Responses API
- Automatic model discovery — fetches
/v1/models at startup, hides unavailable models, auto-adds new models with metadata from models.dev
- Thinking / reasoning — DeepSeek
reasoning_content, Anthropic thinking blocks (enabled/disabled), per-model reasoning-effort selector
- Tool calling — full support for VS Code
LanguageModelToolCallPart
- Vision proxy — non-vision models can call a vision model (
ask_image) to answer questions about attached images, with cross-turn vision history persistence
- Advanced Token indicator — status bar with per-request and cumulative input/output token counts, cache hit counts, progress bar
- Git commit message generation — one-click Conventional Commit messages from the SCM title bar, language auto-detection from commit history
- Model temperature presets — Precise / Balanced / Creative / Extra Creative
- i18n — Simplified Chinese + English
Advanced Token Usage Indicator
The status bar shows the current context usage and cumulative input/output token counts for BAI models. Models that return cache metrics via the OpenAI-compatible format also display the cumulative cache hit count and cache hit rate in the tooltip.
The status bar only appears while you are actually using a BAI model: it stays hidden on startup and when other chat model providers are in use, and auto-hides after 60 seconds of inactivity. Control it via bai.enableThirdPartyTokenIndicator (default: true).
Git Commit Messages
Click the magic wand button in the Source Control (SCM) panel to auto-generate a commit message. Configure the model, language, number of recent commits to reference, and whether to attach context files.
Extended Vision Understanding
This extension adds extended vision understanding capability to text-only models that do not natively support vision. When you send a message with an image to these models, they can call a vision-capable model to describe the image, and then answer based on that description.
Configure the default vision model via bai.visionProxyModel (default kimi-k2.6), or pick from a dynamic list of vision-capable models via the BAI: Select Vision Proxy Model command.
Scope note: the ask_image proxy applies to images you paste/attach manually into the chat. It does not apply to screenshots taken by VS Code's built-in screenshot tool — screenshot analysis is handled internally by the Copilot Chat framework, which is outside a third-party provider's control.
Model List
Built-in definitions for the B.AI chat models (verified against GET /v1/models and the /key pricing page on 2026-08-20; all 38 models support both OpenAI and Anthropic endpoints):
| Series |
Model ID |
Vision |
Thinking |
Default protocol |
| DeepSeek |
deepseek-v4-flash¹ / deepseek-v4-pro |
❌ |
selectable (high/max) |
OpenAI |
| Z.ai |
glm-5.3 / glm-5.2 / glm-5.1 |
❌ |
selectable / always |
OpenAI |
| Moonshot |
kimi-k3 / kimi-k2.6 |
✅ |
always |
OpenAI |
| MiniMax |
minimax-m3 / minimax-m2.7 |
✅/❌ |
always |
OpenAI |
| Alibaba |
qwen3.8-max / qwen3.8-27b |
✅ |
selectable |
OpenAI |
| OpenAI |
gpt-5.6-sol / gpt-5.6-terra / gpt-5.6-luna / gpt-5.5 / gpt-5.5-instant / gpt-5.4-pro / gpt-5.4 / gpt-5.4-mini / gpt-5.4-nano / gpt-5.2 / gpt-5-mini / gpt-5-nano |
✅ |
always |
OpenAI |
| Anthropic |
claude-opus-5 / claude-fable-5 / claude-sonnet-5 / claude-opus-4.8 / 4.7 / 4.6 / 4.5 / claude-sonnet-4.6 / 4.5 / claude-haiku-4.5 |
✅ |
opt-in (enabled/disabled) |
Anthropic |
| Google |
gemini-3.1-pro / gemini-3.6-flash / gemini-3.5-flash / gemini-3.5-flash-lite / gemini-3-flash |
✅ |
always |
OpenAI |
¹ deepseek-v4-flash is currently free (limited-time promo, 0 credits).
[!WARNING]
B.AI has no Responses API (/v1/responses does not exist). The bai.apiMode setting supports only auto / openai / anthropic.
The Anthropic protocol has compatibility issues with some models (e.g. DeepSeek: forced thinking + temperature/top_p returns 400 "请求参数组合无效"). The OpenAI-compatible format is recommended; use Anthropic only when you specifically need the native Messages format.
[!TIP]
Automatic model discovery is enabled by default: the extension fetches the live model list from GET /v1/models and hides models that are not available on your account.
Configuration
Available in settings.json:
{
"bai.apiMode": "auto",
"bai.commitLanguage": "auto",
"bai.commitModel": "deepseek-v4-flash",
"bai.commitMessagePrompt": "",
"bai.requestTimeout": 600000,
"bai.recentCommitsCount": 10,
"bai.commitIncludeCommitDiff": false,
"bai.commitAttachContextFiles": true,
"bai.enableAutoModelDiscovery": true,
"bai.syncModelsOnStartup": true,
"bai.maxInputTokensRatio": 1.0,
"bai.enableThirdPartyTokenIndicator": true,
"bai.apiKeyMode": "sticky",
"bai.apiKeyRotationStatusCodes": [401, 403, 429, 502, 503],
"bai.transientRetryStatusCodes": [429, 502, 503],
"bai.balanceCheckEnabled": true,
"bai.minBalancePoints": 0,
"bai.visionProxyModel": "kimi-k2.6"
}
Development
npm install
npm run compile # tsc + build-info (writes out/build-info.json + .copilot/build-log.md)
npm run lint
npm run build # package VSIX → bai-copilot-<version>.vsix
API test script (requires an API key):
node test/api-tests.mjs <API_KEY> [openai|anthropic|all]
Credits
This extension is adapted from tokenrhythm-copilot, which is in turn based on opencode-go-copilot and oai-compatible-copilot. See NOTICE.md and LICENSE.