Skip to content

Vercel.AI.ProviderUtils

API reference

Public types in the Vercel.AI.ProviderUtils namespace.

Type Summary
AbortErrors Recognizes abort and timeout failures that must not be retried.
ApiKeys Resolves an API key from an explicit value or an environment variable.
BatchResultDownloads Settings for downloading JSON Lines batch results.
BatchResultsApiBase Batch API that downloads results. Start, status, cancel, and list throw unless a provider overrides them.
ByteEncoding Base64 conversions for inline file bytes.
Delay Waits for a duration, or completes immediately when the duration is null. Negative durations wait zero.
DelayAbortedException Raised when Delay is cancelled. Name is AbortError.
DelayedPromise<T> A task that is completed from outside. Maps to DelayedPromise.
EventSourceMessage One Server-Sent Event. Field names are compared without case folding.
EventSourceParser Incremental Server-Sent Events parser. A UTF-8 BOM is ignored at the start of the stream. A trailing carriage return is held until the next chunk so it can form a \r\n line ending. [DONE] is ordinary data.
ExponentialBackoff Retries a failed operation with exponential backoff. Abort errors are rethrown. The first non-retryable error is rethrown without wrapping.
FetchErrors Turns transport failures into retryable ApiCallErrors. Maps to handleFetchError.
FileDataConversions Converts file payloads to the forms providers send.
HostnameParts Checks a value before it is concatenated into a generated host.
IdGenerator Random id generator. The id is not cryptographically secure. A prefix is joined with separator. The separator must not appear in the alphabet.
JsonInstructions Appends a JSON schema instruction to a prompt or to the first system message.
JsonParseException JSON text could not be parsed.
JsonParseResult Success or failure of a JSON parse, including the raw value when parsing succeeded.
JsonParsing Parses JSON text, optionally checking it against a JSON Schema document.
JsonResponseTools Helpers for providers that cannot combine tools with native structured output. They add an internal function tool whose arguments are the structured output, then turn that tool call back into text.
JsonSchemas Builds JSON Schema documents from explicit shapes. This is not a Zod converter.
JsonSchemaValidator Applies a JSON Schema document. Unknown object properties are dropped.
JsonStreams Reads JSON and Server-Sent Event bodies, including response headers.
JsonStreams.JsonBody A parsed JSON body and the headers that came with it.
JsonValues Small JSON helpers shared by providers.
MappedTool A tool passed to a language model when building a name map.
MediaTypes Detects IANA media types from file signatures. Maps to detectMediaType.
ModelOptionsSerialization Serializes model options for a workflow boundary. Maps to serializeModelOptions.
NamedException An exception identified by a name such as AbortError or ResponseAborted.
NoSuchProviderReferenceError A provider reference has no entry for the requested provider. Maps to NoSuchProviderReferenceError.
PathSegments Encodes provider-returned identifiers for URL paths.
ProviderHttp Sends JSON and SSE requests with the SDK retry policy.
ProviderReferences Helpers for provider references: maps from provider name to a provider-specific id.
ProviderTextResponse A successful JSON response body and its headers.
ProviderValues Small collection, header, text, and media helpers shared by providers.
ProviderValues.BatchRequestCounts Complete batch request counts.
ProviderValues.RuntimeProbe Inputs for GetRuntimeEnvironmentUserAgent(RuntimeProbe).
ReasoningMap Maps reasoning levels onto provider effort and token budgets.
ResponseBodies Reads and releases HTTP response bodies.
ResponseHandlerResult<T> A handled response value with the response headers.
ResponseHandlers Response handlers for binary, event stream, and error responses. Maps to createBinaryResponseHandler, createBinaryStreamResponseHandler, createEventSourceResponseHandler, createJsonErrorResponseHandler, and createStatusCodeErrorResponseHandler.
RetryException Failure of ExponentialBackoff after at least one retry.
RetryOptions Options for ExponentialBackoff.
RetryPolicy Retry policy aligned with the AI SDK defaults: 2 retries, 500–5000ms backoff, 25% jitter. Retryable statuses are 408, 429, and 500–599. Retry-After is honored up to 60 seconds.
SecureJson Parses JSON and rejects proto and constructor.prototype payload keys.
SerializationError A value could not be serialized. Maps to SerializationError.
SerializedModelOptions A serialized model id and config. Maps to the result of serializeModelOptions.
SseParser Reads Server-Sent Events data: lines.
ToolExecution Runs a tool delegate and reports preliminary and final outputs.
ToolExecution.ToolStep<T> One tool output.
ToolNameMapping Maps client tool names to provider tool names. Maps to ToolNameMapping.
ToolNames Builds tool name maps. Maps to createToolNameMapping.
TypeValidationException A value did not match a JSON Schema.
UrlSupport Checks whether a model can read a URL natively. Maps to isUrlSupported.
Type Summary
ProviderValues.OptionalHeader Header values that may be omitted.
Type Summary
RetryErrorReason Why RetryException was thrown.

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