GitHub Copilot CLI logo
Coding agents

Use TokenRex with GitHub Copilot CLI

Use Copilot CLI's documented BYOK provider environment with TokenRex.

Setup checked against the linked official documentation. No live TokenRex session inside this tool has been verified. Use a compatible chat model and its real limits; configuration support does not establish support for every model or feature.

Before you start

  • A current GitHub Copilot CLI installation
  • A private TokenRex API key
  • An enabled streaming, tool-capable chat model

Setup methods

01

Install the standalone Copilot CLI

  1. 1

    Use GitHub's current installation instructions for your operating system. For the npm method, install the Node.js version required by that guide, then run the command below.

  2. 2

    Run copilot --version to check the installation. This is the standalone CLI, not the old gh copilot extension or VS Code settings.

Terminal commands
npm install -g @github/copilot
copilot --version

Setup reference
02

Configure a private provider and model

  1. 1

    Create a private TokenRex API key and copy an enabled chat model ID from Models & Pricing. The example model is replaceable; image, video, speech and embedding endpoints are not coding-agent chat models.

  2. 2

    Open or create ~/.copilot/providers.json. Merge the provider and model arrays below with existing entries; do not overwrite other providers.

  3. 3

    Replace YOUR_TOKENREX_API_KEY locally with your own key. GitHub documents that keys in this file are plain text: keep it private, outside your project and out of backups you share. $TOKENREX_API_KEY in JSON would be literal text, not an environment lookup.

  4. 4

    Use type openai with the versioned base URL for Chat Completions. The model's provider must match the provider's name. Add other compatible chat IDs as additional models, not invented aliases.

  5. 5

    Set maxPromptTokens and maxOutputTokens only from the selected model's actual limits if needed. An unknown model can default to 128,000 prompt tokens; that default is not proof of its capacity. Streaming and tool calling are required.

  6. 6

    Save, restart copilot and use /model to choose the configured model.

  7. 7

    Start a new conversation with the selected model, send a short read-only question and check its response and TokenRex usage. Test streaming and tool calls separately before approving file edits or terminal actions. These checks can incur normal model charges.

Configuration
{
  "providers": [
    {
      "name": "tokenrex",
      "type": "openai",
      "baseUrl": "https://tokenrex.ai/api/public/v1",
      "apiKey": "YOUR_TOKENREX_API_KEY"
    }
  ],
  "models": [
    {
      "id": "gpt-6-astra",
      "provider": "tokenrex"
    }
  ]
}

Setup reference
03

Alternative: launch with private environment credentials

  1. 1

    If your installed CLI supports the documented BYOK environment mode, set TOKENREX_API_KEY privately first.

  2. 2

    Run the shell example below. Do not put a raw key into a project script. Use /model to confirm the selected model and inspect any capability warning before continuing.

  3. 3

    Start a new conversation with the selected model, send a short read-only question and check its response and TokenRex usage. Test streaming and tool calls separately before approving file edits or terminal actions. These checks can incur normal model charges.

Terminal commands
export COPILOT_PROVIDER_TYPE=openai
export COPILOT_PROVIDER_BASE_URL="https://tokenrex.ai/api/public/v1"
export COPILOT_PROVIDER_API_KEY="$TOKENREX_API_KEY"
copilot --model gpt-6-astra

Setup reference

Troubleshooting

The model cannot run agent tools
Use a model and transport supporting both streaming and tool calling. Do not disguise a model using a recognized alias to bypass checks.
Authentication fails
Check that the saved TokenRex key is active and belongs in the tool's API-key field, not its subscription sign-in. Remove accidental spaces, check your wallet balance, and never share the key in screenshots or exported settings.
The model is missing or the request URL returns 404
Copy an exact enabled model ID from Models & Pricing. Follow this method's URL field: some tools expect the versioned base, others the root or full completion address. Check the documented API protocol before changing the path.
Chat works but streaming or tools fail
Test a short plain-text conversation first. Confirm the selected model and installed tool version support the required protocol and capabilities. Enable agent actions only after separately checking streaming and tool calls.

Further references

Verify the connection

Send a short message with the selected model, read its response, then confirm the exact model appears in your TokenRex usage. Test streaming and tool use separately before larger agent tasks.