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 API_KEY from the Friendli Suite > Personal Settings > API Keys.
Instantiation
Instantiate your models using a FriendliAI provider instance.
Choose the example for your endpoint type:
To target a specific endpoint type explicitly, pass baseURL when creating the provider with createFriendli. Accepted values include "serverless", "dedicated", or a full API URL (for example, https://api.friendli.ai/serverless/v1).
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.
Pass the regex as a string via providerOptions.friendliai.regex:
OpenAI Compatibility
You can also use @ai-sdk/openai as the APIs are OpenAI-compatible.
If you are using Dedicated Endpoints:
Further Resources
Last modified on September 23, 2026