cp ".env copy" .envLANGGRAPH_URL=https://your-actual-deployment-url.langchain.com
LANGCHAIN_API_KEY=lsv2_pt_your-actual-api-key-here
LANGSMITH_API_KEY=lsv2_pt_your-actual-api-key-here
LANGCHAIN_TRACING_V2=true
OPENAI_API_KEY=sk-your-openai-keyNEXT_PUBLIC_COPILOT_API_KEY=
NEXT_PUBLIC_COPILOTKIT_RUNTIME_URL=https://your-actual-deployment-url.langchain.com
NEXT_PUBLIC_COPILOTKIT_AGENT_NAME=agentFrom LangSmith (https://smith.langchain.com/):
- Go to Settings → API Keys
- Copy key starting with
lsv2_pt_
From LangGraph Platform:
- Copy your deployment URL (ends with
.langchain.com)
cd web
npm run dev- API key MUST start with
lsv2_pt_ - URL MUST be your exact deployment URL
- Both .env files MUST have the SAME deployment URL
node test-connection.jsThis will verify your deployment URL and API key work BEFORE starting the frontend.
Once configured, run your frontend:
# Install dependencies (if not already done)
cd web && npm install
# Start the development server
npm run devYour app will run at http://localhost:3000 and connect to your deployed LangGraph agent!
- User Input: User types in the CopilotKit chat interface
- API Route: Request goes to
/api/copilotkit(route.ts) - LangGraph SDK: Direct connection to your deployed agent using
@langchain/langgraph-sdk - Streaming Response: Real-time streaming of agent responses back to the UI
- Replaced CopilotKit LangGraphAgent: Now using direct SDK connection
- Minimal Code Changes: Only route.ts modified for maximum simplicity
- Environment-Based: Easy switching between local and deployed agents
- Your deployed agent on LangGraph Platform is fully managed
- All tools and capabilities from your
agents.pyare available - Frontend runs locally but connects to your cloud deployment
- Perfect for development while using production agent infrastructure
- Connection Issues: Verify
LANGGRAPH_URLis correct and accessible - Auth Errors: Check
LANGCHAIN_API_KEYis valid - Agent Not Found: Ensure agent name "agent" matches your deployment
Your deployment is ready! 🎉