How to Use
Before you start, ensure you’ve already obtained theAPI_KEY from the Friendli Suite > Personal Settings > API Keys.
Instantiation
Instantiate your models using a Friendli provider instance. Choose the example for your endpoint type: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 thegenerateText 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 viaproviderOptions.friendliai.regex:
OpenAI Compatibility
You can also use@ai-sdk/openai as the APIs are OpenAI-compatible.