Storing model parameters and tools in Langfuse prompt config

Langfuse prompt config holds model settings, tool definitions and response schemas next to each prompt version, so a prompt and the parameters it needs ship together. This page covers when to use it, how to design it and what to confirm before rollout.

On this page

Why keep model parameters in Langfuse prompt config

Prompts change often, but the settings that surround them tend to live somewhere else: the model name in an environment variable, the temperature hard-coded in a service, the tool definitions in a utility module and the response schema in a parser. When a prompt is revised in Langfuse, nothing forces those pieces to change with it, and the version that reaches production can silently pair new wording with old settings. Langfuse prompt config is an optional, arbitrary JSON object attached to each prompt for use by the code making the LLM call. It commonly stores model parameters, and because it is saved with the prompt version, those settings can version and move together with the text.

The practical gain is that one label move changes the whole request contract. A team can keep model, temperature, max_tokens, tool definitions and a response schema inside the config of the same prompt version, then review them in the same diff as the wording. Before adopting this, confirm with your team which settings the calling code will read from config and which, if any, remain in code, since a split ownership model recreates the drift the config was meant to remove. Decide also who may edit config on a production label, because a temperature change can alter output as much as a wording change does. Confirm in your own environment how your SDK version exposes config on fetch before you rely on it.

How prompt config travels from Langfuse to application code

The flow starts with a prompt version and its config saved in a self-hosted Langfuse instance inside your infrastructure. The application fetches the prompt by label, so it receives the prompt text and the config together, then reads the model name, parameters, tool definitions and response schema from that config. It calls the model provider with those values and sends the generation trace back to Langfuse. Check that the label, the config keys and the code's expected keys all match before a change reaches production.

Prompt text and config are fetched together by label, then used for the model call and traced back.

What teams store in the config and what stays in code

Model choice and sampling settings are the values most teams store in the prompt config first, because they change together with the wording of the prompt. A prompt tuned for one model often behaves differently on another, so keeping the model identifier and its parameters next to the prompt version lets a reviewer see the full behavior change in one place. The config is an optional arbitrary JSON object that the calling code reads when it makes the LLM call, so the application decides how to apply each key.

  • Model identifier: a provider model name or alias, stored as a string under a key your code reads consistently.
  • Sampling settings: values such as temperature and maximum output tokens, stored as numbers with agreed ranges.
  • Provider-specific options: settings that only one provider supports, kept under a clearly named block so other providers ignore them.
  • Version pinning: the exact model version when your provider offers dated snapshots, so a provider update does not change behavior silently.
  • Fallback choices: a secondary model name the code can use if the primary is unavailable, if your application supports it.

Check that every key your code reads is also documented, and that a prompt version without a model name fails clearly instead of falling back to an unknown default.

Config design options and when each fits

This table compares four ways to shape the JSON prompt config and tool definitions, with the situations each fits and what it costs in portability. Read each row as a choice you make once per prompt family, then check it against the providers and SDKs your application uses. The main takeaway is that the config is free-form in Langfuse, so consistency in layout is a team decision you must document.

Design optionWhen it fitsMain trade-offCheck before adopting
Flat parameter objectSingle provider, few settings such as model, temperature and max tokensEasy to read and diff, but provider-specific keys can silently mean different things after a switchConfirm each key name matches the SDK call you make in code
Nested per-provider blocksPrompts run on more than one provider or a gateway that routes between themKeeps each provider's settings separate and portable, at the cost of more code that picks the right blockAgree on one shape the application reads and a fallback when a block is missing
Tool definitions inlineTools are short, used by one prompt only, and must ship with the exact prompt versionPrompt and tools deploy together, but long or repeated tool schemas bloat every versionCheck whether the schema is copied across prompts and who reviews changes to it
Tool definitions referenced by name or versionSeveral prompts share the same tools or tools change on their own release cycleLess duplication and clearer ownership, but a prompt version no longer fully describes what it callsRecord the tool version in the config and test that the referenced tool still matches
JSON schema for structured outputThe application parses model output and needs a stable, validated shapeParsing errors drop, but the schema must stay in step with downstream code and the provider's accepted subsetConfirm the provider supports the schema form you store and validate responses in code
Free-form notes or metadata keysReviewer hints, owner names or experiment labels that the code does not executeUseful for people, but the application may read stale or unused valuesMark which keys are executed and which are informational

