An invocation is a request to execute a handler. The Python SDK client lets you invoke Restate handlers from anywhere in your application. Use it in applications that do not have access to a Restate Context.
Each invocation has its own unique ID and lifecycle. See managing invocations to learn how to manage the lifecycle of an invocation.
Always invoke handlers via the context when you have access to it. Restate then links the invocation to its parent invocation.

Prerequisites

Install the Python SDK, which includes the client:
Then register the service you want to invoke. The client uses the handler definitions from your service to serialize requests and responses. The examples below assume that you import restate, timedelta from datetime, and your handler definitions into the application that creates the client.

Request response invocations

To invoke a handler and wait for its response:
Use restate.create_client as an async context manager so the underlying HTTP client closes after use.

One way invocations

To send a message without waiting for a response:
Each send returns a handle containing the invocation ID.

Delayed invocations

To schedule an invocation for a later point in time:

Invoke a handler idempotently

Add an idempotency key to prevent retries of the same request from executing the handler more than once:
After the invocation completes, Restate retains its response for the configured idempotency retention period. If you invoke the same handler with the same idempotency key during that period, Restate returns the stored response without executing the handler again. You can also pass custom request headers with the headers argument.
See service configuration to configure the idempotency retention period.

Flow control: scope and limit key

Scope and limit key are a preview feature and require Restate Server 1.7 with flow control enabled.
Flow control limits how many invocations run concurrently within a scope, with optional hierarchical limit keys. Create a scoped client with client.scope(...), then pass a limit_key for a more specific concurrency limit within that scope:
See Flow control for details about scopes, limit keys, and concurrency rules.