.end().
All setter methods return self, so you can chain calls:
Required
Create step
There are two ways to create a step:| Parameter | Required | Description |
|---|---|---|
step_id | No | Custom step ID. If not provided, a UUID is automatically generated. |
Set prompt
The prompt is required before calling.end().
| Parameter | Required | Description |
|---|---|---|
text | Yes | The prompt sent to the LLM |
Set response
The response is required before calling.end().
| Parameter | Required | Description |
|---|---|---|
text | Yes | The response returned by the LLM |
End step
End the step and export it. A step must have both a prompt and a response set before calling.end(). The step cannot be modified after calling .end().
Optional step data
Tracking costs
Costs are calculated automatically based on the model and token usage you provide, or you can set the cost directly with your own value.Set model
Track which model was requested and which was actually used.| Parameter | Required | Description |
|---|---|---|
requested | No | The model that was requested |
used | No | The model that was actually used |
Set token usage
Track token counts for the step.| Parameter | Required | Description |
|---|---|---|
prompt_uncached | No | Number of uncached prompt tokens |
prompt_cached | No | Number of cached prompt tokens |
completion | No | Number of completion tokens |
Set cost
Alternatively, set the cost directly.| Parameter | Required | Description |
|---|---|---|
real_total | Yes | The total cost of the step |
Set finish reason
Set the finish reason returned by the LLM.| Parameter | Required | Description |
|---|---|---|
reason | Yes | The finish reason returned by the LLM (e.g. "stop", "tool_call") |
Set tool definitions
Set the tool definitions available to the LLM for this step.| Parameter | Required | Description |
|---|---|---|
definitions | Yes | The tool definitions available to the LLM for this step |
Mark step as failed
Sets the status code to error and exports the payload. The step cannot be modified after calling.error(). Unlike .end(), calling .error() does not require a prompt or response to be set.
| Parameter | Required | Description |
|---|---|---|
status_message | No | A description of the error |
