DEV Community

Cover image for How To Use Claude Code With Any AI Model Using an LLM Gateway (Bifrost)
Bonnie
Bonnie

Posted on

How To Use Claude Code With Any AI Model Using an LLM Gateway (Bifrost)

Unless you live under a rock, vibe coding has been the talk of the town in software development for a while now since AI coding tools became a thing.

And one of the most popular and capable AI coding tool developers can use today is Claude Code by Anthropic.

Claude Code can read your repository, run commands, modify files, and help implement features directly from the terminal using only Anthropic’s own AI models.

But what if you want to use Claude Code with different LLM providers instead of being tied to a single one?

Maybe you want to:

  • Switch between Anthropic, OpenAI, or Gemini

  • Use a cheaper model for simple tasks

  • Fall back to another provider during outages

  • Route requests for performance or cost optimization

This is where an LLM gateway becomes incredibly useful.

In this guide, you will learn how to connect Claude Code to any LLM using the Bifrost LLM gateway.

Before we jump in, here is what we will cover:

  • Why Bifrost LLM gateway?

  • Setting up and configuring LLM providers with Bifrost LLM gateway

  • Integrating Claude Code with Bifrost LLM gateway

  • Running Claude Code with any AI model.

  • Enabling built-in observability and monitoring

  • Integrating MCP tools

Let’s dive in.

Why Bifrost LLM gateway?

Bifrost is an open-source LLM gateway built by Maxim AI to route, manage, and optimize requests between your AI application and multiple large language model providers.

The LLM gateway is built using Go (Golang) for performance and below is what makes it stand out:

  • Blazing fast overhead: At 5,000 requests per second, Bifrost adds less than 15 microseconds of internal overhead per request which is very important at production scale.

  • Zero-config startup: You can launch Bifrost with a single npx command and configure everything through a web UI.

  • Built-in fallbacks and load balancing: If a provider fails or rate-limits you, Bifrost automatically routes to a backup. Traffic can be distributed across multiple keys or providers using weighted rules.

  • Semantic caching: Repeated or similar queries can be served from cache, which helps in cutting costs and reducing latency.

  • **Observability: **Bifrost offers Prometheus metrics, request tracing, and a built-in web dashboard out of the box.

Bifrost supports 15+ providers including OpenAI, Anthropic, Google Gemini (via Vertex or GenAI), AWS Bedrock, Azure, Mistral, Cohere, Groq, and more.

You can learn more about Bifrost LLM gateway here on there website.

Image from Notion

Prerequisites

Before we start, make sure you have the following:

Let’s get started!

Setting up and configuring LLM providers with Bifrost

In this section, you will how to set up Bifrost LLM gateway with multiple AI model providers that you can use with Claude Code.

Let’s get started.

Step 1: Install Bifrost using NPX binary

To install Bifrost, first, create your project folder named claude-code-demo and open it using your preferred code editor such as VS Code or Cursor.

Then run the command below with the **-app-dir** flag that determines where Bifrost stores all its data:

npx -y @maximhq/bifrost -app-dir ./my-bifrost-data
Enter fullscreen mode Exit fullscreen mode

Step 2: Create a config.json file

Once you have installed Bifrost in your project, create a config.json file in the ./my-bifrost-data folder. Then add the code below that defines multiple LLM providers and database persistence.