Trade-offs of versioning parameters with prompt text

Storing model parameters and tools in the prompt config makes the prompt text and its settings one release artifact, which is convenient but moves risk into places teams did not review before. The four cards below cover what changes when config and text ship together: the release unit, the review gap, the diff burden and the schema coupling to application code.

One release artifact

A prompt version in Langfuse carries its text, labels and config together, so a model name or temperature change produces a new version the same way a wording change does. This lets you roll back both at once by moving a label. Check that your team understands that rolling back a label also rolls back the parameters, and that any code path reading config must handle the older shape.

Prompt config docs

Config changes skip code review

A pull request reviewer sees code diffs, but a prompt config edit made in the Langfuse UI or API may never pass through your repository's review process. A temperature or model change can alter cost and behavior in production without anyone reading it. Decide which label moves require a second approver, and confirm which roles on your self-hosted instance can edit production prompts.

Larger JSON is harder to diff

Config is an arbitrary JSON object, so nested tool definitions and response schemas can grow long and make version-to-version comparison hard in the UI. Small changes buried in a large object are easy to miss. Agree on key ordering, keep tool schemas in a consistent shape, and review the full version diff before moving a production label.

Tool schemas must match code

Tool definitions and response schemas stored in config describe what the application expects back, so they are coupled to parsing and handler code that lives in your repository. A schema edited in Langfuse without a matching code change can break tool calls silently. Plan a contract test that loads the production config and checks it against the handlers before a label moves.

Setting up config and reading it in application code

This sequence takes a prompt config from an agreed schema to a verified trace, so the model parameters and tool definitions the code sends are the ones recorded against the prompt version. Each step ends with a check that the team can repeat before the change reaches production.

  1. Agree the config schema with the team

    Engineering, the prompt owner and whoever reviews production changes agree on a written schema for the config JSON: which keys exist (for example model name, temperature, maximum output tokens, tool definitions and response schema), which are required, which have allowed values, and which fields the code is allowed to ignore. Keep the schema in your repository next to the code that reads it. The step is done when the team can point to one reviewed document and a sample config that matches it.

  2. Create a prompt version with its config in staging

    In a staging project, the prompt owner creates a new prompt version and enters the agreed config as an arbitrary JSON object, then assigns a staging label to it. Langfuse stores the config with that version, so the model settings and tool definitions travel with the prompt text and do not live in a separate file. The check is that the version detail view in the Langfuse UI shows the config exactly as written, with no fields dropped or reformatted during entry.

  3. Fetch the prompt by label with the SDK

    The application fetches the prompt through the Langfuse SDK using the staging label, not a version number, so the code picks up the latest approved version without a redeploy. Use a staging API key that points at your self-hosted instance and the same method your production code will use. The check is that the returned prompt object includes both the compiled text and the config field, and that the label resolves to the version you just created.

  4. Parse and validate the config in code

    The application converts the config into a typed structure and checks it against the agreed schema before any model call is made. Reject or fall back on missing required keys, out-of-range values such as a temperature outside the range your model accepts, and unknown tool names. Log validation failures with the prompt name and version so they can be traced back to the prompt change that caused them. The check is a unit test that feeds the schema a valid config and several broken ones, and confirms each broken case fails with a clear message.

  5. Pass parameters and tools to the model call

    The validated values are passed to the model client as the request parameters and tool definitions, so the call is built from the Langfuse config rather than from constants in the code. Keep the mapping in one function so a change to a key name is made in one place. The check is a test run against a model or a stub client that records the outgoing request, confirming that the model name, temperature, tool list and response schema in the request match the staging config field for field.

  6. Verify the trace records the expected values

    Run the application once against staging and open the resulting trace in Langfuse. Confirm that the generation is linked to the prompt name and version you fetched, and that the model parameters recorded on the generation match the config. If tool definitions or a response schema are sent, check that the tool calls or structured output in the trace match what the config describes. The step is done when a reviewer can open the trace and see the same config values the request used, and you have saved that trace as the reference for later regression checks.

