@friendliai/ai-provider
A provider to use FriendliAI models with the Vercel AI SDK and OpenAI-compatible APIs.
Requires AI SDK 7 (ai >= 7) and Node.js 22+. Models implement Language Model specification V4 (specificationVersion: 'v4').
Installation
npm i @friendliai/ai-provider
Example
import { friendli } from '@friendliai/ai-provider';
import { generateText } from 'ai';
const { text } = await generateText({
model: friendli('zai-org/GLM-5.3'),
prompt: 'What is the meaning of life?',
maxOutputTokens: 20,
topK: 10,
providerOptions: {
friendliai: {
minP: 0.2,
},
},
});
console.log(text);
Provider Options
You can pass Friendli-specific parameters using providerOptions.friendliai. For backward compatibility, the friendli key is also supported.
Supported options (camelCase):
minPrepetitionPenaltyxtcThresholdxtcProbabilityparallelToolCallsregex(BETA: Force output to satisfy a regular expression)chat_template_kwargs
For more details, see the official documentation.