Use Case:
| You can use MaiToken via VS Code Custom Endpoint, Copilot CLI, or the GitHub Copilot App. First-time users are recommended to start with VS Code. |
|---|
1. VS Code: Recommended Method
Update VS Code: Update VS Code to a stable version that includes Language Models management.
Open Model Management: Press
Cmd/Ctrl + Shift + Pto open the Command Palette and runChat: Manage Language Models. You can also click the gear icon in the Chat model selector.Add Custom Endpoint: Click Add Models → Custom Endpoint.
Enter Basic Details: Enter
MaiTokenas the group name,MaiToken - Model IDas the display name, and your own MaiToken Key as the API Key.Select API Type: Select Chat Completions.
Edit Configuration File: VS Code will open
chatLanguageModels.json. Replace<Your MaiToken Key>and<Model ID>in the example below with your actual values, then save the file.Select Model: Return to Chat and choose the MaiToken model from the model selector. If the model does not appear immediately, restart VS Code.
{ "name": "MaiToken", "vendor": "customendpoint", "apiKey": "<Your MaiToken Key>", "apiType": "chat-completions", "models": [ { "id": "<Model ID>", "name": "MaiToken - <Model ID>", "url": "https://api.maitoken.net/v1/chat/completions", "toolCalling": true, "streaming": true, "maxInputTokens": 128000, "maxOutputTokens": 8192 } ]}128000 and 8192 are examples only—adjust them according to the actual context length and max output limit of your model. If the model does not support tool calling, set toolCalling to false, though that model will not be usable in Agent mode. |
|---|
How to Test After Setup
Test Basic Chat: Enter
"Reply OK only"in the chat box. Receiving a normal reply confirms that your API Key, API address, and Model ID are basically correct.Test Project Reading: Open a test project and enter
"Please read the current project directory and list only the top-level file names without modifying any files."Test Agent: Ask the Agent to create a new file named
test-maitoken.txtcontaininghello, then verify the file was created. Do not run initial tests on a real production project.
2. Copilot CLI: For Terminal Users
Before launching Copilot CLI each time, set the following environment variables in your current terminal session.
macOS / Linux
export COPILOT_PROVIDER_BASE_URL="https://api.maitoken.net/v1"export COPILOT_PROVIDER_TYPE="openai"export COPILOT_PROVIDER_API_KEY="<Your MaiToken Key>"export COPILOT_MODEL="<Model ID>" copilotWindows PowerShell
$env:COPILOT_PROVIDER_BASE_URL="https://api.maitoken.net/v1"$env:COPILOT_PROVIDER_TYPE="openai"$env:COPILOT_PROVIDER_API_KEY="<Your MaiToken Key>"$env:COPILOT_MODEL="<Model ID>" copilot| Environment Variable | Value |
|---|---|
COPILOT_PROVIDER_BASE_URL |
https://api.maitoken.net/v1 |
COPILOT_PROVIDER_TYPE |
openai |
COPILOT_PROVIDER_API_KEY |
<Your MaiToken Key> |
COPILOT_MODEL |
<Model ID> |
Copilot CLI's Agent requires models that support streaming output and tool calling. If basic chat succeeds but Agent fails, switch to a model that supports tool_calls, streaming, and a larger context length. |
|---|
3. GitHub Copilot App
Open Settings: Launch the GitHub Copilot App and open Settings → Model providers.
Add Provider: Click Add provider and select OpenAI-compatible HTTP endpoint.
Enter Parameters: Enter
MaiTokenas the display name, https://api.maitoken.net/v1 as the Base URL, your own MaiToken Key as the API Key, and<Model ID>as the model.Save and Select: After saving the configuration, select the model from the model selector and start an Agent session.
| Custom providers in the GitHub Copilot App may still be in preview, and entry names may change across releases. |
|---|
Troubleshooting
| Issue | Suggested Fix |
|---|---|
| Model does not show up in VS Code | Restart VS Code after saving chatLanguageModels.json, and make sure the current workspace is marked as trusted. |
| Model cannot be selected in Agent mode | The model must have toolCalling enabled, and the endpoint must return OpenAI-compatible tool call data. |
| BYOK is missing for an enterprise account | Your organization administrator may have disabled the BYOK policy—contact your organization administrator to enable it. |