{
  "$schema": "https://www.getbifrost.ai/schema",
  "client": {
    "enable_logging": true,
    "disable_content_logging": false,
    "drop_excess_requests": false,
    "initial_pool_size": 300,
    "allow_direct_keys": false
  },
  "providers": {
    "openai": {
      "keys": [
        {
          "name": "openai-primary",
          "value": "env.OPENAI_API_KEY",
          "models": [],
          "weight": 1.0
        }
      ]
    },
    "anthropic": {
      "keys": [
        {
          "name": "anthropic-primary",
          "value": "env.ANTHROPIC_API_KEY",
          "models": [],
          "weight": 1.0
        }
      ]
    },
    "gemini": {
      "keys": [
        {
          "name": "gemini-primary",
          "value": "env.GEMINI_API_KEY",
          "models": [],
          "weight": 1.0
        }
      ]
    }
  },
  "config_store": {
    "enabled": true,
    "type": "sqlite",
    "config": {
      "path": "./config.db"
    }
  },
  "logs_store": {
    "enabled": true,
    "type": "sqlite",
    "config": {
      "path": "./logs.db"
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Step 3: Set up your API keys

After creating the config.json file, set your API keys as environment variables so they're never hardcoded using the commands below in the terminal.

export OPENAI_API_KEY="your-openai-api-key"
export ANTHROPIC_API_KEY="your-anthropic-api-key"
export GEMINI_API_KEY="your-gemini-api-key"
Enter fullscreen mode Exit fullscreen mode

Step 4: Start Bifrost Gateway server

Once you have set up your API keys, start the Bifrost LLM gateway server by running the command below again (Make sure to stop the initial running server instance).

npx -y @maximhq/bifrost -app-dir ./my-bifrost-data
Enter fullscreen mode Exit fullscreen mode

Then Bifrost will listen on port 8080, as shown below.

Image from Notion

Finally, navigate to the gateway dashboard at http://localhost:8080 as shown below

Image from Notion

Integrating Claude Code with Bifrost LLM gateway

In this section, you will learn how to integrate Claude Code with Bifrost LLM gateway in order to use it with any AI model.

Let’s get started.

Step 1: Install Claude Code

To install Claude Code, run the command below in the command line:

npm install -g @anthropic-ai/claude-code
Enter fullscreen mode Exit fullscreen mode

Step 2: Point Claude Code at Bifrost

Once you have installed Claude Code, point it at Bifrost LLM gateway by setting the environment variables below in the terminal where ANTHROPIC_BASE_URL tells Claude Code to send its API requests to Bifrost instead of Anthropic's servers:

export ANTHROPIC_BASE_URL="http://localhost:8080/anthropic"
export ANTHROPIC_API_KEY="dummy-key"
Enter fullscreen mode Exit fullscreen mode

Step 3: Run Claude Code with Any Model

After pointing Claude Code at Bifrost, start and run Claude Code with with any model such OpenAI GPT 5.2-codex model using the command below.

claude --model openai/gpt-5.2-codex
Enter fullscreen mode Exit fullscreen mode

Then you should see Claude Code running, as shown below:

Image from Notion

Step 4: Verify the setup

Once Claude Code is running, verify it setup with Bifrost using a simple query such as, “Hello there.” You should see the response in Claude Code, as shown below:

Image from Notion

Integrating MCP tools

In this section, you will learn how to integrate MCP tools with Bifrost to allow Claude Code to connect directly and access the tools.

Let’s get started!

Step 1: Connect Bifrost to MCP server

To connect Bifrost to MCP server for let’s say filesystem, update the config.json file with the code below:

{
  "$schema": "https://www.getbifrost.ai/schema",
  "client": {
    "enable_logging": true,
    "disable_content_logging": true,
    "drop_excess_requests": false,
    "initial_pool_size": 300,
    "allow_direct_keys": false
  },

 // ...

  "mcp": {
    "client_configs": [
      {
        "name": "filesystem",
        "connection_type": "stdio",
        "stdio_config": {
          "command": "npx",
          "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
        },
        "tools_to_execute": ["*"],
        "tools_to_auto_execute": [
          "read_file",
          "list_directory",
          "create_file",
          "delete_file"
        ]
      }
    ],
    "tool_manager_config": {
      "max_agent_depth": 10,
      "tool_execution_timeout": 300000000000,
      "code_mode_binding_level": "server"
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Then restart Bifrost server and navigate to the MCP catalog page in the web UI. You should see the filesystem MCP server connected, as shown below:

Image from Notion

Step 2: Connect Claude Code to Bifrost MCP

Once you have connected MCP server to Bifrost, add Bifrost as an MCP server to Claude Code using the command below:

claude mcp add --transport http bifrost http://localhost:8080/mcp
Enter fullscreen mode Exit fullscreen mode

Step 3: Execute a coding task

After connecting Claude Code to Bifrost MCP, restart it and execute a simple coding task using the prompt below:

Create a simple calculator program in Python.

It should support:
- addition
- subtraction
- multiplication
- division

The user should input two numbers and an operation, and the program should print the result.
Enter fullscreen mode Exit fullscreen mode

Claude Code should create a python file with the calculator code. Then run the prompt below that analyzes your codebase and creates a Readme file.

Analyze this repository and create a README.md explaining how the project works.

Include the project architecture and instructions for running it locally.
Enter fullscreen mode Exit fullscreen mode

Once Claude Code completes the run, the Readme file should be created, as shown below:

Image from Notion

Built-in observability and monitoring

Bifrost provides built-in observability and monitoring by logging all traffic passing through the gateway.

The web interface at http://localhost:8080/logs provides:

  • Real-time streaming of requests and responses

  • Token usage tracking per request

  • Latency measurements

  • Filtering by provider, model, or conversation content

  • Full request/response inspection

Image from Notion

You can also monitor LLM logs with requests, latency, tokens and cost, a shown below:

Image from Notion

Conclusion

In conclusion, Claude Code is already one of the most powerful AI development assistants available today.

By combining it with an LLM gateway like Bifrost unlocks even more flexibility where you can:

  • Use any AI provider

  • Dynamically switch models

  • Integrate MCP tools

  • Monitor responses, tokens, latency and usage cost

Finally, feel free to explore Bifrost and try it yourself using the links below:

Top comments (0)