Skip to main content
Define a tool, create an agent, and run it with a gateway client. The model calls your tool, the SDK runs it and sends the result back, and the run returns when the model answers without calling a tool, pauses for a person, or meets a stop condition. If the run reaches its step limit first, the SDK throws an error; only Rust returns the run with status stopped. Phaseo doesn’t host the agent or store its runs; your application does.

Build a first agent

The tool’s ID is the function name the model sees, and its parameters are the JSON Schema the model fills in. The arguments reach your code in each language’s native shape: If the agent, the run, and the client set no model or preset, the gateway client sends phaseo/free. Rust’s create_gateway_agent_client takes the model as an argument.

How a run works

Each step is checkpointed in the returned run result. To resume across requests or restarts, save that result in your own store and pass it to the continue method, or give the agent a state accessor; see State and approval. The step limit and what happens when it runs out differ by language:
Each run() or continueRun() call takes up to 12 steps unless you set maxSteps; past that it throws Max steps exceeded. Use stop conditions to end a run cleanly.

Read the run result

Every run returns the same parts. Field names follow each language’s casing (output, Output, output()): Rust’s usage.cost comes only from a numeric meta.cost or cost on the response; it doesn’t map cost_nanos or cost_cents. Use the Gateway response or generation record for Rust spend reporting.

Find the right feature

Every export is listed in the API reference, and complete agents are in Examples.
Last modified on November 5, 2026