Constructor for the VercelProvider.
The Vercel AI model to use.
The Vercel AI model parameters.
Optional logger: LDLoggerThe logger to use for the Vercel AI provider.
Optional Private _modelPrivate _parametersProtected Optional Readonly loggerStatic createStatic factory method to create a Vercel AIProvider from an AI configuration. This method auto-detects the provider and creates the model. Note: Messages from the AI config are not included in the provider - messages should be passed at invocation time via invokeModel().
The LaunchDarkly AI configuration
Optional logger: LDLoggerOptional logger
Optional A Promise that resolves to a configured VercelProvider
Static createAIMetricsCreate AI metrics information from a Vercel AI response. This method extracts token usage information and success status from Vercel AI responses and returns a LaunchDarkly AIMetrics object. Supports both v4 and v5 field names for backward compatibility.
The response from generateText() or similar non-streaming operations
LDAIMetrics with success status and token usage
Use getAIMetricsFromResponse() instead.
Static createCreate a Vercel AI model from an AI configuration. This method auto-detects the provider and creates the model instance.
The LaunchDarkly AI configuration
A Promise that resolves to a configured Vercel AI model
Static getAIMetricsGet AI metrics from a Vercel AI SDK text response This method extracts token usage information and success status from Vercel AI responses and returns a LaunchDarkly AIMetrics object. Supports both v4 and v5 field names for backward compatibility.
The response from generateText() or similar non-streaming operations
LDAIMetrics with success status and token usage
const response = await aiConfig.tracker.trackMetricsOf(
VercelProvider.getAIMetricsFromResponse,
() => generateText(vercelConfig)
);
Static getAIMetricsGet AI metrics from a Vercel AI SDK streaming result.
This method waits for the stream to complete, then extracts metrics using totalUsage (preferred for cumulative usage across all steps) or usage if totalUsage is unavailable.
The stream result from streamText()
A Promise that resolves to LDAIMetrics
const stream = aiConfig.tracker.trackStreamMetricsOf(
() => streamText(vercelConfig),
VercelProvider.getAIMetricsFromStream
);
Static mapMap LaunchDarkly model parameters to Vercel AI SDK parameters.
Parameter mappings:
Optional parameters: { The LaunchDarkly model parameters to map
Optional
An object containing mapped Vercel AI SDK parameters
Static mapStatic mapStatic toConvert an AI configuration to Vercel AI SDK parameters. This static method allows converting an LDAIConfig to VercelAISDKConfig without requiring an instance of VercelProvider.
The LaunchDarkly AI configuration
A Vercel AI SDK Provider or a map of provider names to Vercel AI SDK Providers
Optional options: VercelAISDKMapOptionsOptional mapping options
Optional A configuration directly usable in Vercel AI SDK generateText() and streamText()
if a Vercel AI SDK model cannot be determined from the given provider parameter
Generated using TypeDoc
Vercel AI implementation of AIProvider. This provider integrates Vercel AI SDK with LaunchDarkly's tracking capabilities.