Starlette
app (including FastAPI
, FastHTML
and other compatible apps). You make LangGraph Platform aware of this by providing a path to the app in your langgraph.json
configuration file.
Defining a custom app object lets you add any routes you’d like, so you can do anything from adding a /login
endpoint to writing an entire full-stack web-app, all deployed in a single LangGraph Server.
Below is an example using FastAPI.
Create app
Starting from an existing LangGraph Platform application, add the following custom route code to yourwebapp.py
file. If you are starting from scratch, you can create a new app from a template using the CLI.
Configure langgraph.json
Add the following to your langgraph.json
configuration file. Make sure the path points to the FastAPI application instance app
in the webapp.py
file you created above.
Start server
Test the server out locally:localhost:2024/hello
in your browser (2024
is the default development port), you should see the /hello
endpoint returning {"Hello": "World"}
.
Shadowing default endpoints
The routes you create in the app are given priority over the system defaults, meaning you can shadow and redefine the behavior of any default endpoint.