qstashClient
: QStash client used by the serve method
workflowRunId
: Current workflow run ID
url
: Publically accessible workflow endpoint URL
failureUrl
: URL for workflow failure notifications.
requestPayload
: Incoming request payload
rawInitialPayload
: String version of the initial payload
headers
: Request headers
env
: Environment variables
await
a sleep
action to properly pause execution.sleepUntil
action to properly pause execution.context.api.openai.call
.
context.call
will still be treated as successful, and the workflow will continue executing.failureFunction
or failureUrl
will not be invoked.To handle non-success cases, you can check the status
field in the response and implement custom logic as needed.url
: The URL to send the HTTP request to.method
: The HTTP method to use for the request (e.g., GET, POST, PUT, etc.). Defaults to GET.body
: Body to use in the requestheaders
: An object representing the HTTP headers to include in the request.retries
: The number of retry attempts to make if the request fails. Retries use exponential backoff. Defaults to 0 (no retries).retryDelay
: Delay between retries (in milliseconds). By default, uses exponential backoff. You can use mathematical expressions and the special variable retried
(current retry attempt count starting from 0). Examples: 1000
, pow(2, retried)
, max(10, pow(2, retried))
.flowControl
: To limit the number of calls made to your endpoint. See Flow Control for more details. The default is no limit.
key
: The key to use for flow control.rate
: The maximum number of calls per second.parallelism
: The maximum number of calls that can be active at the same time.period
: Time window over which the rate limit is enforced.timeout
: The maximum duration to wait for a response from the endpoint, in seconds. If retries are enabled, this timeout applies individually to each retry attempt.workflow
: If you are using serveMany
, you can call another workflow defined under the same serveMany
method by passing it to the workflow
parameter of context.call
.context.notify
: Notify step explained belowclient.notify
: Notify method of the Workflow Client.notifyResponse
is a list of NotifyResponse
objects:
Waiter
object:
body
is the data returned by the invoked workflow, if any is returned.
context.cancel
is different.
context.cancel
allows you to cancel the current workflow:
context.run
automatically retries on failures. Default is 3 retries with exponential backoff.context.call
doesn’t retry by default. If you wish to add retry, you can use retries
option.context.call
and context.invoke
support the retryDelay
parameter to customize the delay between retry attempts. You can use mathematical expressions with functions like pow
, sqrt
, min
, max
, etc., and the variable retried
(current retry attempt count).WorkflowNonRetryableError
allows you to fail workflow on will
without going into retry cycle. The run will be labeled as failed,
triggering the failure function and creating a dlq entry: