LLM Model Configuration#
LLM model parameters in Langfuse are configured through two mechanisms: a flat modelParams JSON column shared by the EvalTemplate and DefaultLlmModel Prisma models, and per-connection settings stored in LlmApiKeys. Together these cover everything from basic sampling parameters to provider-specific options.
Core TypeScript Types#
The central type hierarchy lives in packages/shared/src/server/llm/types.ts:
-
ZodModelConfig— the Zod schema for themodelParamsJSON payload. Fields:max_tokens(number, optional)temperature(number, optional)top_p(number, optional)maxReasoningTokens(number, optional)providerOptions(free-form JSON object, optional)
-
ModelParams— extendsModelConfigwithprovider: string,adapter: LLMAdapter, andmodel: string. This is the runtime type passed into the LLM completion layer. -
UIModelParams— wraps every field in{ value, enabled }for UI toggle support (e.g., enabling/disablingtop_pindividually).
Prisma Models#
EvalTemplate — model_params column#
Stores per-template model configuration for LLM-as-a-Judge evaluators :
model String? // model identifier, e.g. "gpt-4o"
provider String? // provider name, e.g. "openai"
modelParams Json? @map("model_params")
DefaultLlmModel — model_params column#
Stores the project-level default model used when no template-level model is specified :
provider String
adapter String
model String
modelParams Json? @map("model_params")
DefaultLlmModel has a required FK to LlmApiKeys, linking stored parameters to a specific API key connection.
LlmApiKeys — connection-level settings#
Beyond the API secret, LlmApiKeys carries fields that affect how LLM calls are constructed :
| Field | Purpose |
|---|---|
provider / adapter | Provider name and interface type (e.g. openai, anthropic) |
baseURL | Custom endpoint override |
customModels | Extra model IDs beyond built-in lists |
withDefaultModels | Whether to include the built-in model list |
extraHeaders | Encrypted additional HTTP headers |
extraHeaderKeys | Plaintext header key names |
config | Bedrock / VertexAI-specific JSON config |
extraHeaders are stored encrypted and decrypted at call time via decryptAndParseExtraHeaders, validated as z.record(z.string(), z.string()).
Supported Adapters#
The LLMAdapter enum defines six adapters:
| Adapter value | Notes |
|---|---|
openai | GPT / o-series, and OpenAI-compatible providers via baseURL |
azure | Azure OpenAI deployments |
anthropic | Claude family |
bedrock | AWS Bedrock Converse API |
google-vertex-ai | Google Vertex AI |
google-ai-studio | Google AI Studio / Gemini API |
Built-in model lists (openAIModels, anthropicModels, vertexAIModels, googleAIStudioModels) are maintained in types.ts. Azure and Bedrock have empty built-in lists because model names are deployment-specific. The first entry in each list is the default model used when configuring a new API key .
providerOptions — Provider-Specific Parameters#
modelParams.providerOptions is a free-form JSON object for passing parameters that go beyond the standard temperature/top_p/max_tokens trio — for example reasoning_effort or service_tier for OpenAI, or thinkingLevel/thinkingBudget for Google models (docs).
In fetchLLMCompletion, the object is mapped to the adapter's native property name:
| Adapter | Mapped to |
|---|---|
| OpenAI / Azure | modelKwargs |
| Anthropic | invocationKwargs |
| Bedrock | additionalModelRequestFields |
| VertexAI / GoogleAIStudio | Spread directly after schema validation via googleProviderOptionsSchema |
Google adapters validate providerOptions through googleProviderOptionsSchema before spreading, narrowing accepted keys to thinkingBudget and thinkingLevel.
Reasoning Model Special Cases#
For OpenAI reasoning models (o1, o3, o4-mini, gpt-5 series), isOpenAIReasoningModel switches the token-limit parameter from maxTokens to maxCompletionTokens. The mapping openAIModelToReasoning tracks which model IDs are reasoning models.
For Anthropic and Google adapters that emit "thinking" blocks, fetchLLMCompletion forces method: "functionCalling" when calling withStructuredOutput to prevent reasoning blocks from corrupting JSON schema parsing .
Key Entry Points#
| File | Purpose |
|---|---|
packages/shared/prisma/schema.prisma | EvalTemplate, DefaultLlmModel, LlmApiKeys model definitions |
packages/shared/src/server/llm/types.ts | ModelParams, ZodModelConfig, LLMAdapter, model lists |
packages/shared/src/server/llm/fetchLLMCompletion.ts | Adapter instantiation and providerOptions dispatch |
packages/shared/src/server/services/DefaultEvaluationModelService/DefaultEvalModelService.ts | Validates config via live test call before saving DefaultLlmModel |
| LLM Connections docs | User-facing configuration guide |