Vercel AI SDK
Easily integrate FriendliAI models with the Vercel AI SDK, supporting serverless, dedicated, and fine-tuned endpoints.
You can use Vercel AI SDK to interact with FriendliAI. This makes migration of existing applications already using Vercel AI SDK particularly easy.
How to use
Before you start, ensure you’ve already obtained the FRIENDLI_TOKEN
from the Friendli Suite.
Instantiation
Instantiate your models using a Friendli provider instance. We provide usage examples for each type of endpoint. Choose the one that best suits your needs:
Example: Generating text
Generate a response with the generateText
function:
Example: Using Enforcing Patterns (Regex)
Specify a specific pattern (e.g., CSV), character sets, or specific language characters (e.g., Korean Hangul characters) for your LLM’s output.
Example: Using built-in tools
This feature is in Beta and available only on the Serverless Endpoints.
Using tool assisted chat completion API, models can utilize built-in tools prepared for tool calls, enhancing its capability to provide more comprehensive and actionable responses.
Available tools are listed here.
OpenAI Compatibility
You can also use @ai-sdk/openai
as the APIs are OpenAI-compatible.
If you are using dedicated endpoints
Further resources
Was this page helpful?