Qwen Code logo
Coding agents

Use TokenRex with Qwen Code

Add a named OpenAI-compatible model provider to Qwen Code.

Custom-provider setup is documented in the linked official sources. A live TokenRex connection from this tool has not been tested. Screenshots illustrate the publisher's interface, not a verified TokenRex session.

Before you start

  • A current Qwen Code installation
  • A private TokenRex API key
  • An enabled streaming, tool-capable chat model

Setup methods

01

Qwen Code — custom provider

  1. 1

    Install Qwen Code from its official quick start. Use a release supporting modelProviders and custom providerProtocol mappings.

  2. 2

    Create a TokenRex API key and copy an exact enabled chat model ID from Models & Pricing. Replace the example ID with your selected model. Use verified context/output limits and a streaming, tool-capable model for agent tasks.

  3. 3

    Set TOKENREX_API_KEY privately in the environment that launches the app. Never share keys in screenshots, project files or exported configuration.

  4. 4

    Merge the configuration below into ~/.qwen/settings.json, preserving existing settings. The current modelProviders entry is an array; older preview schemas are not interchangeable.

  5. 5

    Run qwen and use /model to select the tokenrex provider's model. envKey reads the private launch environment; Qwen subscription/OAuth credentials are not this API key.

  6. 6

    Send a short read-only question and confirm the exact model in TokenRex usage. Test streaming and tool calls separately before allowing file, terminal or connected-account actions.

Configuration
{
  "providerProtocol": {
    "tokenrex": "openai"
  },
  "modelProviders": {
    "tokenrex": [
      {
        "id": "openai/gpt-6-astra",
        "name": "TokenRex",
        "baseUrl": "https://tokenrex.ai/api/public/v1",
        "envKey": "TOKENREX_API_KEY"
      }
    ]
  }
}

Setup reference

Troubleshooting

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.

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.