Skip to main content

Lovable

Give Lovable context about Agent Router so the apps it generates call the gateway instead of a single provider, with the right base URL, authentication, and endpoints from the first prompt.


Setup

Lovable reads project context from the knowledge or instructions field attached to a project, rather than from a file in a repository. Paste the following into that field before generating AI features:

Project context
# Agent Router AI Gateway

This project uses Agent Router as an AI gateway. Agent Router exposes a single
OpenAI-compatible endpoint that routes to multiple AI providers.

## API configuration

- Base URL: the proxy endpoint shown on the Console Dashboard, ending in `/v1`
- Auth: Bearer token with an Agent Router API key
- Protocol: OpenAI Chat Completions API, so any OpenAI-compatible client works
- Store the key in an environment variable, never in generated source

## Making API calls

Use a standard OpenAI-compatible client and change only the base URL and API key:

- Point `baseURL` at the Agent Router proxy endpoint.
- Read the API key from an environment variable.
- Default to a chat completions model unless a specific model is requested.

## Endpoints available through Agent Router

- Chat completions
- Embeddings
- Image generation
- Audio speech

## Patterns to prefer

- Use streaming for any user-facing chat interface.
- Use a separate API key per feature so cost can be attributed.
- Rely on gateway-side fallback routing for high availability, configured in
the Console rather than in application code.

Because generated apps run the key in the browser or in a deployed backend, keep the Agent Router API key in an environment variable or a server-side secret. Do not let generated code embed the key in client-side source.

What this gives you

With this context attached, Lovable will:

  • Generate API calls that target the Agent Router base URL and Bearer-token auth pattern.
  • Route through the gateway rather than calling a single provider directly.
  • Read the API key from an environment variable instead of hardcoding it.
  • Use streaming for chat interfaces and separate keys per feature.