Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

AI Tools · Type Alias

ToolCallPart

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.

How it works

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.

Syntax

export interface ToolCallPart {
  type: 'tool-call';
  toolCallId: string;
  toolName: string;
  args: unknown;
}

Parameters

NameTypeDescription
type'tool-call'Discriminator for this content part; always the literal 'tool-call'.
toolCallIdstringIdentifier used to associate the call with its result.
toolNamestringName of the requested tool.
argsunknownJSON-serializable arguments matching the tool input schema.

Returns

A ToolCallPart object representing a tool call content part.

Key points

  • A ToolCallPart is one tool-invocation segment within prompt content.
  • toolCallId identifies this particular invocation.
  • toolName states which tool the model requested.
  • args carries the inputs supplied for the invocation.
  • Arguments should be JSON-compatible and conform to the selected tool's schema.

Common mistakes

  • Keep toolCallId stable so the invocation can be correlated with its result.

Example: Construct a tool-call 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.

When to use it

Model-generated tool invocation

Representing assistant output that requests a function or external operation.

Call-result correlation

Linking a tool response to the invocation that caused it.

Schema-driven argument handling

Passing model-produced inputs into a tool-validation and execution pipeline.

Interview questions

QWhat is ToolCallPart used for?

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.

QWhat does the type field signify?

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.

QWhat does args contain?

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.

  • ToolResultPart
  • TextPart
  • AssistantContent
  • ModelMessage

Source: AI SDK Core: ModelMessage. Checked 2026-10-15.