Skip to content
Docs

Deep Agents CLI with AI Gateway

Deep Agents CLI is LangChain's terminal coding agent built on the deepagents framework. You can configure it to use AI Gateway for unified model access and spend monitoring.

Run the Vercel CLI setup command for Deep Agents CLI:

terminal
npx vercel ai-gateway setup --agent deepagents

The command writes a vercel-ai-gateway provider into ~/.deepagents/config.toml with api_key_env naming AI_GATEWAY_API_KEY, a /model switcher shortlist in leaderboard spend order, and per-model profile tables carrying display names and token limits. Re-run it to refresh the shortlist.

If you can't use the Vercel CLI, configure Deep Agents CLI manually:

  1. Go to the AI Gateway section in the Vercel dashboard sidebar and click API keys to create a new API key.

  2. Export the key in your shell:

    Terminal
    export AI_GATEWAY_API_KEY="your-ai-gateway-api-key"

    To persist the key, add the same line to your shell's startup file.

  3. Add a vercel-ai-gateway provider to ~/.deepagents/config.toml:

    ~/.deepagents/config.toml
    [models]
    default = "vercel-ai-gateway:openai/gpt-6-astra"
     
    [models.providers.vercel-ai-gateway]
    display_name = "Vercel AI Gateway"
    api_key_env = "AI_GATEWAY_API_KEY"
    base_url = "https://ai-gateway.vercel.sh/coding-agent/v1"
    class_path = "langchain_openai:ChatOpenAI"
    models = ["openai/gpt-6-astra", "anthropic/claude-sonnet-5"]
     
    [models.providers.vercel-ai-gateway.params]
    use_responses_api = false

    The models array feeds the /model switcher rather than gating requests, so any gateway model ID works. class_path selects LangChain's OpenAI chat client, and use_responses_api = false keeps requests on Chat Completions.

  4. Open a new terminal so the key is loaded, then run:

    Terminal
    dcode

    The /model switcher filters as you type. Use any other gateway model directly with /model vercel-ai-gateway:<gateway-model-id>.

View your usage, spend, and request activity in the AI Gateway section in the Vercel dashboard sidebar. See the observability documentation for more details.

VariableDescription
AI_GATEWAY_API_KEYYour AI Gateway API key, named by api_key_env. Required

Deep Agents calls AI Gateway through the OpenAI-compatible Chat Completions API, so any model that supports Chat Completions works.

Last updated September 13, 2026

Was this helpful?

supported.