Running Nvidia Nemotron on LangChain via OpenRouter Step-by-step guide on how to build a LangChain agent that utilizes Nvidia's free Nemotron AI models via the OpenRouter platform. It covers the entire setup process, from installing necessary packages and configuring API keys to creating a simple tool-calling agent that can execute functions like retrieving weather data. The guide also offers tips for expanding the agent with multiple tools and suggests other free models for further experimentation. Nvidia's Nemotron models are powerful, free-to-use AI models available through OpenRouter. In this guide, you'll learn how to set up a LangChain agent that uses Nemotron — from installing packages to running your first tool-calling agent. A simple LangChain agent that: OpenRouter gives you free access to many models, including Nvidia's Nemotron family, with no credit card required. Create a new project folder and initialize it: mkdir my-nemotron-agent cd my-nemotron-agent uv init Or if you're using pip, just create a folder and a virtual environment: mkdir my-nemotron-agent cd my-nemotron-agent python -m venv .venv .venv\Scripts\activate Windows source .venv/bin/activate Mac/Linux uv add langchain langchain-openrouter python-dotenv Or with pip: pip install langchain langchain-openrouter python-dotenv These three packages are all you need: .env file safelyCreate a .env file in your project folder never commit this to Git : OPENROUTER API KEY=your-key-here Also create a .gitignore to protect it: .env .venv OpenRouter hosts several free Nvidia Nemotron models. Here are the main ones: Note: The :free suffix is required. Without it, OpenRouter will look for a paid endpoint. For beginners, nvidia/nemotron-3-nano-30b-a3b:free is a great starting point — it's fast and capable. Create a file called main.py : from dotenv import load dotenv from langchain.agents import create agent Load the OPENROUTER API KEY from your .env file load dotenv Define a tool — any plain Python function works def get weather city: str - str: """Get weather for a given city.""" return f"It's always sunny in {city} " Create the agent agent = create agent model="openrouter:nvidia/nemotron-3-nano-30b-a3b:free", tools= get weather , system prompt="You are a helpful assistant", Run the agent result = agent.invoke {"messages": {"role": "user", "content": "What's the weather in San Francisco?"} } Print the final response print result "messages" -1 .content load dotenv reads your .env file and sets the OPENROUTER API KEY environment variableget weather is a regular Python function — LangChain uses its docstring to describe the tool to the modelcreate agent wires everything together: the model, the tools, and the system promptagent.invoke ... sends the user's message and returns a result dictresult "messages" -1 .content gets the final text response from the last messageuv run main.py Or with pip/venv: python main.py You should see something like: The weather in San Francisco is sunny You can give your agent multiple tools — just add more functions to the list: def get weather city: str - str: """Get the current weather for a city.""" return f"It's always sunny in {city} " def get population city: str - str: """Get the population of a city.""" populations = { "San Francisco": "870,000", "New York": "8,300,000", "Dhaka": "21,000,000", } return populations.get city, "Population data not available." agent = create agent model="openrouter:nvidia/nemotron-3-nano-30b-a3b:free", tools= get weather, get population , system prompt="You are a helpful assistant", The agent will automatically decide which tool to call based on the user's question. When you're done, your project should look like this: my-nemotron-agent/ ├── .env ← Your API key never share this ├── .gitignore ← Excludes .env from Git ├── main.py ← Your agent code └── pyproject.toml ← Dependencies if using uv Once you're comfortable with the basics, here's what to explore next: deepseek/deepseek-r1:free or google/gemma-3-27b-it:free for comparisonHappy building