js-langsmith in the deployment cookbook.
What you are deploying
A LangSmith Deployment runs a LangGraph graph on LangSmith’s hosted Agent Server. In this example:agent/contains the deep agent graph, subagents, middleware, and tools.langgraph.jsontells the LangGraph CLI which graph to serve and deploy.src/contains the React chat UI.- The UI talks to the Agent Server API through the LangGraph SDK and
@langchain/react.
researcheruses the localsearch_webtool.math-whizuses the localcalculatortool.
How the pieces fit
During local development,pnpm run dev starts both the LangGraph dev server and the Vite app. In production, LangSmith hosts the agent and a static host serves the Vite-built UI.
Prerequisites
- A LangSmith API key with deployment access.
- An OpenAI API key for the agent model.
pnpm.
Run locally
Create your environment file
.env and set:LANGSMITH_API_KEY and VITE_AGENT_API_URL empty for local development. You only need LANGSMITH_API_KEY when deploying or testing the UI against a remote LangSmith deployment.Start the agent and UI
- LangGraph dev server at http://localhost:2024.
- Vite dev server at http://localhost:5173.
Open the chat
Open http://localhost:5173. Try a prompt that uses both subagents:When
VITE_AGENT_API_URL is empty, the Vite app uses its local proxy at /api/langgraph, which forwards requests to the LangGraph dev server and avoids CORS issues.Deploy the agent to LangSmith
Confirm your environment
Your Optionally set a deployment name:If
.env must include:LANGSMITH_DEPLOYMENT_NAME is unset, the deployment name defaults to the directory name.Deploy the agent to LangSmith
langgraphjs deploy. The CLI uses langgraph.json to deploy the agent graph from agent/index.ts.Copy the deployment API URL
After deploy, open the deployment in LangSmith and copy its API URL. It should look like:Use the root URL only. Do not add any API path suffix.
Deploy the frontend
The agent and the UI deploy separately. Afterpnpm run deploy succeeds, host the Vite build (dist/) on any static platform and point it at your LangSmith deployment URL.
- Vercel
- Netlify
- Cloudflare Pages
Import the repository
Click Deploy with Vercel below, or import 
langchain-ai/deployment-cookbook manually.Troubleshooting
pnpm run devstarts but the UI cannot connect: leaveVITE_AGENT_API_URLempty for local dev, then restartpnpm run dev.- The agent fails to answer locally: confirm
OPENAI_API_KEYis set in.env. pnpm run deployfails with an auth error: confirmLANGSMITH_API_KEYhas deployment access.- The remote UI fails to connect: confirm
VITE_AGENT_API_URLis the deployment root URL with no path suffix. - Threads disappear after restarting local dev: local
langgraph devuses the in-memoryMemorySaver; LangSmith Deployment provides durable storage in production. - You changed files in
agent/but production did not change: runpnpm run deployagain.
Learn about the project
Agent files
Agent files
The LangSmith backend lives in
agent/:agent/index.ts exports the graph that LangGraph serves locally and LangSmith deploys. The local MemorySaver checkpointer is only used by langgraph dev. LangSmith Deployment replaces it with durable Postgres-backed storage in production without code changes.LangGraph config
LangGraph config
langgraph.json points the CLI at the graph:agent. The frontend uses that id as the assistant id when streaming.Chat UI
Chat UI
The React app in
src/ provides streaming chat, thread history, subagent rendering, and tool-call rendering.The frontend uses:client.threads.search()for the thread sidebar.client.threads.create()andclient.threads.delete()for conversation management.StreamProviderwithassistantId: "agent"for streaming chat.
Local commands
Local commands
Run both local processes:Run them separately:Build and preview the frontend:
CI/CD
CI/CD
The agent deploys via GitHub Actions when files under
js-langsmith/agent/ or shared config files change:- Workflow:
.github/workflows/deploy-langsmith-agent.yml - Action:
langgraphjs deployto LangSmith. - Required secret:
LANGSMITH_API_KEY. - Optional variable:
LANGSMITH_DEPLOYMENT_NAME.
See also
- Frameworks and platforms overview
- LangSmith Deployment overview
- LangGraph CLI
- Deep Agents going to production
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

