Skip to content

Vercel.AI

API reference

Client, text generation, streaming, tools, and agents.

Type Summary
AbortPart The call was aborted. It is the last part of the stream.
Agent An agent that calls tools until StopWhen matches. Maps to Agent.
AgentOptions Agent settings.
Ai Static entry points. String model ids use the AI Gateway and AIGATEWAYAPIKEY.
AiClient Default IAiClient. String model ids are resolved by the AI Gateway.
AiSdkOptions Options for AiSdkOptions%7d).
AiSdkServiceCollectionExtensions Dependency injection for IAiClient.
ApiOrProvider<TApi, TProvider> An API or a provider that exposes one. Maps to the upstream Api | ProviderV4 unions.
CustomProvider A provider backed by caller-supplied models. Maps to customProvider. A model id that is not registered goes to FallbackProvider, or throws NoSuchModelError when there is none.
DefaultInstructionsMiddleware Prepends system instructions when the prompt has none. Maps to defaultInstructionsMiddleware.
DefaultSettingsMiddleware Fills sampling settings when the caller left them unset. Maps to defaultSettingsMiddleware.
EmbedEventValue<TOne, TMany> A single item for embed or a list for embedMany, as carried by embed events.
EmbedOptions Embedding options.
ErrorPart The stream failed.
EvaluateOptions Evaluation options.
ExecutedTool The result of executing a tool.
ExtractJsonMiddleware Strips markdown JSON fences. Maps to extractJsonMiddleware.
ExtractReasoningMiddleware Splits delimited reasoning, such as …, out of text. Maps to extractReasoningMiddleware.
FinishPart The full stream finished.
GenerateImageOptions Image generation options.
GenerateSpeechOptions Speech options.
GenerateTextOptions Options for CancellationToken). Property names follow generateText.
GenerateTextResult Result of generateText.
GenerateVideoOptions Video options.
LanguageModelCallEndEvent Passed to OnLanguageModelCallEnd after a provider model call returns.
LanguageModelMiddleware Passes both operations through.
LanguageModelMiddlewareExtensions Wraps a language model with middleware. Maps to wrapLanguageModel.
LanguageModelRequestMetadata Metadata for a language model request. Maps to LanguageModelRequestMetadata.
LanguageModelResponseMetadata Metadata for a language model response, as the finish-step part carries it. Maps to Omit<LanguageModelResponseMetadata, ‘messages’ | ‘body’>.
OutputChunkTimingStats Timing statistics for the gaps between generated output chunks, in milliseconds.
OutputSpec Structured output selector. Maps to Output.
PrepareStepContext Context passed to prepareStep.
PrepareStepUpdate Optional changes applied before a step.
ProviderRegistry Looks up provider models by provider:model ids. Maps to createProviderRegistry. Everything after the first separator is the model id, so model ids may contain the separator.
RawPart A raw chunk of the provider stream. It appears only when RawChunks is set.
ReasoningDeltaPart Reasoning delta.
RerankOptions Rerank options.
SimulateStreamingMiddleware Turns a non-streaming model into text deltas. Maps to simulateStreamingMiddleware.
SourcePart A cited source.
StartPart The full stream started. It is the first part of the stream.
StartStepPart A step started. It comes before the parts of that step.
StepFinishPart A step finished.
StepPerformance Performance metrics for one step. Maps to StepResultPerformance.
StepResponse Response information of one step. Maps to LanguageModelResponseMetadata & { messages, body? } on StepResult.response.
StepResult One language-model step, including any tool results from that step.
StopCondition Stops the tool loop. The default for generateText is IsStepCount(int) of 1.
StopWhen Stop-condition factories. Maps to isStepCount, hasToolCall, and isLoopFinished.
StreamAbortContext Passed to OnAbort.
StreamTextInclude What streamText keeps of the request and the provider stream. Maps to StreamTextInclude.
StreamTextOptions Options for CancellationToken).
StreamTextResult Result of streamText. Enumerating Stream(CancellationToken) or awaiting Text consumes the same buffered events.
TextDeltaPart Text delta.
TextStreamPart A part of the streamText full stream.
Tool A tool the model can call. Maps to tool().
ToolApprovalRequest A tool call the caller may approve before it runs.
ToolApprovalRequestPart A provider-executed tool call needs approval before the provider runs it.
ToolCallPart A tool call.
ToolErrorPart A tool call failed or was denied. A successful call is a ToolResultPart.
ToolExecutionEndEvent Passed to OnToolExecutionEnd after a tool ran.
ToolExecutionOptions The options a tool receives when it runs. Maps to the second argument of execute.
ToolExecutionStartEvent Passed to OnToolExecutionStart before a tool runs.
ToolInputDeltaPart A streamed tool-input fragment.
ToolInputEndPart The model finished streaming tool input.
ToolInputStartPart The model started streaming tool input.
ToolResultPart A tool result.
TranscribeOptions Transcription options.
TranslateOptions Speech translation options.
Type Summary
IAiClient Core AI SDK client. Maps to the ai package functions.
IAiTelemetry Telemetry hook invoked around generate and stream calls.
ILanguageModelMiddleware Wraps doGenerate and doStream. Maps to language-model middleware.

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product