#What's recommended integration with Langgraph?

1 messages · Page 1 of 1 (latest)

clever quartz
#

Hey guys, after debugging for days without a debug mode for the sdk or tracing I am now going to start over. What's recommended integration approach with Langgraph? Assuming LG agent is running in langgraph server?

eternal moatBOT
#

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. 🔄

clever quartz
#

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

muted hinge
fair olive
#

what of if i do want to self host the runtime on node and not use fastapi

eternal moatBOT
#

You can use the runtime on NodeJs. But for actual Agent development u need to use the fastapi or the respective js frameworks.

fair olive
#

got you, currently using the runtime on Nodejs and connecting to my remote deployed agent url

clever quartz
#

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?