Command Code BYOK Setup

Connect TokenHub through Command Code BYOK and validate a compatible coding model before enabling edits.

What is Command Code?

Command Code is a command-line coding agent with a BYOK flow for OpenAI-compatible and Anthropic-wire model providers.

This Command Code BYOK guide follows the official /connect workflow. It uses an OpenAI-compatible API root, stores credentials in the local auth store, and allows manual model IDs when discovery is unavailable. The official BYOK flow stores provider credentials locally and lets the user select the resulting model with /model. Choose the API wire deliberately, enter the full model ID when discovery is empty, and verify code reading and tool calls before allowing Command Code to change a working repository.

Command Code currently marks BYOK as Beta. Its custom-provider wizard asks for an ID, wire protocol, API root, key, and models in sequence; it is not a generic three-field form.

Add TokenHub with the official BYOK wizard

  1. Run /connect in Command Code.
  2. Choose (BYOK) Add your own provider.
  3. At Name it, enter the lowercase ID tokenhub. This becomes the entry name in ~/.commandcode/providers.json, and models are routed as tokenhub/<model-id>.
  4. At Pick the wire, choose the default OpenAI-compatible wire, openai-completions. Choose anthropic-messages only for Anthropic Messages.
  5. At Point at the endpoint, enter the API root https://us-api.tokenhub.com/v1. Command Code may trim an accidentally pasted /chat/completions, but you should enter the correct root directly.
  6. At Add the key, paste your TokenHub API key. The wizard saves it to ~/.commandcode/auth.json; do not commit a key to a repository.
  7. At Declare the models, let the wizard request /models. If discovery returns nothing, enter the exact TokenHub model ID manually.

On non-input screens, press h for concise help or esc to return to the preceding step. When setup finishes, Command Code opens /model, where the new provider appears alongside its built-in models.

Edit only providers.json when a manual change is necessary

Provider definitions live in ~/.commandcode/providers.json. Reopen /connect or /model to reload changes:

{
  "provider": {
    "tokenhub": {
      "name": "TokenHub",
      "baseURL": "__API_BASE_URL__/v1",
      "api": "openai-completions",
      "apiKey": "$TOKENHUB_API_KEY",
      "models": {
        "YOUR_TOKENHUB_MODEL_ID": {}
      }
    }
  }
}

If /connect already stored the key, do not duplicate it in the provider file. A model can also declare contextWindow, maxOutput, reasoningEfforts, and options, but add only capabilities verified for that TokenHub model.

Maintain the connection from its Provider card

Run /connect again and select tokenhub. The Provider card displays the endpoint, model count, and key status:

  • r: replace or save the key.
  • u: fetch models again without changing the wire, headers, or key reference.
  • c: clear the stored key.
  • d: delete the provider and its local credentials.

A healthy provider shows a green check and a model count. If providers.json is invalid, Command Code skips the bad entry without overwriting the file and reports its path in /connect or --list-models.

Verify routing from /model

Run /model, choose a model in the TokenHub group, and ask a read-only repository question. Confirm the model ID and /v1/chat/completions in TokenHub logs. For a 401, return to the Provider card and press r; for a 404, inspect baseURL and api; if the model is absent, press u or declare it in providers.json.

Official reference

Choose a compatible Command Code model

WorkloadModel choiceWhy it fits
Complex coding tasksA tool-capable reasoning modelUse a model with reliable tool use, streaming, and the context length your workflow needs.
Daily implementationA balanced coding modelPrioritize reliable edits and useful latency for normal coding loops.
Background and subagent workA fast, lower-cost modelUse this for iterations, summaries, and simpler work only after validating tool use.
Browse TokenHub models and compatibility

Command Code BYOK FAQ

Which wire should I choose for TokenHub?

Choose OpenAI-compatible when using the TokenHub API root ending in /v1.

Where does Command Code store the API key?

The /connect flow stores provider keys in Command Code’s local auth storage. Avoid committing a key to providers.json.

What if the model list is empty?

Enter the exact TokenHub model ID manually in the BYOK flow or providers.json, then select it in /model.

How do I test Command Code safely after BYOK setup?

Select the TokenHub model with /model and begin with a read-only repository question. Verify the request log before granting edit or command permissions.

Why does Command Code reach the wrong endpoint?

Check the wire selected during /connect. The TokenHub /v1 root belongs to the OpenAI-compatible wire unless you intentionally configured an Anthropic Messages endpoint.

References

This setup is based on TokenHub and official documentation, last verified on 2026-09-08.