Run class
A run representing the execution of an assistant on a thread.
Runs process the messages in a thread and may invoke tools.
Example
final run = await client.threads.runs.create(
threadId: thread.id,
assistantId: assistant.id,
);
// Poll until complete
while (run.status != RunStatus.completed) {
await Future.delayed(Duration(seconds: 1));
run = await client.threads.runs.retrieve(thread.id, run.id);
}
- Annotations
-
- @immutable
Constructors
-
Run({required String id, required String object, required int createdAt, required String threadId, required String assistantId, required RunStatus status, RequiredAction? requiredAction, RunError? lastError, int? expiresAt, int? startedAt, int? cancelledAt, int? failedAt, int? completedAt, RunIncompleteDetails? incompleteDetails, required String model, String? instructions, required List<
AssistantTool> tools, required Map<String, String> metadata, Usage? usage, double? temperature, double? topP, int? maxPromptTokens, int? maxCompletionTokens, TruncationStrategy? truncationStrategy, ToolChoice? toolChoice, bool? parallelToolCalls, ResponseFormat? responseFormat}) -
Creates a Run.
const
-
Run.fromJson(Map<
String, dynamic> json) -
Creates a Run from JSON.
factory
Properties
- assistantId → String
-
The assistant ID for this run.
final
- cancelledAt → int?
-
The Unix timestamp when the run was cancelled.
final
- completedAt → int?
-
The Unix timestamp when the run completed.
final
- createdAt → int
-
The Unix timestamp when the run was created.
final
- expiresAt → int?
-
The Unix timestamp when the run will expire.
final
- failedAt → int?
-
The Unix timestamp when the run failed.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- id → String
-
The run identifier.
final
- incompleteDetails → RunIncompleteDetails?
-
Details about why the run is incomplete.
final
- instructions → String?
-
The instructions for the assistant.
final
- isComplete → bool
-
Whether the run is complete.
no setter
- isFailed → bool
-
Whether the run failed.
no setter
- isProcessing → bool
-
Whether the run is still processing.
no setter
- lastError → RunError?
-
The last error if the run failed.
final
- maxCompletionTokens → int?
-
Maximum completion tokens.
final
- maxPromptTokens → int?
-
Maximum prompt tokens.
final
-
metadata
→ Map<
String, String> -
Custom metadata.
final
- model → String
-
The model used for this run.
final
- object → String
-
The object type (always "thread.run").
final
- parallelToolCalls → bool?
-
Whether parallel tool calls are enabled.
final
- requiredAction → RequiredAction?
-
Required action if the run is waiting for tool outputs.
final
- requiresAction → bool
-
Whether the run requires action.
no setter
- responseFormat → ResponseFormat?
-
The response format.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- startedAt → int?
-
The Unix timestamp when the run started.
final
- status → RunStatus
-
The status of the run.
final
- temperature → double?
-
The sampling temperature.
final
- threadId → String
-
The thread ID this run belongs to.
final
- toolChoice → ToolChoice?
-
The tool choice setting.
final
-
tools
→ List<
AssistantTool> -
The tools available for this run.
final
- topP → double?
-
The nucleus sampling parameter.
final
- truncationStrategy → TruncationStrategy?
-
The truncation strategy.
final
- usage → Usage?
-
Token usage statistics.
final
Methods
-
copyWith(
{String? id, String? object, int? createdAt, String? threadId, String? assistantId, RunStatus? status, Object? requiredAction = unsetCopyWithValue, Object? lastError = unsetCopyWithValue, Object? expiresAt = unsetCopyWithValue, Object? startedAt = unsetCopyWithValue, Object? cancelledAt = unsetCopyWithValue, Object? failedAt = unsetCopyWithValue, Object? completedAt = unsetCopyWithValue, Object? incompleteDetails = unsetCopyWithValue, String? model, Object? instructions = unsetCopyWithValue, List< AssistantTool> ? tools, Map<String, String> ? metadata, Object? usage = unsetCopyWithValue, Object? temperature = unsetCopyWithValue, Object? topP = unsetCopyWithValue, Object? maxPromptTokens = unsetCopyWithValue, Object? maxCompletionTokens = unsetCopyWithValue, Object? truncationStrategy = unsetCopyWithValue, Object? toolChoice = unsetCopyWithValue, Object? parallelToolCalls = unsetCopyWithValue, Object? responseFormat = unsetCopyWithValue}) → Run - Creates a copy with the given fields replaced.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> - Converts to JSON.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override