Clarifai
Use Clarifai OpenAI compatible API with the AI SDK.
Clarifai is a platform for building, deploying, and scaling AI-powered applications. It provides a suite of tools and APIs for computer vision, natural language processing, and generative AI. Clarifai offers an OpenAI-compatible API through its full-stack AI development platform, making it easy to integrate powerful AI capabilities using the AI SDK.
Setup
The Clarifai provider is available via the @ai-sdk/openai-compatible module as it is compatible with the OpenAI API. You can install it with:
$ pnpm add @ai-sdk/openai-compatible
$ npm install @ai-sdk/openai-compatible
$ yarn add @ai-sdk/openai-compatible
$ bun add @ai-sdk/openai-compatible
Provider Instance
To use Clarifai, you can create a custom provider instance with the createOpenAICompatible function from @ai-sdk/openai-compatible:
You can obtain an API key by creating a Personal Access Token (PAT) in your Clarifai account settings. Make sure to set the CLARIFAI_PAT environment variable with your PAT.
New users can sign up for a free account on Clarifai to get started.
Language Models
You can interact with various large language models (LLMs) available on Clarifai using the provider instance. For example, to use DeepSeek-R1, a powerful open-source language model:
Example - Generate Text
You can use Clarifai language models to generate text with the generateText function:
Example - Streaming Text
You can also stream text responses from Clarifai models using the streamText function:
For full list of available models, you can refer to the Clarifai Model Gallery.