Skip to main content
Create a minimal agent on the in-process runtime and run a single prompt. No Temporal or Restate server required. Requirements: Go 1.26+ and an API key for at least one LLM provider. Verify your Go version with go version.

Step 1 — Create a Go module

Step 2 — Set your API key

For Anthropic or Gemini, see LLM Providers.

Step 3 — Write the agent

Create main.go:

Step 4 — Run

Expected output includes the agent name, model, and assistant reply in result.Content.

What happened

defer a.Close() is not optional when using a durable runtime — it shuts down the embedded Temporal worker or Restate SDK endpoint. On the in-process runtime it is a no-op but still good practice.Durability note: Close does not terminate in-flight Temporal workflows or Restate invocations. Runs continue on the server and resume when a worker or endpoint is available again — this is the core durability guarantee.

Switch to Temporal (optional)

Import pkg/agent/runtime/temporal and add temporal.WithTemporalConfig to run the same agent durably. A running Temporal cluster is required — see Temporal runtime.
No other code changes. The agent loop now runs as a durable Temporal workflow. See Temporal runtime for connection options including Temporal Cloud.

Switch to Restate (optional)

Import pkg/agent/runtime/restate and add restate.WithRestateConfig to run the same agent durably. A running Restate server is required — see Restate runtime and restate-setup.md.
No other code changes. The agent loop now runs as a durable Restate invocation with an embedded SDK endpoint. See Restate runtime for ingress, deployment URL, and Cloud options.
Use either Temporal or Restate — not both on the same agent.

Try the repository example

The same pattern is in the Simple Agent example. From the repository root:
See Running Examples for environment variable details.

What’s next

LLM Providers

Configure OpenAI, Anthropic, Gemini, or a custom client

Run

AgentRun — Get, Done, Status, Cancel, non-blocking

Streaming

Stream partial tokens and lifecycle events