langgraph new path/to/your/app --template new-langgraph-project-python
langgraph new path/to/your/app --template new-langgraph-project-js
Additional templates
If you use langgraph new without specifying a template, you will be presented with an interactive menu that will allow you to choose from a list of available templates.
You will find a .env.example in the root of your new LangGraph app. Create a .env file in the root of your new LangGraph app and copy the contents of the .env.example file into it, filling in the necessary API keys:
> Ready!>> - API: [http://localhost:2024](http://localhost:2024/)>> - Docs: http://localhost:2024/docs>> - Studio Web UI: https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024
The langgraph dev command starts Agent Server in an in-memory mode. This mode is suitable for development and testing purposes.
For production use, deploy Agent Server with a persistent storage backend. For more information, refer to the LangSmith platform options.To understand when to use langgraph dev vs langgraph up, see the Local development & testing guide.
from langgraph_sdk import get_clientimport asyncioclient = get_client(url="http://localhost:2024")async def main(): async for chunk in client.runs.stream( None, # Threadless run "agent", # Name of assistant. Defined in langgraph.json. input={ "messages": [{ "role": "human", "content": "What is LangGraph?", }], }, ): print(f"Receiving new event of type: {chunk.event}...") print(chunk.data) print("\n\n")asyncio.run(main())
Install the LangGraph Python SDK:
pip install langgraph-sdk
Send a message to the assistant (threadless run):
from langgraph_sdk import get_sync_clientclient = get_sync_client(url="http://localhost:2024")for chunk in client.runs.stream( None, # Threadless run "agent", # Name of assistant. Defined in langgraph.json. input={ "messages": [{ "role": "human", "content": "What is LangGraph?", }], }, stream_mode="messages-tuple",): print(f"Receiving new event of type: {chunk.event}...") print(chunk.data) print("\n\n")
Install the LangGraph JS SDK:
npm install @langchain/langgraph-sdk
Send a message to the assistant (threadless run):
const { Client } = await import("@langchain/langgraph-sdk");// only set the apiUrl if you changed the default port when calling langgraph devconst client = new Client({ apiUrl: "http://localhost:2024"});const streamResponse = client.runs.stream( null, // Threadless run "agent", // Assistant ID { input: { "messages": [ { "role": "user", "content": "What is LangGraph?"} ] }, streamMode: "messages-tuple", });for await (const chunk of streamResponse) { console.log(`Receiving new event of type: ${chunk.event}...`); console.log(JSON.stringify(chunk.data)); console.log("\n\n");}