---
title: Deploy LiteLLM with AI on Blossom
url: "/deploy/litellm/"
canonical_url: https://blossom88.com/deploy/litellm/
markdown_url: https://blossom88.com/deploy/litellm.md
summary: Deploy LiteLLM with AI on Blossom. Give your apps a model gateway with restricted
  virtual keys, budgets, usage tracking, and managed PostgreSQL.
categories:
- deployment
- ai
stack:
- Python
- FastAPI
- Next.js
- React
- PostgreSQL
---

# Deploy LiteLLM with AI on Blossom

[LiteLLM](https://www.litellm.ai/) is an AI gateway that gives your apps a
consistent API for different model providers. Create separate virtual keys,
choose which models each app can use, and track usage in one dashboard.

## Ask Your Agent

> **Ask your AI agent:** Deploy LiteLLM on Blossom with managed Postgres. Help me create a model key with a budget.
>
> Follow this guide: https://blossom88.com/deploy/litellm/

[Install the Blossom CLI and skill](https://docs.blossom88.com/learn/getting-started/install/) on your agent's machine and [choose a Location in your cloud account](https://docs.blossom88.com/learn/getting-started/choose-your-cloud/#connect-your-provider).

## Your Model Gateway Setup

| Part | Purpose |
|---|---|
| Gateway Service | Model API, routing, and administration dashboard |
| Managed PostgreSQL | Virtual keys, budgets, usage, and saved settings |
| Your model provider | Runs the model requests |

Bring your model provider's API key. Keep the dashboard and master key private;
give each client a restricted virtual key. This recipe uses one gateway
instance. Additional replicas need shared coordination and rate-limit settings.

![LiteLLM showing an active virtual key and its usage budget.](/deploy/assets/images/litellm/virtual-keys.png)

<details class="optional-reading" markdown="1">
<summary>Deployment setup and commands</summary>

Test a permitted model with the virtual key. Anonymous requests and requests
for a model outside that key's allowed set must be refused.

Upstream requirements: [LiteLLM deployment requirements](https://docs.litellm.ai/docs/proxy/deploy).

Keep a strong `LITELLM_MASTER_KEY` for administration and a stable
`LITELLM_SALT_KEY` for encrypted credentials. Keep both through updates. Configure
a model alias and reference the provider key through an environment variable.
Enable database-backed configuration and usage tracking.

### Open the Dashboard

Keep the site behind **Blossom Account access**. Configure private dashboard
credentials, then open `/ui` and sign in. Keep the master key out of application
clients; each app should get its own virtual key.

[Source code](https://github.com/BerriAI/litellm).

Create an App and prebuilt-image Environment, then create and link PostgreSQL:

    blossom app:create --data app.yml
    blossom environment:create --data environment.yml
    blossom database_instance:create --data postgres.yml --follow
    blossom environment_link:create --data database-link.yml
    blossom env_var:push --environment environment-100 --file .env.production
    blossom service:create --data gateway-service.yml
    blossom environment:deploy --id environment-100 --follow

The gateway reads `DATABASE_URL`. Preserve the image's production entrypoint,
provide its configuration file, and listen on port `4000`. Use an HTTP readiness
check at `/health/readiness`, which reports database connectivity. Let the
release's database initialization complete before using the gateway.

Example model configuration:

```yaml
model_list:
  - model_name: my-chat-model
    litellm_params:
      model: openai/your-model
      api_key: os.environ/OPENAI_API_KEY

general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY
  database_url: os.environ/DATABASE_URL
  store_model_in_db: true
```

Supply the provider key, master key, salt key, and dashboard credentials
privately. Generate the configuration file from saved deployment settings when
the Container starts, or include a credential-free configuration in your image.
Don't keep the only copy on the Container's local disk.

An OpenAI-compatible client uses your gateway's HTTPS base URL with `/v1`,
the configured model alias, and its virtual key.

</details>

## Give Your App a Key

Choose an allowed model, expiry and budget for the key. Make a short request
and inspect its usage. External clients need only the intended inference
routes opened; the dashboard and administrative routes remain private.

<details class="optional-reading" markdown="1">
<summary>Updates and storage</summary>

Keep PostgreSQL, your model configuration, and application secrets stable.
Back up the database and follow the release's supported upgrade path.

The gateway Container can be replaced without a local data Volume. This guide
tests one instance. Before adding replicas, follow LiteLLM's current
[production guidance](https://docs.litellm.ai/docs/proxy/prod) for shared
configuration, Redis coordination, and rate limits.

</details>

## What You Get

- A model gateway and private administration dashboard
- Separate virtual keys with allowed models, expiry, and budgets
- Usage history in managed PostgreSQL
- An OpenAI-compatible API your apps can call
