---
title: OpenAI-compatible apps
description: Use any OpenAI-compatible app, agent framework or library with a Lovely Router API key: set the base URL, the key and a model id.
---

Most apps, agent frameworks and libraries that call OpenAI can call Lovely Router. Lovely Router serves the OpenAI Chat Completions API at `https://lovelyrouter.com/v1` for every text model, Claude and Gemini included, so one custom endpoint gives the app all of them. You need an [API key](/app/keys) first.

## Settings

Find the setting for a custom endpoint and enter:

| Setting | Value |
| --- | --- |
| Base URL | `https://lovelyrouter.com/v1` |
| API key | your `lr-...` key |
| Model | any id from `GET /v1/models`, such as `gpt-6.1-sol` or `claude-sonnet-5.5` |

If the app asks for an API *host* and appends `/v1` itself, enter `https://lovelyrouter.com` without `/v1`.

## Environment variables

Tools built on the official OpenAI or Anthropic SDKs often read the base URL from the environment:

```bash title="Shell"
# OpenAI SDK based tools
export OPENAI_BASE_URL=https://lovelyrouter.com/v1
export OPENAI_API_KEY=$LOVELY_API_KEY

# Anthropic SDK based tools
export ANTHROPIC_BASE_URL=https://lovelyrouter.com
export ANTHROPIC_API_KEY=$LOVELY_API_KEY
```

Writing your own code? [SDKs](/docs/integrations/sdks) has client examples in Python and Node.js, and [OpenAI Chat Completions](/docs/models/openai) covers streaming, function calling and what is supported.

## Troubleshooting

| Symptom | Fix |
| --- | --- |
| `401` with `Missing API key` | The tool isn't sending the key. Check the variable name, and that you exported it in the shell that starts the tool. |
| `401` with `Invalid or revoked API key` | The key is mistyped, truncated or revoked. Paste it again, or create a new one. |
| `404` with `Model '...' is not available` | The model id doesn't exist. Copy an id from `GET /v1/models` or the [model list](/models). |
| `404` with `Unknown endpoint` | The tool is calling an API Lovely Router doesn't serve, such as embeddings or audio. Switch it to Chat Completions, the Responses API, or the Anthropic or Gemini format. |
| `404` with `not served in responses format` | The Responses API serves GPT models only. Pick a `gpt-*` model, or use Chat Completions for other models. |
| `404` on a path containing `/v1/v1/` | The app appends `/v1` itself. Use `https://lovelyrouter.com` as the host. |
| `402` | Your balance is empty or the key reached its spend limit. See [Credits & billing](/docs/account/billing). |

Every other status is covered in [Errors](/docs/api/errors).
