ApiHookContext class
Context for API call hooks (HookType.preApiCall, HookType.postApiCall).
- Inheritance
-
- Object
- HookContext
- ApiHookContext
Constructors
-
ApiHookContext({required HookType hookType, required DateTime timestamp, String? sessionId, Map<
String, dynamic> metadata = const {}, List<HookResult> previousResults = const [], int? turnIndex, required String model, required List<Map< messages, String? systemPrompt, double? temperature, int? maxTokens, List<String, dynamic> >String> ? stopSequences, ApiTokenUsage? tokenUsage, Duration? latency, int? statusCode}) -
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hookType → HookType
-
The type of hook being executed.
finalinherited
- latency → Duration?
-
Response latency (only set in post-API hooks).
final
- maxTokens → int?
-
Maximum tokens to generate.
final
-
messages
→ List<
Map< String, dynamic> > -
Messages being sent to the API.
final
-
metadata
→ Map<
String, dynamic> -
Arbitrary metadata that hooks can read and contribute to.
finalinherited
- model → String
-
Model identifier (e.g., "claude-sonnet-4-20250514").
final
-
previousResults
→ List<
HookResult> -
Results from previously executed hooks in the same chain.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sessionId → String?
-
The active session ID, if any.
finalinherited
- statusCode → int?
-
HTTP status code (only set in post-API hooks).
final
-
stopSequences
→ List<
String> ? -
Stop sequences, if any.
final
- systemPrompt → String?
-
System prompt, if any.
final
- temperature → double?
-
Sampling temperature.
final
- timestamp → DateTime
-
When this hook execution was initiated.
finalinherited
- tokenUsage → ApiTokenUsage?
-
Token usage from the response (only set in post-API hooks).
final
- turnIndex → int?
-
The current conversation turn index, if applicable.
finalinherited
Methods
-
copyWith(
{HookType? hookType, DateTime? timestamp, String? sessionId, Map< String, dynamic> ? metadata, List<HookResult> ? previousResults, int? turnIndex}) → HookContext -
Create a copy with updated fields.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
withResponse(
{ApiTokenUsage? tokenUsage, Duration? latency, int? statusCode}) → ApiHookContext - Create a post-API context with response information.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited