DOC: <Issue related to /how_to_guides/tracing/log_llm_trace> #15

Closed
opened 2026-02-21 17:16:58 -05:00 by yindo · 2 comments
Owner

Originally created by @YassineRjl on GitHub (Jul 6, 2024).

Hi there, I'm using RunTree and want to log the cost, I figured out how to add the token count but not the cost. Can someone guide me please?

PS: The provider openai and gpt-4 are just values to test with. I figured if it works for them it'll work for the other custom models I'm using like Command-R

Reference: https://docs.smith.langchain.com/how_to_guides/tracing/log_llm_trace#manually-provide-token-counts

   trace.end({
      data,
      usage_metadata: {
        input_tokens: 27,
        output_tokens: 13,
        total_tokens: 40,
        total_cost: ((inCost ?? 0) + (outCost ?? 0)),
        prompt_cost: inCost,
        completion_cost: outCost,
      },
      ls_provider: 'openai',
      ls_model_name: 'gpt-4',
    });
Originally created by @YassineRjl on GitHub (Jul 6, 2024). Hi there, I'm using RunTree and want to log the cost, I figured out how to add the token count but not the cost. Can someone guide me please? PS: The provider openai and gpt-4 are just values to test with. I figured if it works for them it'll work for the other custom models I'm using like Command-R Reference: https://docs.smith.langchain.com/how_to_guides/tracing/log_llm_trace#manually-provide-token-counts ```ts trace.end({ data, usage_metadata: { input_tokens: 27, output_tokens: 13, total_tokens: 40, total_cost: ((inCost ?? 0) + (outCost ?? 0)), prompt_cost: inCost, completion_cost: outCost, }, ls_provider: 'openai', ls_model_name: 'gpt-4', }); ```
yindo closed this issue 2026-02-21 17:16:58 -05:00
Author
Owner

@hinthornw commented on GitHub (Jul 16, 2024):

Hi there! Cost is added in the UI via the models page

@hinthornw commented on GitHub (Jul 16, 2024): Hi there! Cost is added in the UI via the models page
Author
Owner

@katmayb commented on GitHub (Nov 18, 2025):

Closing this issue out, we've moved to a new docs repository at: https://github.com/langchain-ai/docs/issues
Thank you!

@katmayb commented on GitHub (Nov 18, 2025): Closing this issue out, we've moved to a new docs repository at: https://github.com/langchain-ai/docs/issues Thank you!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langsmith-docs#15