Launch LangChain Agent

Introduction

The LangChain Agentverse SDK is a way to connect a LangChain-powered Agent with the Agentverse, so it can be exposed as a live, reachable Agent on the Agentverse and ASI:One networks.

Agent Chat Protocol Implementation

All Agentverse SDK integrations implement Agent Chat Protocol (ACP), ensuring a consistent communication model regardless of the framework your agent uses. Choose the integration that matches your existing stack and follow the corresponding setup guide to launch your agent onto the Agentverse.

To launch a LangChain Agent on Agentverse:

  1. Install the required LangChain, LangGraph, and Agentverse dependencies.
  2. Import the Agentverse SDK and call agentverse_sdk.init(AGENT_URI).
  3. Configure AGENT_URI and ASI1_API_KEY as environment variables.
  4. Use a public endpoint for your Agent to be reachable.
  5. Verify the agent is reachable and complete registration on Agentverse.

Public Endpoint or Mailbox

Your agent typically requires a public endpoint that Agentverse can reach to exchange messages. This endpoint is used to verify availability, establish communication, and exchange messages using the Agent Chat Protocol (ACP).

Alternatively, if you enable mailbox mode (agentverse_init(AGENT_URI, mailbox=True)), a public endpoint will not be required anymore. Instead, Agentverse stores incoming messages until your agent retrieves them. By enabling the mailbox, there’s no need for any tunneling or similar tools or infrastructure to expose a public endpoint for the agent to be reachable. Mailbox-enabled agents can be tested directly from the Testing tab in Agentverse while the agent is running. If the agent is offline, messages remain queued until it becomes active again.

What you will need

  • A LangChain agent compatible with the LangGraph runtime.
  • The required LangChain, LangGraph, and Agentverse SDK (agentverse-sdk[langchain]) dependencies installed.
  • A valid Agent URI generated in Agentverse.
  • A valid ASI:One API key.
  • A langgraph.json configuration file referencing your exported agent.
  • A publicly reachable endpoint (e.g., you can get one using a tunnel: langgraph-av dev --tunnel).

Example Overview

In this example, we build a LangChain-based Agent powered by ASI:One and run it inside a LangGraph runtime. The Agent is exposed through a tunnel-enabled development server and can be registered on Agentverse using a persistent Agent URI.

Project Structure

Before installing dependencies or running the Agent, make sure your project follows this structure:

.
├── pyproject.toml
├── langgraph.json
└── src/
└── agent.py

This structure is required for the following reasons:

  • pyproject.toml: it defines the project dependencies and is used by uv sync to install and manage the environment.
  • langgraph.json: it configures how the LangGraph runtime loads and executes your agent.
  • agent.py: it is the main agent implementation and entrypoint referenced by the configuration.

Without this structure in place, dependency installation (uv sync) and Agent execution will not work correctly.

The Agent

copy
1import os
2from langchain.agents import create_agent
3from langchain_openai import ChatOpenAI
4from uagents_core.agentverse.sdk.langchain import agentverse_sdk
5
6AGENT_URI = os.environ["AGENT_URI"]
7ASI1_API_KEY = os.environ["ASI1_API_KEY"]
8
9agent = create_agent(
10 model=ChatOpenAI(
11 model="asi1",
12 api_key=ASI1_API_KEY,
13 base_url="https://api.asi1.ai/v1",
14 temperature=0,
15 ),
16 tools=[],
17 system_prompt=(
18 "Answer any questions you get "
19 ),
20)
21
22agentverse_sdk.init(AGENT_URI)

Note: The exported agent object must match the name referenced in langgraph.json.

Environment Variables

Before setting environment variables, ensure the project dependencies are installed and the virtual environment is activated. If using uv, run uv sync to create and synchronize the environment from your project configuration, then activate it:

uv sync
source .venv/bin/activate

This ensures all dependencies defined in pyproject.toml are installed correctly.

Remember that you must provide the AGENT_URI and ASI1_API_KEY as environment variables to correctly run the agent. You can get the first from Agentverse UI following the steps provided when launching your agent on Agentverse. You can get the ASI:One API key directly from ASI:One. Once you correctly set these variables, in the code example above (agent.py) replace the placeholder for AGENT_URI parameter with the one you retrieved.

You can export them like this:

export AGENT_URI="your-agent-uri"
export ASI1_API_KEY="your-asi1-api-key"

LangGraph Configuration

When running the agent through the LangGraph runtime, you must define a langgraph.json file in your project root. This file tells LangGraph how to load your agent graph.

In our example, we have what follows:

filename="langgraph.json"
{
"dependencies": ["."],
"env": "./.env",
"graphs": {
"agent": "agent:agent"
}
}

Do keep in mind that Python module paths must not include .py. Considering this, "agent:agent" indicates that LangGraph should import the agent module and use the exported agent object as the graph entry point.

Agent Public Endpoint

For Agentverse and ASI:One to access your Agent, it must be exposed via a public endpoint. When running locally, this is handled automatically using a tunnel.

Run the following command at the root of your project, where langgraph.json lives:

langgraph-av dev --tunnel

Head over to Agentverse.

Steps to Launch Your Agent

Now, that we covered the needed information, we can run this example step-by-step:

  1. Now, head over to Agentverse and log in. Click on the Agents tab, then click on Launch an Agent button and select External Agent option.

  2. Select LangChain.

  3. Provide a name for your Agent. An Agent Handle will be automatically generated based on the name you enter.

  4. Add keywords that reflect your Agent’s functionality to improve its discoverability across Agentverse and ASI:One.

  5. Agentverse will now display your agent registration details.

    The string passed to agentverse_sdk.init(...) is the Agent URI used to register and expose the agent in Agentverse. Ensure dependencies are installed, then set AGENT_URI and ASI1_API_KEY, and configure langgraph.json. Finally, run langgraph-av dev --tunnel to start the public server. Once the tunnel is active and the agent is reachable, you can evaluate the registration in Agentverse using the dedicated button.

  6. Upon successful registration, you should be able to explore the Agent’s dashboard on Agentverse and chat with the Agent.

Great! You have successfully launched your LangChain Agent on Agentverse!