DEV Community

Cover image for Running Moltbot (Clawdbot) with Bifrost: Observability, Cost Control, and Multi-Model Routing
Kuldeep Paul
Kuldeep Paul

Posted on

Running Moltbot (Clawdbot) with Bifrost: Observability, Cost Control, and Multi-Model Routing

A practical guide to integrating Bifrost as a custom model gateway for Moltbot, enabling multi-provider access, observability, and production-grade reliability for your personal AI assistant.


Introduction

Moltbot (formerly Clawdbot) has quickly become one of the most notable open-source projects in the personal AI assistant ecosystem. Built by Peter Steinberger, it allows developers to run a self-hosted AI assistant that integrates with platforms like WhatsApp, Telegram, Discord, and Slack.

This setup lets users interact with large language models through familiar chat interfaces. Many enthusiasts even dedicate always-on hardware, such as Mac Minis, to run their assistants 24/7.

Out of the box, Moltbot supports providers like OpenAI and Anthropic. However, once you move beyond experimentation into daily or production use, direct API connections start to show limitations:

  • No unified observability
  • Limited failover options
  • Fragmented cost tracking
  • Manual model switching

This is where Bifrost fits in.

Bifrost is a high-performance open source LLM gateway from Maxim AI that provides a unified, OpenAI-compatible API across 15+ providers. By routing Moltbot traffic through Bifrost, you gain reliability, governance, and visibility—without sacrificing simplicity.

Github: https://getmax.im/bifrost-repo?utm_medium=kuldeep_dev.to

In this guide, we’ll walk through how to connect Moltbot to Bifrost and explain the architectural benefits of this setup.


Why Use Bifrost with Moltbot?

Single Endpoint for Multiple Providers

By default, Moltbot requires separate configurations for each provider.

With Bifrost, you configure one endpoint and gain access to OpenAI, Anthropic, Google Vertex, AWS Bedrock, Mistral, local models, and more.

All models are exposed through the same OpenAI-compatible interface, simplifying management and experimentation.

Automatic Failover and Load Balancing

Bifrost supports automatic routing between providers. If one service hits rate limits or goes offline, traffic is redirected to backups transparently.

Native Observability

Bifrost provides built-in observability, including request logging, latency metrics, and deep tracing via Maxim integration.

Governance and Cost Management

Bifrost enables budget limits, virtual API keys, usage tracking, and cost attribution to prevent runaway spend.

High Performance

Implemented in Go, Bifrost adds roughly 11 microseconds of overhead at high throughput, which is negligible compared to model inference times.


Prerequisites

  • Moltbot installed and running
  • Docker (or NPX)
  • Provider API keys
  • Basic CLI familiarity

Step 1: Deploy Bifrost

Option A: Docker Deployment

# Pull and run Bifrost HTTP API
docker pull maximhq/bifrost

# For configuration persistence across restarts
docker run -p 8080:8080 -v $(pwd)/data:/app/data maximhq/bifrost
Enter fullscreen mode Exit fullscreen mode

Option B: NPX Deployment

npx -y @maximhq/bifrost
Enter fullscreen mode Exit fullscreen mode

Verify the Deployment

curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/v1/models
Enter fullscreen mode Exit fullscreen mode

Step 2: Configure Providers in Bifrost

Using the Web Interface

Open:

http://localhost:8080
Enter fullscreen mode Exit fullscreen mode

Using the API

curl --location 'http://localhost:8080/api/providers' \
  --header 'Content-Type: application/json' \
  --data '{
    "provider": "google",
    "keys": [
      {
        "name": "google-key-1",
        "value": "YOUR_GOOGLE_API_KEY",
        "models": ["gemini-2.5-pro", "gemini-2.5-flash"],
        "weight": 1.0
      }
    ]
  }'
Enter fullscreen mode Exit fullscreen mode

Step 3: Configure Moltbot to Use Bifrost

Locate the Configuration File

~/.clawdbot/clawdbot.json
Enter fullscreen mode Exit fullscreen mode

Method A: CLI Configuration

clawdbot config set models.providers.bifrost '{
  "baseUrl": "http://localhost:8080/v1",
  "apiKey": "dummy-key",
  "api": "openai-completions",
  "models": [
    {
      "id": "gemini/gemini-2.5-pro",
      "name": "Gemini 2.5 Pro (via Bifrost)",
      "reasoning": false,
      "input": ["text"],
      "cost": {
        "input": 0.00000125,
        "output": 0.00001,
        "cacheRead": 0.000000125,
        "cacheWrite": 0
      },
      "contextWindow": 1048576,
      "maxTokens": 65536
    }
  ]
}'
Enter fullscreen mode Exit fullscreen mode

