Clarifai provides an OpenAI-compatible API endpoint, which allows you to leverage your existing OpenAI API code and workflows to make inferences with Clarifai models, including those that integrate or wrap OpenAI models.
The built-in compatibility layer converts your OpenAI calls directly into Clarifai API requests, letting you harness Clarifai's diverse models as custom tools in your OpenAI projects.
This simplifies the integration process, as you don't need to rewrite your code specifically for Clarifai's native API structure if you're already familiar with OpenAI's.
The Vercel AI SDK provides a convenient way to interact with Clarifai's OpenAI-compatible API. You can leverage the OpenAI provider to interact with Clarifai models.
- A Clarifai account with API access
- A Clarifai Personal Access Token (PAT)
Clone this directory to your local machine using degit
degit clarifai/examples/nodejs/vercel-ai-sdkInstall the required packages:
npm installAdd your Clarifai PAT to the environment variable CLARIFAI_PAT
export CLARIFAI_PAT=your_pat_hereor use a .env file to setup your environment variables.
- The example uses Clarifai's GPT-4o model by default, but you can easily switch to other models
- Make sure your Clarifai PAT has the necessary permissions