#What's recommended integration with Langgraph?
1 messages · Page 1 of 1 (latest)
This solution has been AI generated
The recommended approach is to use CopilotKit's LangGraphAgent and point it at your LangGraph Server. CopilotKit handles streaming (SSE), tool calls, and multi‑turn state out of the box. Configure either LangGraph Platform (cloud) or a self‑hosted endpoint.
Integration options
- LangGraph Platform (cloud)
- Self‑hosted LangGraph Server (FastAPI)
Server route (Next.js / Node) — LangGraph Platform
// app/api/copilotkit/route.ts
import { CopilotRuntime, LangGraphAgent } from "@copilotkit/runtime";
const agent = new LangGraphAgent({
name: "my_agent",
description: "My LG agent",
langGraphPlatformEndpoint: "https://<your-deployment>.langchain.app",
langGraphPlatformApiKey: process.env.LANGGRAPH_API_KEY,
});
const runtime = new CopilotRuntime();
export const POST = runtime.streamHttpServerResponse(agent);
Server route — Self‑hosted LangGraph
import { CopilotRuntime, LangGraphAgent } from "@copilotkit/runtime";
const agent = new LangGraphAgent({
name: "my_agent",
description: "My LG agent",
langGraphEndpoint: "http://localhost:8000", // your FastAPI server
});
const runtime = new CopilotRuntime();
export const POST = runtime.streamHttpServerResponse(agent);
Frontend hookup (React)
import { CopilotKit } from "@copilotkit/react-core";
import { CopilotChat } from "@copilotkit/react-ui";
export default function App() {
return (
<CopilotKit runtimeUrl="/api/copilotkit">
<CopilotChat labels={{ title: "LangGraph Agent", initial: "Hi!" }} />
</CopilotKit>
);
}
Notes
- Protocols: CopilotKit uses SSE for real‑time streaming; WebSocket is supported via LangGraph Platform.
- Auth: Provide LANGGRAPH_API_KEY for Platform; for self‑hosting, secure your FastAPI server as needed.
- Features: Streaming respon
Was this helpful?
If this solution worked for you, please click on the appropriate option below to help us improve:
Thank you for your feedback! Our team will provide additional assistance. 🔄
I need to see the complete setup, routing, agent targeting etc within the Langgraph server and how to confirm the connection is working
What needs to be installed altogether for this to work
Also AG-UI integration documentation
I would like to use Copilotkit primarily to support AG-UI integration with Langgraph
Hi @clever quartz, As of now there is no AG-UI integration docs yet. But this Github repo has a basic setup and all you have asked for in a simpler way.
https://github.com/CopilotKit/with-langgraph-fastapi
If you have any questions on it, please reach out here.
what of if i do want to self host the runtime on node and not use fastapi
You can use the runtime on NodeJs. But for actual Agent development u need to use the fastapi or the respective js frameworks.
got you, currently using the runtime on Nodejs and connecting to my remote deployed agent url
What changes would be needed to support Gemini using the basic langgraph project above? In particular a Gemini adapter is that configured in app/api/copilotkit/route.js what should be routes settings for Gemini?