Skip to content
providerkit
GitHub

Turn

Defined in: core/src/turn.ts:28

One drained turn: the message a loop appends, whose toolCalls are the calls it runs, and what the turn cost.

finishReason:
| FinishReason
| null;

Defined in: core/src/turn.ts:35

As the provider stated it, and null when it stated none.


message: object;

Defined in: core/src/turn.ts:31

Ready to append to history as it is. toolCalls holds the calls to run, in the order the provider indexed them, and is absent when there are none.

optional citations?: Citation[];

The sources the answer cites, with spans into content.

content: string;
optional hostedCalls?: HostedCall[];

What the vendor’s own tools did in this turn (a search, a fetch, a code run), in the order they ran. Never function calls: nothing here is run by the loop or answered with a tool message. Display data, with the sensitivity of content.

optional hostedItems?: HostedItems;

The vendor’s own record of its hosted tools, replayed only to the provider that made it. Provider-owned like reasoningItems: never echo it to a browser. See HostedItems.

optional reasoning?: string;

The model’s chain-of-thought. Thinking-mode providers require it replayed on a turn that made a tool call (DeepSeek 400s without it). OpenAI-shape serializes it as reasoning_content; Anthropic-shape drops it, since its thinking blocks carry signatures we never capture.

A turn that disables thinking must not carry it. Mixing the two is unsupported. stripReasoning below is that rule, once.

optional reasoningDetails?: unknown[];

OpenRouter’s normalized reasoning payload, arriving on the stream and riding back UNMODIFIED on the next turn’s assistant message.

Opaque on purpose, with the same contract as Gemini’s thoughtSignature, and for the same reason: it is the provider’s own record of how it got here, and reading, reshaping or dropping it costs the model its continuity across a tool round. Absent on every other dialect.

optional reasoningItems?: ReasoningItems;

The ChatGPT backend’s own reasoning items, encrypted, riding back UNMODIFIED on the next turn so the model keeps its chain of thought. Tagged with the provider that made them: only that provider replays them, because another vendor (after a fallback) would reject them. Opaque, like reasoningDetails.

role: "assistant";
optional toolCalls?: ToolCall[];

optional source?: object;

Defined in: core/src/turn.ts:37

The endpoint and model that answered, when a fallback provider says.

model: string;
provider: string;

usage: TokenUsage;

Defined in: core/src/turn.ts:33

The last usage the stream reported, or zeros when it reported none.