Which API key should I use: LANGSMITH_API_KEY or LANGCHAIN_API_KEY in the latest LangChain setup?

I’m going through the LangChain documentation, and I’m a bit confused about which API key is the correct one to use. In some older tutorials, they recommend setting the key with export LANGCHAIN_API_KEY="your_key_here". However, the newer documentation mentions using export LANGSMITH_API_KEY="your_key_here" instead.

I’m unsure if this is merely a name change or if these keys serve different purposes. Could someone clarify the differences between these two API keys? Which one is appropriate for new projects? Am I supposed to have both or just one? I want to ensure my environment is set up correctly and that I’m not using outdated information.

I’ve migrated several production apps and LANGSMITH_API_KEY is definitely the way to go. LangChain consolidated everything under LangSmith branding around mid-2023. I kept both keys at first thinking they did different things, but that just caused confusion. LANGSMITH_API_KEY gives you way more than just tracing - you get evaluation tools, dataset management, and prompt versioning. The old LANGCHAIN_API_KEY couldn’t do any of that. Pro tip: search your codebase for hardcoded references to the old key name. I had a few hiding in config files that kept causing random auth failures until I found and cleaned them all up.

Had the same issue last week! Go with LANGSMITH_API_KEY - that’s what works now. The old LANGCHAIN_API_KEY is dead. Don’t waste time trying both like I did lol

Yeah, I get the confusion - LangChain changed things up and it’s annoying. LANGCHAIN_API_KEY used to work in older versions but they ditched it. Now you need LANGSMITH_API_KEY instead, which connects to LangSmith (their main tracing platform). Just use LANGSMITH_API_KEY for new projects. The old key won’t work anymore and you’ll get auth errors. I actually ran into this same issue when updating an old project and wasted way too much time debugging it. Grab your key from smith.langchain.com, not from any outdated docs you might find.

The naming changed from LANGCHAIN_API_KEY to LANGSMITH_API_KEY when they rebranded their tracing service to LangSmith. I dealt with this at work when we migrated our internal tools.

LANGSMITH_API_KEY is what you need for anything LangChain related now. The old variable name’s completely deprecated. This key gives you access to LangSmith’s tracing, monitoring, and debugging features - not just basic LangChain functionality.

You only need the one key (LANGSMITH_API_KEY). Set it in your environment and you’re good to go. I’d also check out the LangSmith dashboard since it’s pretty useful for tracking your chain executions.

If you’re just getting started, this video walks through account creation and API key setup:

One thing to watch out for - make sure you’re looking at current documentation. There’s still tons of outdated setup guides that reference the old key name.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.