Skip to main content

Overview

The update() method allows you to modify an existing inference result after it has been created. This is useful when you need to add or update output, latency, token usage, or cost information.

Parameters

string
required
The ID of the inference result to update.

Output Fields

string
The generated output or response from the AI model.
string
The input text or prompt for the inference result.
string
The context retrieved by a RAG system, if applicable.
When you set retrieval_context, Galtea also records it as a RETRIEVER trace on this inference result. Sending null (or an empty string) clears the value and removes that trace.

Performance Fields

float
The time in milliseconds from request to response.

Usage Fields

int
Number of input tokens sent to the model.
int
Number of output tokens generated by the model.
int
Number of input tokens read from the cache.
int
Total tokens used in the model call.

Cost Fields

float
The total cost associated with the model call.
float
Cost per input token sent to the model.
float
Cost per output token generated by the model.
float
Cost per input token read from the cache.

Returns

Returns the updated InferenceResult object.

Example

Use Cases

Deferred Output Update

Create an inference result first, then update it after processing completes:

Adding Cost Information

Update an inference result with cost data after receiving billing info:

Notes

All fields except inference_result_id default to PydanticUndefined (from pydantic_core). Omit a field (or pass PydanticUndefined) to leave it unchanged. Pass None to explicitly clear an optional field. Pass a value to update it.
  • The creditsUsed field cannot be modified through this method