Quickstart
Run your first durable agent flow with Kitaru
This guide walks you through setting up a model and running your first durable flow. If you haven't installed Kitaru yet, start with Installation.
Initialize your project
kitaru initThis creates a .kitaru/ directory that marks your project root.
Set up a model
kitaru.llm() needs to know which model to call and how to authenticate. Set your provider API key and a default model:
export OPENAI_API_KEY=sk-...
export KITARU_DEFAULT_MODEL=openai/gpt-5-nanokitaru.llm() picks up both from the environment.
For production, register a model alias so you can swap models or credentials without changing code:
kitaru secrets set openai-creds --OPENAI_API_KEY=sk-...
kitaru model register fast --model openai/gpt-5-nano --secret openai-credsSee Secrets + Model Registration for the full setup.
Optional: start a local Kitaru server
Flows always run where you execute them — the server does not run your code. It stores execution metadata, secrets, model aliases, and serves the UI. If you already have a deployed server and want your executions tracked there, connect first and verify with kitaru status. If you are just trying Kitaru locally, skip this section.
Run your first flow
Create a file called agent.py:
Then run it:
What happens here:
@flowmarks the top-level execution boundary — everything inside is trackedEach
@checkpointpersists its return value automaticallykitaru.llm()picks up your API key from the environment, calls the model, and captures the prompt, response, token usage, and latency.run()starts the execution and returns aFlowHandle;.wait()blocks until completion
Why checkpoints matter
Now imagine research succeeds but draft_report fails — maybe you hit a rate limit or the model returned an error. Without Kitaru you would re-run the entire script, paying for the research call again and losing progress. With Kitaru, you replay from the failure point:
Replay creates a new execution that reuses the recorded output of research and only re-executes draft_report. The more checkpoints your flow has, the less work you repeat when something goes wrong.
This works the same whether you use kitaru.llm() or bring your own client.
That's the runtime layer running on your laptop. The same flow survives the move into production unchanged: the harness inside your checkpoints keeps owning how the agent thinks, Kitaru keeps owning the durable run, and your platform (auth, policy, UI) keeps sitting in front. When you're ready, my_agent.deploy(...) captures an immutable versioned snapshot that your platform invokes by flow name — no per-deployment tokens, no separate service per version.
Deploy to a remote stack
Everything above runs locally. To run on remote infrastructure (Kubernetes, Vertex AI, SageMaker, or AzureML), point your flow at a remote stack. When targeting a remote stack, Kitaru automatically builds a container image with your code and dependencies. You can control the base image, Python packages, system packages, and environment variables through the image parameter:
This example includes kitaru[pydantic-ai,openai] explicitly because setting base_image means you control the image contents. Kitaru can auto-add plain kitaru when it builds the requirements list for you, but it does not guess optional extras such as the PydanticAI/OpenAI adapter dependencies.
See the Containerization guide for the full set of image options, custom Dockerfiles, and how Kitaru packages your source code.
What's Next
Now that Kitaru is installed and you've run a flow, follow the next path that fits what you want to learn:
Last updated
Was this helpful?