Overview
Theupdate() 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
The ID of the inference result to update.
Output Fields
The generated output or response from the AI model.
The input text or prompt for the inference result.
The context retrieved by a RAG system, if applicable.
Performance Fields
The time in milliseconds from request to response.
Usage Fields
Number of input tokens sent to the model.
Number of output tokens generated by the model.
Number of input tokens read from the cache.
Total tokens used in the model call.
Cost Fields
The total cost associated with the model call.
Cost per input token sent to the model.
Cost per output token generated by the model.
Cost per input token read from the cache.
Returns
Returns the updatedInferenceResult 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
- Pass
Noneexplicitly to clear a field’s value - The
creditsUsedfield cannot be modified through this method
Related Methods
- Create Inference Result - Create a new inference result
- Generate Inference Result - Create with automatic trace collection
- Get Inference Result - Retrieve an inference result