Method B: Direct Configuration

{
  "models": {
    "mode": "merge",
    "providers": {
      "bifrost": {
        "baseUrl": "http://localhost:8080/v1",
        "apiKey": "dummy-key",
        "api": "openai-completions",
        "models": [
          {
            "id": "gemini/gemini-2.5-pro",
            "name": "Gemini 2.5 Pro (via Bifrost)",
            "reasoning": false,
            "input": ["text"],
            "cost": {
              "input": 0.00000125,
              "output": 0.00001,
              "cacheRead": 0.000000125,
              "cacheWrite": 0
            },
            "contextWindow": 1048576,
            "maxTokens": 65536
          }
        ]
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Step 4: Set the Default Model

clawdbot config set agents.defaults.model.primary bifrost/gemini/gemini-2.5-pro
Enter fullscreen mode Exit fullscreen mode

Step 5: Restart Moltbot

clawdbot gateway restart
Enter fullscreen mode Exit fullscreen mode
clawdbot gateway status
Enter fullscreen mode Exit fullscreen mode

Step 6: Verify the Integration

clawdbot chat "Respond with exactly three words."
Enter fullscreen mode Exit fullscreen mode

Test Bifrost Directly

curl -X POST http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer dummy-key" \
  -d '{
    "model": "gemini/gemini-2.5-pro",
    "messages": [{"role": "user", "content": "Hello"}],
    "max_tokens": 50
  }'
Enter fullscreen mode Exit fullscreen mode

Clawdbot UI


Adding Multiple Models

curl -s http://localhost:8080/v1/models | jq '.data[] | {id: .id, name: .name}'
Enter fullscreen mode Exit fullscreen mode
{
  "models": {
    "mode": "merge",
    "providers": {
      "bifrost": {
        "baseUrl": "http://localhost:8080/v1",
        "apiKey": "dummy-key",
        "api": "openai-completions",
        "models": [
          {
            "id": "gemini/gemini-2.5-pro",
            "name": "Gemini 2.5 Pro (via Bifrost)",
            "contextWindow": 1048576,
            "maxTokens": 65536
          },
          {
            "id": "gemini/gemini-2.5-flash",
            "name": "Gemini 2.5 Flash (via Bifrost)",
            "contextWindow": 1048576,
            "maxTokens": 65536
          },
          {
            "id": "openai/gpt-4o",
            "name": "GPT-4o (via Bifrost)",
            "contextWindow": 128000,
            "maxTokens": 16384
          },
          {
            "id": "anthropic/claude-sonnet-4-5-20250929",
            "name": "Claude Sonnet 4.5 (via Bifrost)",
            "contextWindow": 200000,
            "maxTokens": 8192
          }
        ]
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode
clawdbot chat --model bifrost/openai/gpt-4o "Summarize this concept"
Enter fullscreen mode Exit fullscreen mode

Monitoring and Observability

Access the dashboard at:

http://localhost:8080
Enter fullscreen mode Exit fullscreen mode

Maxim Integration

{
  "plugins": [
    {
      "enabled": true,
      "name": "maxim",
      "config": {
        "api_key": "your_maxim_api_key",
        "log_repo_id": "your_repository_id"
      }
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

Bifrost Dashboard


Troubleshooting

Provider Not Found

  • Validate JSON syntax
  • Restart gateway
  • Check case sensitivity

Connection Issues

  • lsof -i :8080
  • curl http://localhost:8080/v1/models
  • Verify baseUrl

Invalid Model Format

Correct:

gemini/gemini-2.5-pro
Enter fullscreen mode Exit fullscreen mode

Incorrect:

gemini-2.5-pro
Enter fullscreen mode Exit fullscreen mode

API Type Errors

Set api to openai-completions and use /v1 endpoints.

Gateway Logs

tail -f ~/.clawdbot/logs/gateway.err.log
Enter fullscreen mode Exit fullscreen mode

Conclusion

Running Moltbot behind Bifrost turns a personal assistant into a production-grade system with unified access, failover, observability, and cost governance.

This architecture is well-suited for long-term automation, research, and productivity workflows.


Additional Resources


Bifrost is an open-source LLM gateway by Maxim AI. For enterprise features such as clustering, guardrails, and dedicated support, explore Bifrost Enterprise.

Top comments (0)