Vercel AI SDK
Using Datawizz with Vercel AI SDK
The Vercel AI SDK is a powerful framework for creating AI-powered applications, making it easy to build AI features with streaming, function-calling and other capabilities built in. You can easily integrate Datawizz with the Vercel AI SDK to create powerful AI applications.
The integration with Datawizz will use the AI SDK’s OpenAI provider and Datawizz’s OpenAI-compatible API, so for the most part, this will look a lot like using OpenAI with the Vercel AI SDK. You can see the reference for the OpenAI provider for additional information.
Connecting to Datawizz
Assuming you already have the rest of the SDK installed, you’ll need to install the OpenAI provider for the Vercel AI SDK. You can do this by running the following command:
Once you have the SDK installed, you can connect to Datawizz by creating a new OpenAI client with your Datawizz API key and base URL. Here’s an example of how you might do this:
Finally, you can instanciate a model using the openai client and the Datawizz endpoint ID you wish to connect to:
Using Datawizz with the Vercel AI SDK
You can now use the model to generate text, stream outputs and perform any other action supported by the Vercel AI SDK. Here’s an example of how you might generate text using the model:
Adding Metadata
Metadata is crucial for tracking the performance of your models and organizing your logs better - Datawizz creates tags from your metadata, and allows you to route requests and train models based on these tags. You can add metadata to your requests using the experimental_providerMetadata
option in the Vercel AI SDK. Here’s an example of how you might add metadata to your request: