Command Code

Command Code CLI supports any OpenAI-compatible endpoint as a BYOK provider. FreeGate is one, so the setup is an environment variable plus one entry in providers.json · or the /connect wizard, which imports the model list for you.

1. Export your key in the shell that starts the CLI

export FREEGATE_API_KEY="fg_live_…"

The config references $FREEGATE_API_KEY, so the variable must exist in the process that launches Command Code · not just in another terminal.

2. Add the provider

Run cmd, open /connect and pick (BYOK) Add your own provider. Use freegate as the id, OpenAI-compatible as the wire, and https://api.firesafety.men/v1 as the endpoint. Model discovery reads the gateway's own /models listing, so the catalog arrives without typing ids.

A key pasted into /connect is stored in ~/.commandcode/auth.json. If you skip the key there, set "apiKey": "$FREEGATE_API_KEY" in the file instead · a stored key wins over the file reference.

Or declare it manually

mkdir -p ~/.commandcode && ${EDITOR:-nano} ~/.commandcode/providers.json
{
  "provider": {
    "freegate": {
      "name": "FreeGate",
      "baseURL": "https://api.firesafety.men/v1",
      "apiKey": "$FREEGATE_API_KEY",
      "models": {
        "flint": { "name": "Flint", "contextWindow": 262144, "maxOutput": 32768 },
        "glyph": { "name": "Glyph Cluster", "contextWindow": 262144, "maxOutput": 32768 },
        "beam-contributor-free": { "name": "Beam 1.0 Contributor", "contextWindow": 1050000, "maxOutput": 131072 },
        "oss-120b": { "name": "GPT-OSS 120B", "contextWindow": 131072, "maxOutput": 16384 },
        "oss-20b": { "name": "GPT-OSS 20B", "contextWindow": 131072, "maxOutput": 16384 },
        "qwen38": { "name": "Qwen 3.8 27B", "contextWindow": 131072, "maxOutput": 16384 },
        "allam-2-7b": { "name": "ALLaM 2 7B", "contextWindow": 4096, "maxOutput": 4096 },
        "dd-v4-flash": { "name": "DeepSeek V4 Flash", "contextWindow": 1000000, "maxOutput": 32768 },
        "dd-v41-flash-fast": { "name": "DeepSeek V4.1 Flash Fast", "contextWindow": 1000000, "maxOutput": 32768 },
        "muse-spark-13": { "name": "Muse Spark 1.3 Contributor", "contextWindow": 1048576, "maxOutput": 32768 },
        "glm-53-flash": { "name": "GLM 5.3 Flash", "contextWindow": 1050000, "maxOutput": 32768 },
        "qwen37-flash": { "name": "Qwen 3.7 Flash", "contextWindow": 1000000, "maxOutput": 32768 },
        "hy4-flash": { "name": "Tencent Hy4 Flash", "contextWindow": 1024000, "maxOutput": 32768 },
        "kimi-k27": { "name": "Kimi K2.7 Code", "contextWindow": 256000, "maxOutput": 16384 }
      }
    }
  }
}

The top-level key is provider, not providers. Models appear as freegate/<id> in /model. The list above is the whole catalog, including paid models your account may not have; calling a locked one returns 403 model_not_allowed.

3. Pick a model

Inside the CLI, run /model and choose a freegate/* model. BYOK models appear alongside Command Code's own catalog, each under its own heading.

What works

  • Chat and code questions, streaming responses.
  • Tool calling. Tools and tool results are forwarded.
  • Images on vision-capable models (see models).
  • Files · text-like files are inlined; binary formats are refused.
  • Requests stay direct. Traffic goes from your machine to FreeGate; Command Code's backend is not in the path.

Troubleshooting

  • Confirm the endpoint and key from the same shell:
    curl https://api.firesafety.men/v1/models -H "Authorization: Bearer $FREEGATE_API_KEY"
  • A malformed providers.json entry is skipped with a warning under /connect; siblings keep working. Fix the JSON rather than restarting.
  • Check the env var resolves in the same shell: on macOS/Linux echo $FREEGATE_API_KEY, on Windows $env:FREEGATE_API_KEY.
  • 401 · key invalid or revoked. 403 · model not available to your account.
  • 429 or 503 · a token/request allowance or the provider pool is spent; check status.