How a config change deploys with its prompt

Moving a label to a new version moves the text and the config together. In Langfuse, the prompt config is stored on the prompt version, not in the application, so when a production label points at version 12 instead of version 11, the model name, temperature, tool definitions and response schema all change in the same step. The practical consequence is that rollback works the same way for parameters as it does for wording: moving the label back restores the older text and the older settings with it. Before relying on this, test it once on a non-production prompt. Fetch the labeled version from the application, confirm the config arrives with the text, move the label, and confirm the fetched config changes. Also confirm that your application caches prompts (see the caching section) so you know how long a rollback takes to reach running services.

The application must tolerate keys it does not recognize and keys that are missing. A config is arbitrary JSON, so a prompt author can add a field the code never reads, or remove one the code expects. Read each parameter with an explicit default in code, log a warning when a required key is absent, and reject a config whose values fall outside the ranges your code can safely send to the model provider. Decide in advance what happens when the config is invalid: fall back to a known-good version, or stop the request and alert. Write this behavior down, since it determines how a bad config fails in production.

Config changes need the same review as prompt text, because a temperature change, a new tool or a loosened response schema can alter behavior and data exposure as much as a wording change. A tool definition is particularly sensitive, since it can give the model a new capability. Assign reviewers for config edits, keep them in the same approval path as prompt edits, and require that the config is evaluated against your test dataset before the production label moves. Whether your Langfuse edition can restrict who moves production labels is a question to confirm against the protected labels feature in your license tier and your role design.

Security and operational considerations for prompt config

Prompt config sits next to the prompt text and travels with it through every label move, so the same controls that protect prompts apply to parameters, tool definitions and schemas. The cards below cover what should never live in config, who can edit it, which controls need an Enterprise license key, and how long old versions stay in your database.

Keep credentials out of config

The config is an arbitrary JSON object that every reader of the prompt can see in the UI and API, so API keys, tokens and connection strings do not belong in it. Keep provider credentials in your application's secret store and let config hold only model names, parameters and schema shapes. Before rollout, scan existing prompt versions for key-like strings, since a value pasted once stays in version history even after it is removed from a later version.

Prompt config docs

Limit who can edit config

Anyone with prompt write access in your self-hosted instance can change temperature, a tool definition or a response schema, and those edits can reach production when a label moves. Review which project roles can create prompt versions and which can set production labels, and treat config changes with the same review as prompt text. Confirm how your organization's role model maps onto those permissions before inviting engineers to the instance.

Plan audit trails for config changes

Audit logs and protected prompt labels are Enterprise features that need a license key, so they are not available on the open source edition. If you need a record of who changed a model parameter or tool schema and when, confirm whether your audit requirement can be met with Enterprise audit logs or needs a separate record, such as Git history for the code that reads the config. Ask your team to decide this before the first production label move.

License key docs

Set retention for prompt versions

Every saved version of a prompt, including its config, is stored in your self-hosted PostgreSQL database and stays there until someone removes it. Old versions can contain outdated model names, deprecated tool definitions or sensitive example values, so decide how long versions are kept and who may delete them. Confirm with your team how backups of that database handle deleted versions, because a version removed from the UI may still exist in an older backup.

Validate config before code reads it

Config is optional and unvalidated, so a missing key, a renamed parameter or a malformed tool schema reaches your application only at call time. Define the expected keys in your code, fail closed when a required value is absent, and test a new config version against a staging label before the production label moves. This keeps a single careless edit from changing model behavior for every user at once.

Questions teams ask before storing config in Langfuse

Can our team store model parameters and tools in Langfuse prompt config without outside help?

