Quickstart from scratch

Minimal steps to get started with Resonate.
1. Install Resonate
Install the Resonate Server + CLI on your local machine.
Install with Homebrew
Shellbrew install resonatehq/tap/resonate
Run the Resonate Server
Start Resonate Server
Shellresonate dev
2. Install the SDK
Add the Resonate SDK to your project as a dependency.
- Python
- TypeScript
- uv
- pip
- poetry
Install with uv
Shelluv add resonate-sdk
Install with pip
Shellpip install resonate-sdk
Install with poetry
Shellpoetry add resonate-sdk
- Bun
- npm
- Yarn
Install with bun
Shellbun add @resonatehq/sdk
Install with npm
Shellnpm install @resonatehq/sdk
Install with yarn
Shellyarn add @resonatehq/sdk
3. Register a function
Register a flow function with Resonate and start a Worker process to execute it.
- Python
- TypeScript
main.py
Pythonfrom resonate import Resonate, Context
from typing import Generator, Any
resonate = Resonate.remote()
def step_1(_: Context, greetee: str) -> str:
print("running step 1")
return f"Hello {greetee} from step 1!"
def step_2(_: Context, greetee: str) -> str:
print("running step 2")
return f"Hello {greetee} from step 2!"
@resonate.register
def flow(ctx: Context, greetee: str) -> Generator[str, Any, Any]:
print("running flow")
flow_greeting = f"Hello {greetee} from the main flow!"
step_1_greeting = yield ctx.run(step_1, greetee=greetee)
step_2_greeting = yield ctx.run(step_2, greetee=greetee)
greeting = f"{flow_greeting} {step_1_greeting} {step_2_greeting}"
return greeting
resonate.start()
Run your Worker
- uv
- pip
- poetry
Run with uv
Shelluv run main.py
Run with python
Shellpython main.py
Run with poetry
Shellpoetry run python main.py
index.ts
TypeScriptimport { Resonate } from "@resonatehq/sdk";
import type { Context } from "@resonatehq/sdk";
const resonate = new Resonate({
url: "http://localhost:8001",
group: "worker",
});
async function step1(_: Context, greetee: string): Promise<string> {
console.log("running step 1");
return `Hello ${greetee} from step 1!`;
}
async function step2(_: Context, greetee: string): Promise<string> {
console.log("running step 2");
return `Hello ${greetee} from step 2!`;
}
function* flow(ctx: Context, greetee: string): Generator<any, string, any> {
console.log("running flow");
const flowGreeting = `Hello ${greetee} from flow!`;
const step1Greeting = yield* ctx.run(step1, greetee);
const step2Greeting = yield* ctx.run(step2, greetee);
const greeting = `${flowGreeting} ${step1Greeting} ${step2Greeting}`;
return greeting;
}
resonate.register("flow", flow);
4. Invoke a function
Invoke the flow function defined above.
Invoke flow
Shellresonate invoke hello-world-greeting-flow --func flow --arg World --target poll://any@worker
5. Get the result
Get the result of the invoked flow function using the promise ID.
Get the result of flow
Shellresonate promises get hello-world-greeting-flow
You should see the following output:
resonate promises get output
ShellId: hello-world-greeting-flow
State: RESOLVED
Timeout: 1764970170102
Idempotency Key (create):
Idempotency Key (complete): hello-world-greeting-flow
Param:
Headers:
Data:
{"func":"flow","args":["World"],"version":1}
Value:
Headers:
Data:
"Hello World from flow! Hello World from step 1! Hello World from step 2!"
Tags:
resonate:invoke: poll://any@workers
The Data field under Value contains the final greeting returned by the flow function.