transcribe

Trace OpenRouter Calls to LangSmith — No Code Changes Needed

LangChain · 4m · transcribed Jul 2026
More from LangChain Business
𝕏 Share ▶ YouTube 📥 PDF 🤖 .md

Section Insights

# 0:00

Introduction to Open Router's Broadcast Feature

What is the broadcast feature in Open Router?

The broadcast feature allows for the storage of destination information server-side, simplifying the integration process by only requiring the Open Router API key in the code.

  • Broadcast feature simplifies sending traces to Langmith.
  • Only the Open Router API key is needed in the code.
  • Destination information is stored server-side.
# 0:24

Setting Up Langchain with Open Router

How do you set up Langchain to work with Open Router?

To set up Langchain, you need to initialize the chat model with the OpenAI provider and set the base URL to Open Router, along with passing the Open Router API key.

  • Initialize Langchain's chat model with OpenAI provider.
  • Set the base URL to Open Router.
  • Pass the Open Router API key for configuration.
# 0:58

Obtaining API Keys

How do you obtain the necessary API keys for Open Router and Langmith?

You can obtain the Open Router API key from the Open Router UI and the Langmith API key from the Langmith configuration settings.

  • API keys are essential for integration.
  • Keys can be obtained from their respective UIs.
  • Configuration is straightforward for both services.
# 0:34

Testing the Broadcast Feature

How can you test the broadcast feature?

You can send a test trace directly from the Open Router UI to Langmith to verify that the setup is working correctly.

  • Testing can be done directly from the Open Router UI.
  • Successful trace sending indicates proper setup.
  • Real-time feedback is available in Langmith.
# 0:52

Switching Models in Langchain

Can you switch models dynamically in Langchain?

Yes, you can swap out models in Langchain at runtime with just a single line of code, allowing for flexibility in model usage.

  • Dynamic model switching is possible in Langchain.
  • Only one line of code is needed to change models.
  • This feature enhances flexibility and adaptability.
# 0:49

Tracking Costs Across Models

How does Open Router help in tracking costs?

Open Router allows users to track LLM costs across different models and manage spending across their organization effectively.

  • Open Router aids in tracking LLM costs.
  • Helps manage organizational spending.
  • Provides insights into model usage and expenses.
# 0:16

Conclusion and Encouragement

What is the final takeaway from the demonstration?

The integration of Open Router with Langchain is efficient and user-friendly, encouraging users to try it out for their own applications.

  • Integration is efficient and user-friendly.
  • Encouragement to experiment with the setup.
  • Highlights the benefits of using both tools together.

Transcript

0:01 Hey, I'm Tanish from Langchain. Today I'm going to go through how to use Open Router's new broadcast feature with Langchain to send traces to Langmith. The cool thing about broadcast is it stores destination information, which in this case is Langmith server side. So the only thing that you need to worry about in your code is your open router API key. Let's go through how to set this up. So let me walk you through a quick code snippet. This uses lang chain's init chat model in order to initialize a model and I've actually set it up so that you can pass the model dynamically at runtime.

0:39 So one thing you want to keep in mind because open open router is open AAI compatible. the model provider should always be set to open AAI when using lang chains init chat model. And then the base URL should point to Open Router since we want all our LLM requests to go to Open Router. And then finally, you would pass your Open Router API key through. So let's go set this up. In order to get my Open Router API key, I'm going to head into the Open Router UI, create an API key, and then let's copy that over.

1:28 And now we can go to the new broadcast feature in the UI. Hit Langmith and configure this. So I'm going to need a Langmith API key as well. And then we can copy that over to the open router UI. Set the project as I don't need to configure either of these for this demo, but if you're self-hosted linksmith user, you would point this to your LinkSmith URL. And then if you created a orwide API key, you could specify your workspace ID here. And then here we're going to select the key that we created.

2:29 Let's test this. Save. And the nice thing is you can actually send a trace directly from the open router UI to Langmith. So let's test that out. There we go. Open router demo. We should see the trace show up here in just a second. And so that that was the test trace sent by open router. and now that we have the open open router API key set here too, we can try running this and again we should see the reflecting trace in linksmith.

3:10 There we go. So that was that bedrock call. Let's say I wanted to swap this out to use an OpenAI model instead. Let's try that.

3:43 And we should see the trace in linksmith as well. There we go. So that's super nice. I love that you can use open router to track your LLM cross costs across models, track your spend across your organization. And it works really well when you pair it together with lang chain. So you have the optionality of configuring various models and updating the model you use at runtime with just a single line of code. So thanks for watching. Give it a try.

Summary

Tanish from Langchain demonstrates how to utilize Open Router's new broadcast feature to send traces to Langmith, emphasizing the simplicity of the setup process, which primarily involves using an Open Router API key. The integration allows for dynamic model selection and effective tracking of LLM usage and costs across different models.

- Open Router's broadcast feature stores destination information server-side, simplifying the integration process.
- Users only need to manage their Open Router API key in the code.
- The setup involves initializing a chat model with Langchain and ensuring the model provider is set to OpenAI.
- The base URL for LLM requests should point to Open Router.
- Users can configure Langmith API keys within the Open Router UI for trace sending.
- The demo shows how to send a trace from Open Router to Langmith and verify its reception.
- The integration allows for dynamic model swapping at runtime with minimal code changes.
- This setup helps track LLM costs and usage efficiently across different models within an organization.

Questions Answered

What is the broadcast feature in Open Router?

The broadcast feature allows for the storage of destination information server-side, simplifying the integration process by only requiring the Open Router API key in the code.

How do you set up Langchain to work with Open Router?

To set up Langchain, you need to initialize the chat model with the OpenAI provider and set the base URL to Open Router, along with passing the Open Router API key.

How do you obtain the necessary API keys for Open Router and Langmith?

You can obtain the Open Router API key from the Open Router UI and the Langmith API key from the Langmith configuration settings.

How can you test the broadcast feature?

You can send a test trace directly from the Open Router UI to Langmith to verify that the setup is working correctly.

Can you switch models dynamically in Langchain?

Yes, you can swap out models in Langchain at runtime with just a single line of code, allowing for flexibility in model usage.

How does Open Router help in tracking costs?

Open Router allows users to track LLM costs across different models and manage spending across their organization effectively.

What is the final takeaway from the demonstration?

The integration of Open Router with Langchain is efficient and user-friendly, encouraging users to try it out for their own applications.

© transcribe · For agents Built with care and craft by Gokul Rajaram