Skip to main content

OpenRouter

Configure OpenRouter when LIGHTFLARE_LLM_PROVIDER is set to openrouter.

The OpenRouter provider uses the OpenRouter chat completions API for structured responses and the embeddings API for memory embeddings.

Required Properties

VariableDescription
LIGHTFLARE_LLM_PROVIDERSet to openrouter.
LIGHTFLARE_LLM_OPENROUTER_ENABLEDSet to true.
LIGHTFLARE_LLM_OPENROUTER_API_KEYOpenRouter API key.

Optional Properties

VariableDefaultDescription
LIGHTFLARE_LLM_OPENROUTER_BASE_URLhttps://openrouter.ai/api/v1OpenRouter API base URL.
LIGHTFLARE_LLM_OPENROUTER_MODELopenai/gpt-4.1-nanoModel used for chat completions.
LIGHTFLARE_LLM_OPENROUTER_EMBEDDING_MODELopenai/text-embedding-3-smallModel used for embeddings.
LIGHTFLARE_LLM_OPENROUTER_MAX_COMPLETION_TOKENSLIGHTFLARE_LLM_MAX_OUTPUT_TOKENSMax chat completion tokens.
LIGHTFLARE_LLM_OPENROUTER_TEMPERATUREemptyOptional sampling temperature.
LIGHTFLARE_LLM_OPENROUTER_TOP_PemptyOptional nucleus sampling value.
LIGHTFLARE_LLM_OPENROUTER_SEEDemptyOptional generation seed.
LIGHTFLARE_LLM_OPENROUTER_USERemptyOptional stable user identifier sent to OpenRouter.
LIGHTFLARE_LLM_OPENROUTER_PROVIDERemptyOptional OpenRouter provider routing preferences as a map-style Spring property.
LIGHTFLARE_LLM_OPENROUTER_EMBEDDING_DIMENSIONSemptyOptional embedding dimensions when supported by the selected model/provider.
LIGHTFLARE_LLM_OPENROUTER_EMBEDDING_ENCODING_FORMATemptyOptional embedding encoding format.
LIGHTFLARE_LLM_OPENROUTER_EMBEDDING_INPUT_TYPEemptyOptional embedding input type.
LIGHTFLARE_LLM_OPENROUTER_EMBEDDING_PROVIDERemptyOptional embedding provider routing preferences as a map-style Spring property.
LIGHTFLARE_LLM_OPENROUTER_HTTP_REFERERemptyOptional HTTP-Referer header for OpenRouter rankings and analytics.
LIGHTFLARE_LLM_OPENROUTER_TITLEemptyOptional X-OpenRouter-Title header.
LIGHTFLARE_LLM_OPENROUTER_CATEGORIESemptyOptional X-OpenRouter-Categories header.

Example

LIGHTFLARE_LLM_PROVIDER=openrouter \
LIGHTFLARE_LLM_OPENROUTER_ENABLED=true \
LIGHTFLARE_LLM_OPENROUTER_API_KEY='replace-this-key' \
LIGHTFLARE_LLM_OPENROUTER_MODEL='openai/gpt-4.1-nano' \
LIGHTFLARE_LLM_OPENROUTER_EMBEDDING_MODEL='openai/text-embedding-3-small' \
docker compose up --build