Sourcebot logo
    /

    Langfuse Model Detection

    Public

    Recent Chats

    Sign in to access your chat history.

    When using Sourcebot's chat feature, I'm able to get langfuse traces. However, it can only detect the model (and pricing) when using claude sonnet 4. If I try to use gemini 2.5 pro I see the traces in langfuse but it doesn't detect which model I'm using. What could be causing this?

    Answer

    The issue is that Langfuse cannot identify the gemini-2.5-pro model because it is not defined in its model pricing configuration. While you are able to use the model in Sourcebot, Langfuse requires a corresponding entry to properly trace and report on it.

    Here's a breakdown of the problem:

    • Langfuse Model Pricing: Langfuse uses a file named default-model-prices.json default-model-prices.json to identify and calculate costs for different language models.
    • Missing Gemini 2.5 Pro: The gemini-2.5-pro model is not present in this configuration file. While other models like claude-3-sonnet-20240229 default-model-prices.json:836-854 and even gemini-2.5-flash default-model-prices.json:1854-1873 are defined, gemini-2.5-pro is missing.
    • Sourcebot Configuration: The Sourcebot repository does have configuration for gemini-2.5-pro in its documentation language-model-providers.mdx:14-21, which is why you are able to use it in the chat feature.

    To resolve this, you will need to add an entry for gemini-2.5-pro to the default-model-prices.json file within the Langfuse repository. This will allow Langfuse to recognize the model and provide the correct tracing information.

    default-model-prices.json
    language-model-providers.mdx

    is there a guide on how to add a new entry into default-model-prices.json ?

    Answer

    While there isn't an explicit guide in the Langfuse documentation on how to add a new model to the pricing configuration, the process can be inferred from the structure of the default-model-prices.json file default-model-prices.json and the surrounding code.

    Here’s a guide on how to add a new entry for gemini-2.5-pro:

    1. Understand the Model Configuration Structure

    Each model in the default-model-prices.json file default-model-prices.json is a JSON object with the following key fields:

    • id: A unique identifier. You can generate a new one for your entry.
    • model_name: The standardized name for the model (e.g., "gemini-2.5-pro").
    • match_pattern: A regular expression used to match the model name as it appears in traces. This is crucial for Langfuse to identify the model correctly. For Gemini models, a pattern like (?i)^(gemini-2.5-pro)(@[a-zA-Z0-9]+)?$ is typically used, as seen with gemini-1.5-pro default-model-prices.json:995-1003.
    • prices: An object specifying the cost per unit (e.g., per character or token) for both input and output. You will need to find the official pricing for gemini-2.5-pro to fill this in.
    • tokenizer_id: The tokenizer used for the model. For Gemini models, this is often set to null default-model-prices.json:992-992 as the token count is expected to be provided in the trace.
    • tokenizer_config: Additional configuration for the tokenizer, also typically null for Gemini models default-model-prices.json:991-991.

    2. Create a New Model Entry

    You would need to create a new JSON object for gemini-2.5-pro and add it to the array in default-model-prices.json default-model-prices.json. Here is a template you can use, which you'll need to populate with the correct pricing information:

    1{
    2 "id": "clx_new_gemini_pro_entry",
    3 "model_name": "gemini-2.5-pro",
    4 "match_pattern": "(?i)^(gemini-2.5-pro)(@[a-zA-Z0-9]+)?$",
    5 "created_at": "YYYY-MM-DDTHH:MM:SS.sssZ",
    6 "updated_at": "YYYY-MM-DDTHH:MM:SS.sssZ",
    7 "prices": {
    8 "input": 0.0000035,
    9 "output": 0.0000105
    10 },
    11 "tokenizer_config": null,
    12 "tokenizer_id": null
    13}

    Replace the placeholder values with the correct data.

    3. Adding the Entry to Langfuse

    Since default-model-prices.json default-model-prices.json is part of the Langfuse repository, you have a few options:

    • Self-Hosted Langfuse: If you are running your own instance of Langfuse, you can directly modify this file in your deployment.
    • Langfuse Cloud: If you are using the cloud version of Langfuse, you will not be able to modify this file directly. In this case, you should:
      1. Open an issue or pull request on the langfuse/langfuse GitHub repository, requesting the addition of gemini-2.5-pro to the default-model-prices.json file. This is the recommended approach as it will benefit the entire community.
      2. Use the Custom Models UI: Langfuse provides a UI for adding custom model definitions in the project settings. You can navigate to Settings -> Models and click "Add model definition" models.tsx:283-292. This will allow you to define the model name, match pattern, and pricing for your project. This is the most immediate solution for cloud users.

    By adding the model definition, Langfuse will be able to correctly identify gemini-2.5-pro in your traces and provide accurate pricing and analytics.

    default-model-prices.json
    models.tsx