Overview
core-ai uses a comprehensive type system to ensure type safety across all operations. This page documents the essential types for working with messages, models, configurations, and results.Message types
Message
Union type representing all message types in a conversation.SystemMessage
ModelCapabilities.messages.systemPlacement below and
System message placement.
UserMessage
TextPart
ImagePart
FilePart
AudioPart
AssistantMessage
AssistantTextPart
ReasoningPart
metadata field is application-owned and provider adapters ignore it. The providerMetadata field is provider-namespaced. The top-level key is the provider identifier (for example 'anthropic', 'google', 'openai', or 'azure-openai'). Adapters treat other providers’ keys as foreign and downgrade those reasoning blocks to plain text instead of forwarding opaque metadata. Use getProviderMetadata() for typed access.
ToolCallPart
providerMetadata follows the same provider-namespaced convention as ReasoningPart. Keep it on the part when you replay history: Gemini 3 rejects a request when a function call from the current turn comes back without its thought signature.
ToolCall
ToolDiscoveryCallPart
GenerateOptions.toolDiscovery). Answer it with one ToolDiscoveryResultMessage before the next request. The part wraps the call as ToolCallPart wraps a ToolCall. Discovery calls appear in GenerateResult.discoveryCalls, never in toolCalls. providerMetadata follows the same ownership rules as on ToolCallPart. See Tool Discovery.
ToolResultMessage
ToolDiscoveryResultMessage
ToolDiscoveryCallPart. Place it with the step’s tool results: after the assistant message, in any order relative to ToolResultMessages. tools may be empty when nothing matched; note can then tell the model why. The tools it lists stay declared on later generate() and stream() requests while the message is in the history, unless tools declares the same name.
metadata on message parts, tool calls, tool results, and discovery results is for your application and middleware. It stays in conversation history and generated results, but core-ai does not send it to provider APIs.
Schema types
SchemaInput
The schema type for tool parameters and structured outputs.StandardSchemaWithJsonis a Standard Schema that can also produce JSON Schema, such as a Zod 4.2+ schema. core-ai converts it to the JSON Schema of its input type and validates structured output with it.validateToolCall()validates tool calls with it.JsonSchemais a plain JSON Schema object. core-ai sends it as is and never validates against it. Any other object type is accepted as plain JSON Schema too, including interfaces such asJSONSchema7from@types/json-schema, unless it is a Standard Schema without JSON Schema support.
@core-ai/core-ai also exports the Standard Schema type namespaces StandardSchemaV1, StandardJSONSchemaV1, and StandardTypedV1.
InferSchemaOutput
unknown for plain JSON Schema.
Tool types
ToolDefinition
parameters is a Standard Schema with JSON Schema support, such as a Zod 4.2+ schema, or plain JSON Schema. Validate calls to tools with Standard Schema parameters with validateToolCall(), which returns a ToolCallValidation.
strict: true opts the tool into provider-enforced adherence to its parameter
schema; the schema must fit the strict-capable contract described in the
tool-calling guide. Omitted or
false keeps the tool non-strict on every provider.
ToolCallValidation
validateToolCall(): the schema’s result, { value } or { issues }, for Standard Schema parameters, and undefined for plain JSON Schema, which core-ai never validates.
ToolSet
ToolSnapshot
ToolDiscoveryResultMessage. Its parameters are plain JSON Schema, so messages stay plain data and render byte for byte on every request. Produce them from a Standard Schema with toJsonSchema(). core-ai does not validate calls to discovered tools.
ToolDiscoveryOptions
description is appended to the discovery tool’s default description, which only explains how discovery works. Use it, for example, to list the discoverable tool names.
ToolChoice
{ type: 'tool', toolName } may only name a tool in tools. 'none' also keeps the model from discovering tools, and a discovery call satisfies 'required'.
Model types
ChatModel
capabilities describes how a specific model accepts unified generation
options. It is different from the provider-level feature lists in the provider
guides: those show which APIs a provider exposes, while ModelCapabilities
describes request constraints for one model ID.
ModelCapabilities
mode: 'unsupported' means the provider does not map the unified reasoning
option. The model may still return reasoning output. optional means callers
can enable reasoning, while always-on means the model reasons without an
option and cannot disable it.
An empty supportedEfforts list means the model does not accept effort
control. It does not necessarily mean the model cannot produce reasoning
output. When restrictsSamplingParams is true, consult the provider guide for
the exact accepted values.
modalities.input / modalities.output describe chat I/O modalities. Check
them with .includes(...), or with the exported helpers
supportsInputModality and supportsOutputModality. Core also exports the
common presets TEXT_ONLY_MODALITIES (text in / text out) and
MULTIMODAL_INPUT_MODALITIES (text + image + file in / text out).
Providers that support AudioPart add 'audio' to their input array. 'video'
is reserved until a dedicated user content part exists.
output is present only when the provider has a verified output ceiling for
the model id. It is the limit an omitted maxTokens resolves to. A missing
output means the ceiling is unknown.
Sending image, file, or audio parts when those modalities are not in
modalities.input throws an UnsupportedInputModalityError before the
provider call. Unrecognized model IDs are treated as multimodal capable on
purpose for image and file input (fail-open), so self-hosted endpoints and
newly released models are not blocked locally for those parts. Audio remains
opt-in. Typos and custom deployment names that do not match a registry key
therefore include 'image' and 'file' in modalities.input and still rely
on the provider to reject unsupported requests. For Azure and other wrappers,
pass a known registry model ID when you need accurate capability data.
modalities.output currently always includes 'text'. Dedicated image
generation uses ImageModel / generateImage, not chat output.
Check model.capabilities.tools.strictSchemas before setting strict: true.
Setting it on a model that reports { supported: false } throws
ToolSchemaStrictnessError before the provider request. Unknown and future
model IDs resolve optimistically to { supported: true }, so explicit strict
tools are forwarded and the provider rejects them if the model genuinely lacks
support. Strict tool schemas only govern tool arguments. They are separate
from the response formats used by generateObject() and streamObject().
tools.toolDiscovery is 'native' when the model delivers discovered tools
through the provider’s deferred tool loading, which keeps the prompt cache when
the model discovers tools. 'emulated' declares discovered tools as ordinary
tools, so each discovery changes the tool declarations. Your application code is
the same for both. See
Native and emulated discovery.
messages.systemPlacement describes where a model accepts a system message
that comes after the first non-system message. 'leading' accepts none,
'before-reply' accepts one directly after a user, tool, or tool discovery
result message when it is last or followed by an assistant message, and
'anywhere' accepts any position. A system message that breaks the rule throws
UnsupportedSystemMessagePlacementError before the provider request. Call
getSystemMessagePlacementIssues(messages, placement) to check a conversation
without sending it. Unknown Claude model IDs resolve to 'before-reply'.
Provider packages also export get*ModelCapabilities(modelId) helpers for
registry data without constructing a ChatModel. A model factory can apply
API- or endpoint-specific gates afterward; for example, OpenAI Responses has
narrower legacy-model support than Chat Completions. Kimi and xAI expose this
data through ChatModel.capabilities only.
EmbeddingModel
ImageModel
Configuration types
ReasoningConfig
Provider options types
Provider-specific options are namespaced by provider name and validated by each provider adapter.model.provider, so each model
reads only its own entry and ignores the rest:
Generation options
BaseGenerateOptions
Shared options for all generation functions.GenerateOptions
ExtendsBaseGenerateOptions with tool support.
toolDiscovery enables tool discovery: core-ai declares its discovery tool, and the model’s calls to it arrive as ToolDiscoveryCallParts. Keep it set consistently within a conversation; switching it costs a prompt cache rewrite. See Tool Discovery.
GenerateObjectOptions
schema is a Standard Schema with JSON Schema support, whose validated output becomes object, or plain JSON Schema, whose parsed JSON is returned without validation.
StreamObjectOptions
Result types
GenerateResult
toolCalls holds the calls to your tools and to discovered tools; discoveryCalls holds the discovery calls. Both list the calls of parts in order. finishReason is 'tool-calls' when either has pending calls: answer both before the next request.
GenerateObjectResult
object is the schema’s validated output for a Standard Schema and the parsed JSON, typed unknown, for plain JSON Schema.
FinishReason
Streaming types
ChatStream
Replayable handle for a chat streaming operation. Iterating after events have arrived replays the buffered history.StreamEvent
tool-discovery-call event, a complete ToolDiscoveryCallPart, when the model finishes it. It has no start or delta events.
ObjectStream
Replayable handle for a structured object streaming operation.ObjectStreamEvent
Usage types
ChatUsage
inputTokens is the total including cached reads and cache writes. outputTokens is the total including visible text and reasoning.