Vercel AI SDK
Run inferences on Clarifai models using Vercel
Vercel offers a TypeScript toolkit called the AI SDK, which streamlines integration with language models in modern web applications.
The SDK supports the OpenAI Compatible Provider package that enables seamless interaction with any OpenAI-compatible API — including Clarifai’s OpenAI-compatible endpoint.
Prerequisites
Install Package
Vercel offers a Clarifai provider, which is available through the @ai-sdk/openai-compatible module and is compatible with the OpenAI API. You can install it using:
- pnpm
- npm
- yarn
pnpm add @ai-sdk/openai-compatible
npm install @ai-sdk/openai-compatible
yarn add @ai-sdk/openai-compatible
Get a PAT Key
You need a PAT (Personal Access Token) key to authenticate your connection to the Clarifai platform. You can get one by navigating to Settings in the collapsible left sidebar, selecting Secrets, and creating or copying an existing token from there.
You can then set the PAT as an environment variable using CLARIFAI_PAT:
- Unix-Like Systems
- Windows
export CLARIFAI_PAT=YOUR_PERSONAL_ACCESS_TOKEN_HERE
set CLARIFAI_PAT=YOUR_PERSONAL_ACCESS_TOKEN_HERE
Get a Clarifai Model
Go to the Clarifai Community platform and select the model you want to use for making predictions.
Some Clarifai models that support Vercel AI SDK, and their capabilities
| Model | Image Input | Tool Usage | Tool Streaming |
|---|---|---|---|
| gpt-oss-120b | ✅ | ✅ | ✅ |
| DeepSeek R1 0528 Qwen3 8B | ✅ | ✅ | ✅ |
| Llama 3.2 3B Instruct | ✅ | ✅ | ✅ |
| claude Sonnet 4 | ✅ | ✅ | ✅ |
| Qwen3 14B | ✅ | ✅ | ✅ |
| Devstral Small 2505.gguf 4bit | ✅ | ✅ | ✅ |
| grok 3 | ❌ | ✅ | ✅ |
| gpt 4o | ✅ | ✅ | ✅ |
| gpt 4.1 | ✅ | ✅ | ✅ |
| gemini 2.5 Flash | ✅ | ✅ | ✅ |
| claude 3.5 Haiku | ✅ | ✅ | ✅ |
| Qwen3 30B A3B GGUF | ✅ | ✅ | ✅ |
| gemini 2.0 Flash | ✅ | ✅ | ✅ |
| gemma 3 12b It | ✅ | ✅ | ✅ |
| Phi 4 Reasoning Plus | ✅ | ✅ | ✅ |
| phi 4 Mini Instruct | ✅ | ✅ | ✅ |
| Qwen2.5 VL 7B Instruct | ✅ | ❌ | ❌ |
| phi 4 | ✅ | ✅ | ✅ |
| grok 2 Vision 1212 | ✅ | ✅ | ✅ |
| grok 2 1212 | ❌ | ✅ | ✅ |
| QwQ 32B AWQ | ✅ | ✅ | ✅ |
| gemini 2.0 Flash Lite | ✅ | ✅ | ✅ |
| claude Opus 4 | ✅ | ✅ | ✅ |
| o4 Mini | ✅ | ✅ | ✅ |
| o3 | ✅ | ✅ | ✅ |
| MiniCPM-o 2.6 Language | ✅ | ❌ | ❌ |
| DeepSeek R1 Distill Qwen 7B | ✅ | ❌ | ❌ |
| Qwen2.5 Coder 7B Instruct | ✅ |