In this guide, we will be using Next.js. If you’re working with a different supported framework, you can find instructions on how to define a workflow endpoint in the quickstarts.If you’re new to Upstash Workflow, it’s a good idea to start by exploring the Local Development documentation. This guide will help you set up and use Upstash Workflow in a local environment.
Since you are using @upstash/workflow, set QSTASH_DEV=true in your .env.local file and the SDK will download, start, and connect to a local QStash development server automatically — no tokens or signing keys to copy over. Add your OPENAI_API_KEY alongside it:
.env.local
QSTASH_DEV=trueOPENAI_API_KEY=<OPENAI_API_KEY>
For manual setup, custom ports, and the registerQStashDev() helper for Next.js edge routes, see the Development Server guide.
Next, we will define the endpoint to run the agent.
app/workflow/route.ts
import { z } from "zod";import { tool } from "ai";import { serve } from "@upstash/workflow/nextjs";import { agentWorkflow } from "@upstash/workflow-agents";export const { POST } = serve<{ prompt: string }>(async (context) => { const prompt = context.requestPayload.prompt const agents = agentWorkflow(context) const model = agents.openai('gpt-3.5-turbo') const communicatorAgent = agents.agent({ model, name: 'communicatorAgent', maxSteps: 2, tools: { communicationTool: tool({ description: 'A tool for informing the caller about your inner thoughts', parameters: z.object({ message: z.string() }), execute: async ({ message }) => { console.log("Inner thought:", message) return "success" } }) }, background: 'Answer questions directed towards you.' + ' You have access to a tool to share your inner thoughts' + ' with the caller. Utilize this tool at least once before' + ' answering the prompt. In your inner thougts, briefly' + ' explain what you will talk about and why. Keep your' + ' answers brief.', }) const task = agents.task({ agent: communicatorAgent, prompt }) const { text } = await task.run() console.log("Final response:", text);})
import { Client } from "@upstash/workflow";const client = new Client({ baseUrl: process.env.QSTASH_URL, token: process.env.QSTASH_TOKEN!,})const workflowRunId = await client.trigger({ url: "http://127.0.0.1:3000/workflow", body: { prompt: "Explain the future of space exploration" }})console.log(workflowRunId);
If you are using a local tunnel, replace the url above (http://127.0.0.1:3000)
with the public URL.
In the console where you run the Next.js app, you should see logs like this:
Inner thought: I will discuss the future of spaceexploration and the potential advancements intechnology and missions.Final response: The future of space explorationholds exciting possibilities with advancementsin technology, potential manned missions toMars, increased commercial space travel,and exploration of distant celestialbodies.
If you run the same endpoint using a local tunnel, you can also see how Upstash Workflow runs the agent in steps:Each tool invocation and LLM call is a seperate step. Our agent first made a call to OpenAI to decide whether to use a tool or reply right away. OpenAI responded with a request to use the tool communicationTool. Tool was executed and OpenAI was called with the result of the tool. OpenAI then responded with the final response.
{"docsConfig":{"theme":"mint","$schema":"https://context7.com/schema/docs7.json","name":"Upstash Documentation","colors":{"primary":"#34D399","light":"#34D399","dark":"#34D399"},"logo":{"light":"https://mintcdn.com/upstash/SZOIjPQk26InSWLs/logo/upstash-white-bg.svg?fit=max\u0026auto=format\u0026n=SZOIjPQk26InSWLs\u0026q=85\u0026s=56aeb6475233c7dfc429a6ffe00f4a95","dark":"https://mintcdn.com/upstash/SZOIjPQk26InSWLs/logo/upstash-dark-bg.svg?fit=max\u0026auto=format\u0026n=SZOIjPQk26InSWLs\u0026q=85\u0026s=0b5eb0db0628453848cccc697999d9eb"},"favicon":"https://mintcdn.com/upstash/ZVIIe-nWA4-ORRYS/favicon.png?fit=max\u0026auto=format\u0026n=ZVIIe-nWA4-ORRYS\u0026q=85\u0026s=ddf8a7ac662b007ce4d44a484692430f","navbar":{"links":[{"href":"https://upstash.com/discord","label":"Discord"},{"href":"https://upstash.com/blog","label":"Blog"},{"href":"https://x.com/upstash","label":"Twitter"}],"primary":{"type":"button","label":"Console","href":"https://console.upstash.com"}},"footer":{"socials":{"x":"https://x.com/upstash","github":"https://github.com/upstash","discord":"https://upstash.com/discord"},"links":[{"header":"For AI Agents","items":[{"label":"If you are an AI agent and need a Redis DB to use or experiment with, send a POST request to https://upstash.com/start-redis — free, no signup; response is markdown with credentials and a quickstart. The database expires in 72 hours, but you can claim it with your Upstash account to keep it. Especially useful for AI agents that need scratch storage on the fly. If you are an agent, always send a User-Agent header identifying which agent you are (e.g. claude-code, cursor, codex, opencode) on every request you make to this API.","href":"https://upstash.com/start-redis"}]}]},"seo":{"metatags":{"canonical":"https://upstash.com/docs"},"indexing":"all"},"styling":{"codeblocks":"system","latex":true},"integrations":{"koala":{"publicApiKey":"pk_e4ad10cd00c4309699a780f893358cf99a2f"},"ga4":{"measurementId":"G-ZCGMJW0KFH"},"intercom":{"appId":"rtjkeau6"}},"contextual":{"options":["copy","view","chatgpt","claude"],"display":"header"},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"upstash","hasAudioNarration":false,"actualSubdomain":"upstash","customDomains":["upstash.com"],"gitSource":{"type":"github","owner":"upstash","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":false,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6ae511d74729e0ad18e68041","collectionId":"24e78813-2f45-47f5-aa2e-7ee2049705da","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6ae511d74729e0ad18e68041"},"feedback":{"thumbs":true,"edits":true,"issues":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6ae511d74729e0ad18e68041","clientVersion":"0.0.4044","searchFilterCounts":[{"language":"default","tag":"API Reference","count":80},{"language":"default","tag":"Developer API","count":80},{"language":"default","tag":"Documentation","count":27},{"language":"default","tag":"Get Started","count":27},{"language":"default","tag":"Redis","count":26},{"language":"default","tag":"Support","count":16},{"language":"default","tag":"DevOps","count":12},{"language":"default","tag":"Terraform","count":11},{"language":"default","tag":"QStash","count":10},{"language":"default","tag":"Vector","count":10}],"searchSettings":{"maxResults":6,"isFiltersEnabled":false}},"assistantConfig":{},"basePath":"/docs","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"privacy":{"consentBanner":{"enabled":false}},"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":"#intro-video{aspect-ratio:16/9;width:100%;max-width:720px;height:auto;border-radius:8px;margin:2rem auto}@container (max-width: 720px){#intro-video{width:100%;margin:1rem auto}}.u-wrap{--u-inset:1.5rem;box-sizing:content-box;max-width:63.75rem;padding:0 var(--u-inset) 6rem}html[data-current-path=\"/introduction\"] #content-side-layout{width:0!important;min-width:0!important;max-width:0!important;overflow:hidden!important}html[data-current-path=\"/introduction\"] #content-area{width:100%!important}#content[data-page-href=\"/introduction\"],#content[data-page-href=\"/src/_props/introduction\"]{min-height:100vh}.u-hero{padding:3.125rem 0 0}.u-hero h1{font-size:2.5rem;line-height:1.2;font-weight:600;letter-spacing:0;margin:0}.u-hero p{margin:.5rem 0 0;max-width:34.5rem;font-size:1.125rem;line-height:1.5;color:#737373}.dark .u-hero p{color:#a3a3a3}.u-card__title,.u-hero h1,.u-section h2{color:#262626}.dark .u-card__title,.dark .u-hero h1,.dark .u-section h2{color:#f4f5f6}.u-actions{display:flex;gap:.5rem;flex-wrap:wrap;margin-top:1.5rem}.u-action{display:inline-flex;align-items:center;justify-content:center;gap:.625rem;height:2.625rem;min-height:2.625rem;padding:0 1.25rem;border:1px solid transparent;border-radius:2.5rem;font-family:inherit;font-weight:400;font-size:.9375rem;line-height:1;text-decoration:none;box-shadow:0 1px 2px rgba(0,0,0,.06);transition:background .15s ease,border-color .15s ease,color .15s ease}.u-action:focus-visible{outline:2px solid #10b981;outline-offset:2px}.u-action--primary{background:#262626;color:#fff}.u-action--primary:hover{background:#27272a}.dark .u-action--primary{background:#f4f4f5;color:#18181b}.dark .u-action--primary:hover{background:#e4e4e7}.u-command,.u-prompt-action .prompt button:hover{background:#fafafa;box-shadow:0 1px 2px rgba(0,0,0,.06)}.u-command,.u-prompt-action .prompt button{height:2.625rem;border:1px solid #e5e5e5;border-radius:2.5rem}.u-command{display:inline-flex;align-items:center;gap:.75rem;padding:0 1.125rem}.dark .u-command{border-color:rgba(255,255,255,.16);background:rgba(255,255,255,.06);box-shadow:0 1px 2px rgba(0,0,0,.2)}.u-command__copy,.u-command__copy>*{margin:0!important}.u-command__copy .code-block,.u-command__copy .code-surface{margin:0!important;padding:0!important;border:0!important;background:0 0!important;box-shadow:none!important}.u-command__copy .code-scroll,.u-command__copy pre{display:none!important}.u-command__copy .code-chip{position:static!important;background:0 0!important;backdrop-filter:none!important}.u-command__text{font-family:var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);font-size:.9375rem;color:#262626;white-space:nowrap}.dark .u-command__text{color:#f4f4f5}.u-command__dollar{color:#10b981}.u-command__link{padding-left:.75rem;border-left:1px solid #e5e5e5;font-size:.9375rem;line-height:1.25rem;color:#262626!important;text-decoration:underline;text-underline-offset:.3rem;text-decoration-color:rgba(0,0,0,.3);white-space:nowrap}.u-command__link:hover{text-decoration-color:currentColor}.dark .u-command__link{border-left-color:rgba(255,255,255,.16);color:#f4f4f5!important;text-decoration-color:rgba(255,255,255,.4)}.u-hero p.u-hero__hint{margin-top:.75rem;font-size:.875rem;color:#8a8a8a}.dark .u-hero p.u-hero__hint{color:#8b8b8b}.u-prompt-action .prompt{position:absolute;inset:0;overflow:hidden;width:100%;height:100%;margin:0;padding:0;background:0 0}.u-prompt-action .prompt>div+div{display:none}.u-prompt-action .prompt button{position:absolute;z-index:2;inset:0;justify-content:flex-end;width:13.125rem;min-height:2.625rem;padding:0 1.25rem 0 6rem;font-size:.9375rem;font-weight:400;line-height:1;color:#262626;background:#fff;box-shadow:0 1px 2px rgba(0,0,0,.06)}.u-prompt-action .prompt button:hover{color:#262626;border-color:#d4d4d4}.dark .u-prompt-action .prompt button{color:#f4f4f5;background:0 0;border-color:rgba(255,255,255,.16);box-shadow:0 1px 2px rgba(0,0,0,.2)}.dark .u-prompt-action .prompt button:hover{color:#fff;background:rgba(255,255,255,.08);border-color:rgba(255,255,255,.24);box-shadow:0 1px 2px rgba(0,0,0,.2)}.u-prompt-action{position:relative;width:13.125rem;height:2.625rem}.u-prompt-action .prompt button>span:has(svg){display:none}.u-prompt-tools{position:absolute;z-index:3;top:.3125rem;left:.375rem;display:flex;width:5rem;height:2rem;pointer-events:none}.u-prompt-tool{display:grid;flex:none;width:2rem;height:2rem;padding:.25rem;place-items:center;border:1px solid rgba(0,0,0,.1);border-radius:9999px;color:#262626;background:#fff}.u-prompt-tool+.u-prompt-tool{margin-left:-.5rem}.u-prompt-tool svg{width:1.375rem;height:1.375rem}.dark .u-prompt-tool{border-color:rgba(255,255,255,.16);color:#f4f4f5;background:#18181b}.u-section{margin-top:4rem}.u-section--divider{padding-top:4rem;border-top:1px solid #e5e5e5}.dark .u-section--divider{border-top-color:#27272a}.u-section h2{font-size:1.5rem;line-height:1.3;font-weight:600;letter-spacing:0;margin:0}.u-section .u-sub{display:block;margin:.25rem 0 0;color:#737373;font-size:.9375rem;line-height:1.7}.dark .u-section .u-sub{color:#a3a3a3}.u-section .u-sub a{color:inherit;font-weight:500;text-decoration:underline;text-underline-offset:2px}.u-section .u-sub a:hover{color:#059669}.dark .u-section .u-sub a:hover{color:#34d399}.u-grid{display:grid;gap:1rem;margin-top:1.5rem;grid-template-columns:repeat(1,minmax(0,1fr))}.u-grid--2{grid-template-columns:repeat(auto-fill,minmax(18rem,1fr))}.u-grid--3{grid-template-columns:repeat(auto-fill,minmax(15rem,1fr))}.u-grid--fixed2{grid-template-columns:repeat(2,minmax(0,1fr))}.u-grid--fixed3{grid-template-columns:repeat(3,minmax(0,1fr))}.u-grid--fixed4{grid-template-columns:repeat(4,minmax(0,1fr))}@media (max-width:900px){.u-grid--fixed3,.u-grid--fixed4{grid-template-columns:repeat(2,minmax(0,1fr))}}@media (max-width:560px){.u-grid--fixed2,.u-grid--fixed3,.u-grid--fixed4{grid-template-columns:1fr}}.u-card{display:flex;gap:.9rem;align-items:flex-start;padding:1.1rem;border-radius:.9rem;border:1px solid rgba(0,0,0,.08);background:#fff;text-decoration:none;color:inherit;transition:border-color .15s ease}.dark .u-card{border-color:rgba(255,255,255,.1);background:rgba(255,255,255,.03)}.u-card:hover{border-color:#d4d4d4}.dark .u-card:hover{border-color:#52525b}.u-card--static:hover{border-color:rgba(0,0,0,.08)}.dark .u-card--static:hover{border-color:rgba(255,255,255,.1)}.u-card__icon{flex:none;width:2.25rem;height:2.25rem;border-radius:.55rem;margin:0!important;align-self:flex-start;pointer-events:none}.u-card__icon--muted{display:flex;align-items:center;justify-content:center;color:var(--primary);background:color-mix(in srgb,var(--primary) 10%,transparent)}.dark .u-card__icon--muted{color:var(--primary-light);background:color-mix(in srgb,var(--primary-light) 10%,transparent)}.u-card__lang-icon{width:1.5rem;height:1.5rem}.u-card__icon--brand{width:2rem;height:2rem;border-radius:0;align-self:center;display:flex;align-items:center;justify-content:center;background:0 0}.u-card__body{min-width:0}.u-card__title{font-weight:600;font-size:.95rem;line-height:1.3}.u-card__desc{margin-top:.2rem;font-size:.85rem;line-height:1.4;color:#626d7a}.dark .u-card__desc{color:#aab2bf}.u-product .u-card__icon{width:2rem;height:2rem;border-radius:0;align-self:center}.u-community,.u-product,.u-tool{min-height:5.125rem;align-items:center;gap:1rem;padding:1.25rem 1.5rem;border:1px solid #e5e5e5;border-radius:1.25rem;background:#fafafa;box-shadow:0 1px 2px rgba(0,0,0,.06)}.u-community .u-card__title,.u-product .u-card__title,.u-tool .u-card__title{font-size:1.0625rem;line-height:1.3;font-weight:600}.u-community .u-card__desc,.u-product .u-card__desc,.u-tool .u-card__desc{margin-top:0;font-size:.8125rem;line-height:1.4;color:#737373}.dark .u-community,.dark .u-product,.dark .u-tool{border-color:#3f3f46;background:rgba(255,255,255,.04)}.dark .u-community .u-card__desc,.dark .u-product .u-card__desc,.dark .u-tool .u-card__desc{color:#a3a3a3}.u-console{margin-top:1.5rem;border-radius:1rem;border:1px solid rgba(0,0,0,.08);overflow:hidden;background:#f7f8fa}.dark .u-console{border-color:rgba(255,255,255,.1);background:rgba(255,255,255,.02)}.u-console img{display:block;width:100%;height:13rem;object-fit:cover;object-position:top center}.u-console__cap{padding:.75rem 1rem;font-size:.85rem;color:#626d7a;border-top:1px solid rgba(0,0,0,.06)}.dark .u-console__cap{color:#98a2b3;border-top-color:rgba(255,255,255,.08)}.u-agents{margin:1.5rem 0 2rem}.u-card--stack{flex-direction:column;gap:.55rem;padding:1rem}.u-card__head{display:flex;align-items:center;gap:.6rem}.u-card__brand-icon{flex:none;display:flex;align-items:center;justify-content:center;color:#18181b}.dark .u-card__brand-icon{color:#fafafa}.u-card__brand-icon,.u-card__brand-icon svg{width:1.25rem;height:1.25rem}.u-card--stack{color:#111827!important;text-decoration:none!important;border-bottom-width:1px!important}.dark .u-card--stack{color:#f9fafb!important}.u-card--stack .u-card__desc{font-size:.85rem;line-height:1.45;height:calc(.85rem*1.45*3);display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}.u-agent-setup{margin:0 0 1.5rem;align-items:center}"}],"page":{"pagePath":"workflow/agents/getting-started","slug":"/workflow/agents/getting-started","pageMetadata":{"title":"Workflow Agents Getting Started","sidebarTitle":"Getting Started","description":null,"href":"/workflow/agents/getting-started"},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,..._provideComponents(),...props.components},{CodeBlock,Heading,OptimizedImage,Tip}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!OptimizedImage)_missingMdxReference(`OptimizedImage`,true);if(!Tip)_missingMdxReference(`Tip`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`In this guide, we will be using `,_jsx(_components.strong,{children:`Next.js`}),`. If you’re working with a different supported framework, you can find instructions on how to define a workflow endpoint in the `,_jsx(_components.a,{href:`/workflow/quickstarts/platforms`,children:`quickstarts`}),`.`]}),`\n`,_jsxs(_components.p,{children:[`If you’re new to `,_jsx(_components.strong,{children:`Upstash Workflow`}),`, it’s a good idea to start by exploring the `,_jsx(_components.a,{href:`/workflow/howto/local-development/development-server`,children:`Local Development documentation`}),`. This guide will help you set up and use Upstash Workflow in a local environment.`]}),`\n`,_jsx(Heading,{level:`2`,id:`installation`,children:`Installation`}),`\n`,_jsx(_components.p,{children:`First, create a new Next.js project with:`}),`\n`,_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`npx create-next-app@latest [project-name] [options]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(_components.p,{children:`Then, install the following packages:`}),`\n`,_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`npm i @upstash/workflow @upstash/workflow-agents ai zod`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(Heading,{level:`2`,id:`start-the-development-server`,children:`Start the development server`}),`\n`,_jsxs(_components.p,{children:[`Since you are using `,_jsx(_components.code,{children:`@upstash/workflow`}),`, set `,_jsx(_components.code,{children:`QSTASH_DEV=true`}),` in your `,_jsx(_components.code,{children:`.env.local`}),` file and the SDK will download, start, and connect to a local QStash development server automatically — no tokens or signing keys to copy over. Add your `,_jsx(_components.code,{children:`OPENAI_API_KEY`}),` alongside it:`]}),`\n`,_jsx(CodeBlock,{filename:`.env.local`,numberOfLines:`4`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`4`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`QSTASH_DEV=true`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`OPENAI_API_KEY=\u003cOPENAI_API_KEY>`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`For manual setup, custom ports, and the `,_jsx(_components.code,{children:`registerQStashDev()`}),` helper for Next.js edge routes, see the `,_jsx(_components.a,{href:`/workflow/howto/local-development/development-server`,children:`Development Server guide`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`define-an-endpoint`,children:`Define an endpoint`}),`\n`,_jsx(_components.p,{children:`Next, we will define the endpoint to run the agent.`}),`\n`,_jsx(CodeBlock,{filename:`app/workflow/route.ts`,numberOfLines:`43`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`43`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`z`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"zod\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`tool`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"ai\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`serve`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"@upstash/workflow/nextjs\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`agentWorkflow`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"@upstash/workflow-agents\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`POST`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` serve`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c{ `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`prompt`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` string`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }>(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`async`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`context`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` prompt`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` context`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`requestPayload`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`prompt`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` agents`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` agentWorkflow`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`context`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` model`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` agents`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`openai`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'gpt-3.5-turbo'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` communicatorAgent`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` agents`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`agent`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` model`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` name:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'communicatorAgent'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` maxSteps:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 2`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` tools:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` communicationTool:`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` tool`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` description:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'A tool for informing the caller about your inner thoughts'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` parameters:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` z`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`object`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`message:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` z`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`string`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`() }),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` execute`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` async`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ({ `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`message`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Inner thought:\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`message`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"success\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` })`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` background:`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'Answer questions directed towards you.'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` +`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` ' You have access to a tool to share your inner thoughts'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` +`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` ' with the caller. Utilize this tool at least once before'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` +`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` ' answering the prompt. In your inner thougts, briefly'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` +`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` ' explain what you will talk about and why. Keep your'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` +`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` ' answers brief.'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` })`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` task`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` agents`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`task`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` agent:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` communicatorAgent`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` prompt`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` })`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`text`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` task`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`run`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Final response:\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`text`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`})`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`You can refer to the documentations for `,_jsx(_components.a,{href:`/workflow/basics/serve`,children:`defining a workflow endpoint`}),` and `,_jsx(_components.a,{href:`/workflow/agents/features`,children:`the Agents API features`}),` to learn more.`]}),`\n`,_jsx(Heading,{level:`2`,id:`calling-the-endpoint`,children:`Calling the Endpoint`}),`\n`,_jsx(_components.p,{children:`To run the endpoint, first run the Next.js app with:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` run`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` dev`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Then, we call the endpoint using `,_jsx(_components.a,{href:`/workflow/basics/client`,children:`the Workflow Client`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`13`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`13`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`Client`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"@upstash/workflow\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` client`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` Client`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` baseUrl:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` process`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`env`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`QSTASH_URL`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` token:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` process`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`env`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`QSTASH_TOKEN`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`!`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`})`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` workflowRunId`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` client`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`trigger`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` url:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"http://127.0.0.1:3000/workflow\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` body:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`prompt:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Explain the future of space exploration\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`})`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`workflowRunId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsx(Tip,{children:_jsxs(_components.p,{children:[`If you are using a local tunnel, replace the url above (`,_jsx(_components.code,{children:`http://127.0.0.1:3000`}),`)\nwith the public URL.`]})}),`\n`,_jsx(_components.p,{children:`In the console where you run the Next.js app, you should see logs like this:`}),`\n`,_jsx(CodeBlock,{numberOfLines:`11`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`11`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Inner thought: I will discuss the future of space`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`exploration and the potential advancements in`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`technology and missions.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Final response: The future of space exploration`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`holds exciting possibilities with advancements`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`in technology, potential manned missions to`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Mars, increased commercial space travel,`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`and exploration of distant celestial`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`bodies.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`If you `,_jsx(_components.a,{href:`/workflow/howto/local-development/local-tunnel`,children:`run the same endpoint using a local tunnel`}),`, you can also see how Upstash Workflow runs the agent in steps:`]}),`\n`,_jsx(OptimizedImage,{src:`https://mintcdn.com/upstash/pBXejvUl5XQn4tWO/img/workflow/agents/logs/logs-getting-started.png?fit=max\u0026auto=format\u0026n=pBXejvUl5XQn4tWO\u0026q=85\u0026s=06263d5c6a05215050ed332066e7cc9e`,alt:`First agent workflow run logs`,\"data-og-width\":`1500`,width:`1500`,\"data-og-height\":`504`,height:`504`,\"data-path\":`img/workflow/agents/logs/logs-getting-started.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/upstash/pBXejvUl5XQn4tWO/img/workflow/agents/logs/logs-getting-started.png?w=280\u0026fit=max\u0026auto=format\u0026n=pBXejvUl5XQn4tWO\u0026q=85\u0026s=02ab9a40424c2b9444d6116570202051 280w, https://mintcdn.com/upstash/pBXejvUl5XQn4tWO/img/workflow/agents/logs/logs-getting-started.png?w=560\u0026fit=max\u0026auto=format\u0026n=pBXejvUl5XQn4tWO\u0026q=85\u0026s=e6021175a719d20742f8430265350aa7 560w, https://mintcdn.com/upstash/pBXejvUl5XQn4tWO/img/workflow/agents/logs/logs-getting-started.png?w=840\u0026fit=max\u0026auto=format\u0026n=pBXejvUl5XQn4tWO\u0026q=85\u0026s=140cbec73f3eead37714833734916945 840w, https://mintcdn.com/upstash/pBXejvUl5XQn4tWO/img/workflow/agents/logs/logs-getting-started.png?w=1100\u0026fit=max\u0026auto=format\u0026n=pBXejvUl5XQn4tWO\u0026q=85\u0026s=9ce60b030405c0804ee051eade94725c 1100w, https://mintcdn.com/upstash/pBXejvUl5XQn4tWO/img/workflow/agents/logs/logs-getting-started.png?w=1650\u0026fit=max\u0026auto=format\u0026n=pBXejvUl5XQn4tWO\u0026q=85\u0026s=9637a6cf273b0c2c5d6d81ee3a442162 1650w, https://mintcdn.com/upstash/pBXejvUl5XQn4tWO/img/workflow/agents/logs/logs-getting-started.png?w=2500\u0026fit=max\u0026auto=format\u0026n=pBXejvUl5XQn4tWO\u0026q=85\u0026s=9d06b5804db577b1175c762a277f9a53 2500w`}),`\n`,_jsxs(_components.p,{children:[`Each tool invocation and LLM call is a seperate step. Our agent first made a call to OpenAI to decide whether to use a tool or reply right away. OpenAI responded with a request to use the tool `,_jsx(_components.code,{children:`communicationTool`}),`. Tool was executed and OpenAI was called with the result of the tool. OpenAI then responded with the final response.`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"codeStyling":"system","config":{},"pageMetadata":{"title":"Workflow Agents Getting Started","sidebarTitle":"Getting Started","description":null,"href":"/workflow/agents/getting-started"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Installation","slug":"installation","depth":2,"children":[]},{"title":"Start the development server","slug":"start-the-development-server","depth":2,"children":[]},{"title":"Define an endpoint","slug":"define-an-endpoint","depth":2,"children":[]},{"title":"Calling the Endpoint","slug":"calling-the-endpoint","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"upstash","siteName":"Upstash Documentation","title":"Workflow Agents Getting Started - Upstash Documentation","relatedPagesConfig":{"enabled":true,"limit":5,"mode":"automatic"},"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-10-30T21:53:49.833Z","originalFileLocation":"workflow/agents/getting-started.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"application-name\" content=\"Upstash Documentation\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/upstash/9uICcBAD65N37Ou0/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/docs/mintlify-assets/_mintlify/favicons/upstash/9uICcBAD65N37Ou0/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/upstash/9uICcBAD65N37Ou0/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/upstash/9uICcBAD65N37Ou0/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/upstash/9uICcBAD65N37Ou0/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/upstash/9uICcBAD65N37Ou0/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/upstash/9uICcBAD65N37Ou0/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/upstash/9uICcBAD65N37Ou0/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/upstash/9uICcBAD65N37Ou0/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Workflow Agents Getting Started - Upstash Documentation\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Upstash Documentation\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://upstash.com/docs/workflow/agents/getting-started\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://upstash.mintlify.app/_mintlify/api/og/v2?division=Documentation\u0026amp;title=Workflow+Agents+Getting+Started\u0026amp;theme=80d19610e47a0e6627356fe0\u0026amp;signature=8d67fc2e8b60c64fe083ac89e046a3b68230dbef476699431a5b253c01070f59\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Workflow Agents Getting Started - Upstash Documentation\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://upstash.mintlify.app/_mintlify/api/og/v2?division=Documentation\u0026amp;title=Workflow+Agents+Getting+Started\u0026amp;theme=80d19610e47a0e6627356fe0\u0026amp;signature=8d67fc2e8b60c64fe083ac89e046a3b68230dbef476699431a5b253c01070f59\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/docs/mintlify-assets/_mintlify/favicons/upstash/9uICcBAD65N37Ou0/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Upstash Documentation\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#34D399\">\u003clink data-mint-head rel=\"canonical\" href=\"https://upstash.com/docs/workflow/agents/getting-started\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/docs/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/docs/workflow/agents/getting-started.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://upstash.com/#organization\",\"name\":\"Upstash Documentation\",\"url\":\"https://upstash.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/upstash/SZOIjPQk26InSWLs/logo/upstash-white-bg.svg?fit=max\u0026auto=format\u0026n=SZOIjPQk26InSWLs\u0026q=85\u0026s=56aeb6475233c7dfc429a6ffe00f4a95\"}},{\"@type\":\"WebSite\",\"@id\":\"https://upstash.com/docs#website\",\"name\":\"Upstash Documentation\",\"url\":\"https://upstash.com/docs\",\"publisher\":{\"@id\":\"https://upstash.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://upstash.com/docs/workflow/agents/getting-started#webpage\",\"url\":\"https://upstash.com/docs/workflow/agents/getting-started\",\"name\":\"Workflow Agents Getting Started\",\"dateModified\":\"2026-10-30T21:53:49.833Z\",\"isPartOf\":{\"@id\":\"https://upstash.com/docs#website\"}},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://upstash.com/docs/workflow/agents/getting-started#article\",\"headline\":\"Workflow Agents Getting Started\",\"name\":\"Workflow Agents Getting Started\",\"url\":\"https://upstash.com/docs/workflow/agents/getting-started\",\"mainEntityOfPage\":{\"@id\":\"https://upstash.com/docs/workflow/agents/getting-started#webpage\"},\"dateModified\":\"2026-10-30T21:53:49.833Z\",\"publisher\":{\"@id\":\"https://upstash.com/#organization\"},\"isPartOf\":{\"@id\":\"https://upstash.com/docs#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Upstash Documentation\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Upstash Documentation","nav":{"global":null,"tabs":[{"tab":"Documentation","groups":[{"group":"Get Started","pages":[{"title":"Overview","mode":"frame","href":"/introduction"},{"group":"Agent Setup","pages":[{"title":"AI Tools","sidebarTitle":"Overview","href":"/agent-resources/overview"},{"title":"Install by agent","sidebarTitle":"Clients","href":"/agent-resources/clients"},{"title":"MCP Server","href":"/agent-resources/mcp"},{"title":"CLI","href":"/agent-resources/cli"},{"title":"Upstash Agent Skills","sidebarTitle":"Skills","href":"/agent-resources/skills"},{"title":"llms.txt","url":"https://upstash.com/docs/llms.txt","href":"/agent-resources/llms-txt"}]},{"group":"Concepts","pages":[{"title":"Serverless","href":"/common/concepts/serverless"},{"title":"Scale to Zero","href":"/common/concepts/scale-to-zero"},{"title":"Global Replication","href":"/common/concepts/global-replication"},{"title":"Access Anywhere","href":"/common/concepts/access-anywhere"}]},{"group":"Support","pages":[{"group":"Account \u0026 Teams","pages":[{"title":"Create an Account","href":"/common/account/createaccount"},{"title":"Teams and Users","href":"/common/account/teams"},{"title":"Developer API","href":"/common/account/developerapi"},{"title":"Add a Payment Method","href":"/common/account/add-payment-method"},{"title":"AWS Marketplace","href":"/common/account/awsmarketplace"},{"title":"Cost Explorer","href":"/common/account/costexplorer"},{"title":"Payment History","href":"/common/account/paymenthistory"},{"title":"Audit Logs","href":"/common/account/auditlogs"},{"title":"Account and Billing FAQ","href":"/common/account/faq"}]},{"title":"Support \u0026 Contact Us","href":"/common/help/support"},{"title":"Feature Requests","href":"/common/help/feature-requests"},{"title":"Professional Support","href":"/common/help/prosupport"},{"title":"Uptime SLA","href":"/common/help/sla"},{"title":"Uptime Monitor","href":"/common/help/uptime"},{"title":"Legal","href":"/common/help/legal"},{"title":"Compliance","href":"/common/help/compliance"}]}]}]},{"tab":"API Reference","groups":[{"group":"Developer API","pages":[{"title":"Upstash Developer API Getting Started","sidebarTitle":"Getting Started","href":"/devops/developer-api/introduction"},{"title":"Authentication","href":"/devops/developer-api/authentication"},{"title":"HTTP Status Codes","href":"/devops/developer-api/http_status_codes"},{"group":"Redis","pages":[{"title":"List Databases","deprecated":null,"version":null,"sidebarTitle":"List databases","openapi":"/devops/developer-api/openapi.yaml get /redis/databases","href":"/devops/developer-api/redis/list_databases"},{"title":"Get Database","deprecated":null,"version":null,"sidebarTitle":"Get database","openapi":"/devops/developer-api/openapi.yaml get /redis/database/{id}","href":"/devops/developer-api/redis/get_database"},{"title":"Get Database Stats","deprecated":null,"version":null,"sidebarTitle":"Get database stats","openapi":"/devops/developer-api/openapi.yaml get /redis/stats/{id}","href":"/devops/developer-api/redis/get_database_stats"},{"title":"Get Database Traffic","deprecated":null,"version":null,"sidebarTitle":"Get database traffic","openapi":"/devops/developer-api/openapi.yaml get /redis/traffic/{id}","href":"/devops/developer-api/redis/get_database_traffic"},{"title":"Get Database Insights","deprecated":null,"version":null,"sidebarTitle":"Get database insights","openapi":"/devops/developer-api/openapi.yaml get /redis/insights/{id}","href":"/devops/developer-api/redis/get_database_insights"},{"title":"Create Redis Database","deprecated":null,"version":null,"sidebarTitle":"Create database global","openapi":"/devops/developer-api/openapi.yaml post /redis/database","href":"/devops/developer-api/redis/create_database_global"},{"title":"Rename Database","deprecated":null,"version":null,"sidebarTitle":"Rename database","openapi":"/devops/developer-api/openapi.yaml post /redis/rename/{id}","href":"/devops/developer-api/redis/rename_database"},{"title":"Reset Password","deprecated":null,"version":null,"sidebarTitle":"Reset password","openapi":"/devops/developer-api/openapi.yaml post /redis/reset-password/{id}","href":"/devops/developer-api/redis/reset_password"},{"title":"Enable TLS","deprecated":null,"version":null,"sidebarTitle":"Enable tls","openapi":"/devops/developer-api/openapi.yaml post /redis/enable-tls/{id}","href":"/devops/developer-api/redis/enable_tls"},{"title":"Enable Eviction","deprecated":null,"version":null,"sidebarTitle":"Enable eviction","openapi":"/devops/developer-api/openapi.yaml post /redis/enable-eviction/{id}","href":"/devops/developer-api/redis/enable_eviction"},{"title":"Disable Eviction","deprecated":null,"version":null,"sidebarTitle":"Disable eviction","openapi":"/devops/developer-api/openapi.yaml post /redis/disable-eviction/{id}","href":"/devops/developer-api/redis/disable_eviction"},{"title":"Enable Auto Upgrade","deprecated":null,"version":null,"sidebarTitle":"Enable autoscaling","openapi":"/devops/developer-api/openapi.yaml post /redis/enable-autoupgrade/{id}","href":"/devops/developer-api/redis/enable_autoscaling"},{"title":"Disable Auto Upgrade","deprecated":null,"version":null,"sidebarTitle":"Disable autoscaling","openapi":"/devops/developer-api/openapi.yaml post /redis/disable-autoupgrade/{id}","href":"/devops/developer-api/redis/disable_autoscaling"},{"title":"Change Database Plan","deprecated":null,"version":null,"sidebarTitle":"Change plan","openapi":"/devops/developer-api/openapi.yaml post /redis/{id}/change-plan","href":"/devops/developer-api/redis/change_plan"},{"title":"Update Regions","deprecated":null,"version":null,"sidebarTitle":"Update regions","openapi":"/devops/developer-api/openapi.yaml post /redis/update-regions/{id}","href":"/devops/developer-api/redis/update_regions"},{"title":"Move To Team","deprecated":null,"version":null,"sidebarTitle":"Moveto team","openapi":"/devops/developer-api/openapi.yaml post /redis/move-to-team","href":"/devops/developer-api/redis/moveto_team"},{"title":"Update Database Budget","deprecated":null,"version":null,"sidebarTitle":"Update budget","openapi":"/devops/developer-api/openapi.yaml patch /redis/update-budget/{id}","href":"/devops/developer-api/redis/update_budget"},{"title":"Delete Database","deprecated":null,"version":null,"sidebarTitle":"Delete database","openapi":"/devops/developer-api/openapi.yaml delete /redis/database/{id}","href":"/devops/developer-api/redis/delete_database"},{"group":"Backup","pages":[{"title":"List Backup","deprecated":null,"version":null,"sidebarTitle":"List backup","openapi":"/devops/developer-api/openapi.yaml get /redis/list-backup/{id}","href":"/devops/developer-api/redis/backup/list_backup"},{"title":"Get Backup Analysis","deprecated":null,"version":null,"sidebarTitle":"Get backup analysis","openapi":"/devops/developer-api/openapi.yaml get /redis/backup-analysis/{id}/{backupid}","href":"/devops/developer-api/redis/backup/get_backup_analysis"},{"title":"Analyze Backup","deprecated":null,"version":null,"sidebarTitle":"Analyze backup","openapi":"/devops/developer-api/openapi.yaml post /redis/backup-analysis/{id}/{backupid}","href":"/devops/developer-api/redis/backup/analyze_backup"},{"title":"Create Backup","deprecated":null,"version":null,"sidebarTitle":"Create backup","openapi":"/devops/developer-api/openapi.yaml post /redis/create-backup/{id}","href":"/devops/developer-api/redis/backup/create_backup"},{"title":"Restore Backup","deprecated":null,"version":null,"sidebarTitle":"Restore backup","openapi":"/devops/developer-api/openapi.yaml post /redis/restore-backup/{id}","href":"/devops/developer-api/redis/backup/restore_backup"},{"title":"Enable Daily Backup","deprecated":null,"version":null,"sidebarTitle":"Enable dailybackup","openapi":"/devops/developer-api/openapi.yaml patch /redis/enable-dailybackup/{id}","href":"/devops/developer-api/redis/backup/enable_dailybackup"},{"title":"Disable Daily Backup","deprecated":null,"version":null,"sidebarTitle":"Disable dailybackup","openapi":"/devops/developer-api/openapi.yaml patch /redis/disable-dailybackup/{id}","href":"/devops/developer-api/redis/backup/disable_dailybackup"},{"title":"Delete Backup","deprecated":null,"version":null,"sidebarTitle":"Delete backup","openapi":"/devops/developer-api/openapi.yaml delete /redis/delete-backup/{id}/{backup_id}","href":"/devops/developer-api/redis/backup/delete_backup"}]}]},{"group":"Redis for Agents","pages":[{"title":"Get Instructions","api":"GET https://upstash.com/start-redis","href":"/devops/developer-api/start-redis/instructions"},{"title":"Create a Free Database","api":"POST https://upstash.com/start-redis","href":"/devops/developer-api/start-redis/create"},{"title":"Get Metrics","api":"GET https://upstash.com/start-redis/metrics/{id}","href":"/devops/developer-api/start-redis/metrics"}]},{"group":"Vector","pages":[{"title":"List Indices","deprecated":null,"version":null,"sidebarTitle":"List indices","openapi":"/devops/developer-api/openapi.yaml get /vector/index","href":"/devops/developer-api/vector/list_indices"},{"title":"Get Index","deprecated":null,"version":null,"sidebarTitle":"Get index","openapi":"/devops/developer-api/openapi.yaml get /vector/index/{id}","href":"/devops/developer-api/vector/get_index"},{"title":"Get Index Stats","deprecated":null,"version":null,"openapi":"/devops/developer-api/openapi.yaml get /vector/index/{id}/stats","href":"/api-reference/vector/get-index-stats"},{"title":"Get Vector Stats","deprecated":null,"version":null,"openapi":"/devops/developer-api/openapi.yaml get /vector/index/stats","href":"/api-reference/vector/get-vector-stats"},{"title":"Create Index","deprecated":null,"version":null,"sidebarTitle":"Create index","openapi":"/devops/developer-api/openapi.yaml post /vector/index","href":"/devops/developer-api/vector/create_index"},{"title":"Rename Index","deprecated":null,"version":null,"sidebarTitle":"Rename index","openapi":"/devops/developer-api/openapi.yaml post /vector/index/{id}/rename","href":"/devops/developer-api/vector/rename_index"},{"title":"Reset Index Passwords","deprecated":null,"version":null,"sidebarTitle":"Reset index passwords","openapi":"/devops/developer-api/openapi.yaml post /vector/index/{id}/reset-password","href":"/devops/developer-api/vector/reset_index_passwords"},{"title":"Set Index Plan","deprecated":null,"version":null,"sidebarTitle":"Set index plan","openapi":"/devops/developer-api/openapi.yaml post /vector/index/{id}/setplan","href":"/devops/developer-api/vector/set_index_plan"},{"title":"Transfer Index","deprecated":null,"version":null,"sidebarTitle":"Transfer index","openapi":"/devops/developer-api/openapi.yaml post /vector/index/{id}/transfer","href":"/devops/developer-api/vector/transfer_index"},{"title":"Delete Index","deprecated":null,"version":null,"sidebarTitle":"Delete index","openapi":"/devops/developer-api/openapi.yaml delete /vector/index/{id}","href":"/devops/developer-api/vector/delete_index"}]},{"group":"Search","pages":[{"title":"List Search Indexes","deprecated":null,"version":null,"openapi":"/devops/developer-api/openapi.yaml get /search","href":"/api-reference/search/list-search-indexes"},{"title":"Get Search Index","deprecated":null,"version":null,"openapi":"/devops/developer-api/openapi.yaml get /search/{id}","href":"/api-reference/search/get-search-index"},{"title":"Get Search Stats","deprecated":null,"version":null,"openapi":"/devops/developer-api/openapi.yaml get /search/stats","href":"/api-reference/search/get-search-stats"},{"title":"Get Index Stats","deprecated":null,"version":null,"openapi":"/devops/developer-api/openapi.yaml get /search/{id}/stats","href":"/api-reference/search/get-index-stats"},{"title":"Create Search Index","deprecated":null,"version":null,"openapi":"/devops/developer-api/openapi.yaml post /search","href":"/api-reference/search/create-search-index"},{"title":"Reset Password","deprecated":null,"version":null,"openapi":"/devops/developer-api/openapi.yaml post /search/{id}/reset-password","href":"/api-reference/search/reset-password"},{"title":"Transfer Search Index","deprecated":null,"version":null,"openapi":"/devops/developer-api/openapi.yaml post /search/{id}/transfer","href":"/api-reference/search/transfer-search-index"},{"title":"Rename Search Index","deprecated":null,"version":null,"openapi":"/devops/developer-api/openapi.yaml post /search/{id}/rename","href":"/api-reference/search/rename-search-index"},{"title":"Delete Search Index","deprecated":null,"version":null,"openapi":"/devops/developer-api/openapi.yaml delete /search/{id}","href":"/api-reference/search/delete-search-index"}]},{"group":"QStash","pages":[{"title":"List QStash Users","deprecated":null,"version":null,"openapi":"/devops/developer-api/openapi.yaml get /qstash/users","href":"/api-reference/qstash/list-qstash-users"},{"title":"Get QStash","deprecated":null,"version":null,"openapi":"/devops/developer-api/openapi.yaml get /qstash/user/{id}","href":"/api-reference/qstash/get-qstash"},{"title":"Get QStash Stats","deprecated":null,"version":null,"openapi":"/devops/developer-api/openapi.yaml get /qstash/stats/{id}","href":"/api-reference/qstash/get-qstash-stats"},{"title":"Get QStash IPv4 Addresses","deprecated":null,"version":null,"openapi":"/devops/developer-api/openapi.yaml get /qstash/ipv4","href":"/api-reference/qstash/get-qstash-ipv4-addresses"},{"title":"Reset QStash Token","deprecated":null,"version":null,"openapi":"/devops/developer-api/openapi.yaml post /qstash/rotate-token/{id}","href":"/api-reference/qstash/reset-qstash-token"},{"title":"Set QStash Plan","deprecated":null,"version":null,"openapi":"/devops/developer-api/openapi.yaml post /qstash/set-plan/{id}","href":"/api-reference/qstash/set-qstash-plan"},{"title":"Move QStash to Team","deprecated":null,"version":null,"openapi":"/devops/developer-api/openapi.yaml post /qstash/move-to-team","href":"/api-reference/qstash/move-qstash-to-team"},{"title":"Update QStash Budget","deprecated":null,"version":null,"openapi":"/devops/developer-api/openapi.yaml patch /qstash/update-budget/{id}","href":"/api-reference/qstash/update-qstash-budget"},{"title":"Enable Production Pack","deprecated":null,"version":null,"openapi":"/devops/developer-api/openapi.yaml post /qstash/enable-prodpack/{id}","href":"/api-reference/qstash/enable-production-pack"},{"title":"Disable Production Pack","deprecated":null,"version":null,"openapi":"/devops/developer-api/openapi.yaml post /qstash/disable-prodpack/{id}","href":"/api-reference/qstash/disable-production-pack"}]},{"group":"Teams","pages":[{"title":"List Teams","deprecated":null,"version":null,"sidebarTitle":"List teams","openapi":"/devops/developer-api/openapi.yaml get /teams","href":"/devops/developer-api/teams/list_teams"},{"title":"Get Team Members","deprecated":null,"version":null,"sidebarTitle":"Get team members","openapi":"/devops/developer-api/openapi.yaml get /teams/{team_id}","href":"/devops/developer-api/teams/get_team_members"},{"title":"Create Team","deprecated":null,"version":null,"sidebarTitle":"Create team","openapi":"/devops/developer-api/openapi.yaml post /team","href":"/devops/developer-api/teams/create_team"},{"title":"Add Team Member","deprecated":null,"version":null,"sidebarTitle":"Add team member","openapi":"/devops/developer-api/openapi.yaml post /teams/member","href":"/devops/developer-api/teams/add_team_member"},{"title":"Delete Team","deprecated":null,"version":null,"sidebarTitle":"Delete team","openapi":"/devops/developer-api/openapi.yaml delete /team/{id}","href":"/devops/developer-api/teams/delete_team"},{"title":"Delete Team Member","deprecated":null,"version":null,"sidebarTitle":"Delete team member","openapi":"/devops/developer-api/openapi.yaml delete /teams/member","href":"/devops/developer-api/teams/delete_team_member"}]},{"group":"Account","pages":[{"title":"List Audit Logs","deprecated":null,"version":null,"sidebarTitle":"List audit logs","openapi":"/devops/developer-api/openapi.yaml get /auditlogs","href":"/devops/developer-api/account/list_audit_logs"}]},{"group":"DevOps","pages":[{"group":"Terraform","pages":[{"title":"Upstash Terraform Provider Overview","sidebarTitle":"Overview","href":"/devops/terraform/overview"},{"group":"Resources","pages":[{"title":"upstash_qstash_endpoint","href":"/devops/terraform/resources/upstash_qstash_endpoint"},{"title":"upstash_qstash_schedule","href":"/devops/terraform/resources/upstash_qstash_schedule"},{"title":"upstash_qstash_topic","href":"/devops/terraform/resources/upstash_qstash_topic"},{"title":"upstash_redis_database","href":"/devops/terraform/resources/upstash_redis_database"},{"title":"upstash_team","href":"/devops/terraform/resources/upstash_team"}]},{"group":"Data Sources","pages":[{"title":"upstash_qstash_endpoint_data","href":"/devops/terraform/data_sources/upstash_qstash_endpoint_data"},{"title":"upstash_qstash_schedule_data","href":"/devops/terraform/data_sources/upstash_qstash_schedule_data"},{"title":"upstash_qstash_topic_data","href":"/devops/terraform/data_sources/upstash_qstash_topic_data"},{"title":"upstash_redis_database_data","href":"/devops/terraform/data_sources/upstash_redis_database_data"},{"title":"upstash_team_data","href":"/devops/terraform/data_sources/upstash_team_data"}]}]},{"group":"Pulumi","pages":[{"title":"Upstash Pulumi Provider Overview","sidebarTitle":"Overview","href":"/devops/pulumi/overview"}]}]}]}]}]},"basePath":"","title":"Workflow Agents Getting Started - Upstash Documentation","buildId":"dpl_6cCEiK8XNNvaLBBkWzcBhdE9QfLC","deploymentId":"dpl_6cCEiK8XNNvaLBBkWzcBhdE9QfLC","dynamics":["a74be98ba7"],"chunks":["zoom-image-lightbox-B-WKhCOL.js","lightbox-handle-r17bVUz3.js"]}