Function: createTurn()
@providerprotocol/ai / @providerprotocol/ai / createTurn
Function: createTurn()
Section titled “Function: createTurn()”createTurn<
TData>(messages,toolExecutions,usage,cycles,data?):Turn<TData>
Defined in: src/types/turn.ts:152
Creates a Turn from accumulated inference data.
Type Parameters
Section titled “Type Parameters”TData = unknown
Type of the structured output data
Parameters
Section titled “Parameters”messages
Section titled “messages”Message[]
All messages produced during the inference
toolExecutions
Section titled “toolExecutions”Record of all tool executions
Aggregate token usage
cycles
Section titled “cycles”number
Number of inference cycles
TData
Optional structured output data
Returns
Section titled “Returns”Turn<TData>
A complete Turn object
Throws
Section titled “Throws”Error if no assistant message is found in the messages
Example
Section titled “Example”const turn = createTurn( [userMsg, assistantMsg], [], { inputTokens: 100, outputTokens: 50, totalTokens: 150 }, 1);