Model-generated tool invocation
Representing assistant output that requests a function or external operation.
AI Tools · Type Alias
ToolCallPart is the AI SDK content-part shape for a model-generated tool invocation. It identifies the call, names the target tool, and stores schema-shaped arguments.
ToolCallPart models one tool invocation inside prompt content. Its discriminator identifies the part, the call ID links it to the corresponding result, the tool name identifies the requested tool, and args carries the model-generated JSON-serializable inputs.
export interface ToolCallPart {
type: 'tool-call';
toolCallId: string;
toolName: string;
args: unknown;
}| Name | Type | Description |
|---|---|---|
type | 'tool-call' | Discriminator for this content part; always the literal 'tool-call'. |
toolCallId | string | Identifier used to associate the call with its result. |
toolName | string | Name of the requested tool. |
args | unknown | JSON-serializable arguments matching the tool input schema. |
A ToolCallPart object representing a tool call content part.
const part: ToolCallPart = {
type: 'tool-call',
toolCallId: 'call_123',
toolName: 'weather',
args: { city: 'Paris' },
};
console.log(part.toolName, part.args);Creates a tool-call content part with an identifier, tool name, and JSON-compatible arguments.
Representing assistant output that requests a function or external operation.
Linking a tool response to the invocation that caused it.
Passing model-produced inputs into a tool-validation and execution pipeline.
ToolCallPart represents a tool-call content part of a prompt, usually produced by a model. It contains a 'tool-call' discriminator, a call identifier, the tool name, and the call arguments.
Follow-up: How would you associate a result with the request? Use the same toolCallId on the corresponding tool-result part.
The type field must be the literal 'tool-call'. This discriminates the object from other message-content part types.
Follow-up: Why is a literal discriminator useful? It lets TypeScript and runtime logic identify the union member reliably.
args is an unknown value representing the tool's arguments. The documentation describes it as a JSON-serializable object matching the tool's input schema.
Follow-up: How should consumers validate args? Check it against the tool's input schema before executing the operation.
ToolResultPartTextPartAssistantContentModelMessage