页面简介
Connect Command Code to AI Gateway with your own API key and a custom base URL. Configure models, switch between them, and monitor usage and spending.
正文摘录
Copy pageCopy pageCommand Code with AI GatewayCopy pageCopy pageUse Command Code with AI Gateway for model access and spend monitoring. Command Code's bring your own key (BYOK) configuration, currently in beta, lets you set a custom provider endpoint and choose models. Command Code requires manual configuration. The Vercel CLI setup command does not configure it. Configuring Command Code Install Command CodeWith Node.js 22 or later installed, run:Terminalnpm i -g command-code@latest command-code --versionThe second command prints the installed version. See the Command Code installation instructions for platform-specific details.If you haven't signed in to Command Code, run:Terminalcommand-code loginComplete the sign-in in your browser, then return to the terminal after Command Code confirms the login.Create an API keyCreate an AI Gateway API key and export it in the terminal where you run Command Code:Terminalexport AI_GATEWAY_API_KEY="your-ai-gateway-api-key"Replace your-ai-gateway-api-key with your key.Configure the providerCreate ~/.commandcode/providers.json with the following configuration. If the file exists, add the vercel entry to its provider object:~/.commandcode/providers.json{ "provider": { "vercel": { "name": "Vercel AI Gateway", "baseURL": "https://ai-gateway.vercel.sh/coding-agent/v1", "apiKey": "$AI_GATEWAY_API_KEY", "models": { "deepseek/deepseek-v4.1-flash": {} } } } }The baseURL uses the coding agent endpoint. Command Code uses OpenAI-compatible Chat Completions by default. Add an entry under models for each model you want to use, with its AI Gateway model ID.Keep apiKey as an environment variable reference. Command Code rejects raw secrets in providers.json. A key previously saved for this provider through /connect takes precedence. Clear that saved key to use the environment variable.Start Command CodeStart a session in the same terminal:Terminalcommand-codeRun /model and select a model under Vercel AI Gateway. Requests for that model route through AI Gateway. Reopen /model after editing providers.json to load your changes.Send a prompt, then check AI Gateway logs to verify the request. Next steps Monitor usage and spending Explore Command Code's BYOK options Last updated September 13, 2026PreviousCodexNextConductorWas this helpful?