Yes, in most cases a team that already runs its own Langfuse instance and writes its own LLM calls can attach config to prompts itself. The prompt config is an optional arbitrary JSON object attached to each prompt version, and the code making the LLM call reads it. The harder part is agreeing on a shared schema, wiring every application to read it the same way, and testing that a config change does not break a production call. Teams that want an independent review of that design, or help with the rollout across several applications, can ask DeployOpen for a fixed-scope quote based on a written list of prompts, applications and models.

What makes the effort to set up prompt config grow?

The main drivers are the number of models, the number of tool definitions and response schema variants, and the number of applications that read prompts. Each new model adds parameter differences to document and test. Each tool definition or JSON response schema adds a contract that the application code must parse correctly. Each application reading prompts adds a integration point that must handle missing keys, defaults and version changes. Ask for a quote that lists these three counts explicitly, along with which prompts use tools and which use structured outputs.

Is storing prompt config a one-time task or ongoing work?

The initial design is one-time work: defining the config shape, moving existing parameters into Langfuse, and updating application code to read them. After that, work recurs whenever a model changes, a tool is added or a schema evolves, and whenever a new application starts using prompts. Model names and provider parameters also change over time, so someone must review config as part of normal prompt releases. When you request a quote, ask which items are included in the first build and which are covered by a retainer for ongoing changes.

Who on our side needs to be involved in a prompt config project?

Three things are needed from your team. First, a named owner for the config schema who decides which keys are allowed, their types and defaults, and how breaking changes are handled. Second, a staging Langfuse project where new config versions can be tested before they reach production labels. Third, access to the application code that makes LLM calls, so reading config can be added and tested in each service. Confirm these owners and access rights with your security team early, because production prompt changes often need review.

Does prompt config work the same way in self-hosted Langfuse as in Langfuse Cloud?

Prompt config is a core prompt feature, and Langfuse states that all core features and APIs are available in the MIT-licensed open source version without limits. Self-hosted deployments use the same codebase as Langfuse Cloud. Enterprise license features such as protected prompt labels, which control who can move production labels, are separate and need a license key on self-hosted instances. Confirm with the Langfuse license key documentation which controls your release process will need before you finalize the design.

What should our application do if it cannot read the config?

The application should fall back to a known safe configuration rather than failing silently or calling a model with unknown parameters. Define defaults in code for every required key, log when a fallback is used, and test the fallback path in staging. Also decide how long the application may keep using a cached config if Langfuse is unreachable. Prompt caching and fallback behavior are covered in a separate sibling topic, so review that design alongside the config schema.

How do we check that a config change behaves correctly before release?

Test each config version against the same inputs you use for the prompt, in the staging project, before moving a production label. Check that the application parses every key, that tool calls match the declared definitions, and that structured outputs validate against the schema. Compare cost and latency on a sample of traces if you already record them. Ask a vendor to describe how it will run these checks and what evidence it will hand over at the end of the project.

How DeployOpen scopes prompt config work for your Langfuse

DeployOpen plans the prompt config for your Langfuse around the code that reads it, so model parameters, tool definitions and response schemas are defined once per prompt version. We scope, build, test and document that pattern inside your own infrastructure, then hand it over to the teams who will maintain it. Engagements are fixed-scope and agreed in writing before work starts.

How we scope

  • We inventory which prompts need config and which application code reads each field.
  • We agree a config schema covering model name, temperature, tool definitions and response schemas.
  • We record which settings are fixed in code and which may change through a new prompt version.

How we build

  • We set up config objects on prompt versions in your self-hosted Langfuse instance.
  • We write application code that reads config at call time and validates it before the LLM call.
  • We test that a label move changes model settings and tools together with the prompt text.

How we hand over

  • We document the config schema, field owners and the steps to change a prompt version safely.
  • We walk your engineers through reading config in code and rolling back by moving a label.
  • We deliver runbooks for reviewing config changes before they reach production labels.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer.
  • We can retest config handling after Langfuse upgrades or changes to your model providers.
  • Ask us to confirm how your scope changes affect fixed-scope deliverables before work continues.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.