## Deploy and Host Bifrost on Railway

Bifrost is a high-performance AI gateway written in Go. It exposes one OpenAI-compatible API in front of OpenAI, Anthropic, Google, AWS Bedrock, Azure, Mistral, Groq, Ollama and many more providers, with load balancing, fallbacks, semantic caching, budgets, rate limits, virtual keys, MCP tools and request logs.

### About Hosting Bifrost

This template deploys Bifrost v2.2.2 from the official image with its config and logs stores in SQLite on a Railway volume. The start command writes a `config.json` that protects the dashboard and management API with an admin username and a generated password, and requires a virtual key for every inference request. Provider keys are encrypted with a generated key. Add providers and virtual keys in the dashboard, then point any OpenAI SDK at Bifrost. It is light and fits the Hobby plan. Requests from other Railway services can use the private URL.

### Common Use Cases

- One OpenAI-compatible endpoint for many LLM providers with fallbacks
- Per-team virtual keys with budgets and rate limits
- Logging and cost tracking for AI requests across applications

### Dependencies for Bifrost Hosting

- `maximhq/bifrost:v2.2.2` (official image)
- A Railway volume at `/app/data` for config and logs

#### Deployment Dependencies

- [Bifrost documentation](https://docs.getbifrost.ai/)
- [Bifrost releases](https://github.com/maximhq/bifrost/releases)
- [config.json reference](https://docs.getbifrost.ai/deployment-guides/config-json/client)
- [Railway volumes](https://docs.railway.com/reference/volumes)

#### Implementation Details

| Service | Image | Networking | Storage |
| --- | --- | --- | --- |
| bifrost | `maximhq/bifrost:v2.2.2` | public domain on 8080; private IPv4/IPv6 | volume at `/app/data` |

```python
from openai import OpenAI
client = OpenAI(base_url="https:///v1", api_key="")
client.chat.completions.create(model="openai/gpt-4o-mini", messages=[{"role": "user", "content": "hi"}])
```

| Variable | Default | Purpose |
| --- | --- | --- |
| `BIFROST_ADMIN_USERNAME` / `BIFROST_ADMIN_PASSWORD` | `admin` / generated | Dashboard and management API login |
| `BIFROST_ENCRYPTION_KEY` | generated | Encrypts provider keys; never change it |
| `BIFROST_DISABLE_CONTENT_LOGGING` | `false` | Set `true` to log metadata only |
| `BIFROST_LOG_RETENTION_DAYS` | `30` | Request log retention |

Notes:

- Virtual keys need an allowed provider with `allowed_models` and `key_ids` (use `*` for all).
- For providers on the Railway private network, such as Ollama, enable **Allow private network** on the provider.

### Why Deploy Bifrost on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Bifrost on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
