Introduction
The Vercel AI SDK provides a shared interface for building AI-powered JavaScript and TypeScript applications. For AI SDK 7, use the published SaladCloud provider to connect to Salad AI Gateway. For self-hosted OpenAI-compatible servers, use@ai-sdk/openai-compatible instead.
This is a direct connection to SaladCloud using the AI SDK library, not a connection through the hosted Vercel AI
Gateway. You do not need a Vercel account or Vercel API key.
- Salad AI Gateway - no infrastructure to deploy or manage. Available in beta with pay-per-token billing. Connect to the shared endpoint using your organization-specific AI Gateway API key.
- Self-hosted model - deploy your own SaladCloud container group for full control over the model, hardware, and configuration. Still very easy to set up and use.
Prerequisites
Before getting started, make sure you have:- A SaladCloud account
- Node.js 22 or newer installed
Step-by-Step Setup
Step 1: Choose Your Backend
- Salad AI Gateway
- Self-Hosted on SaladCloud
Salad AI Gateway is the fastest way to get started - no container groups to deploy, no cold starts to wait for.
- Sign in to the SaladCloud portal.
- Follow Pay-Per-Token Onboarding to add credits and create your organization’s AI Gateway API key.
qwen3.6-35b-a3b.Step 2: Install the Dependencies
In a new project directory, initialize an ES module project. If you already have a project, keep its existing configuration and adapt the examples to its module system.- Salad AI Gateway
- Self-Hosted on SaladCloud
0.2.0 of the SaladCloud provider implements the AI SDK 7 provider interface. Do not use it with
ai@6 or older.Step 3: Configure the SaladCloud Provider
- Salad AI Gateway
- Self-Hosted on SaladCloud
Create a Create The provider reads
.env file with your organization’s AI Gateway API key:provider.js:provider.js
SALAD_CLOUD_API_KEY and defaults to https://ai.salad.cloud/v1. You do not need to supply a
base URL or custom headers. A regular SaladCloud API key is not a substitute for an AI Gateway key..env and .env.local to your project’s .gitignore. Keep the key on the server: do not expose it in browser code
or a NEXT_PUBLIC_ environment variable. In Next.js, run the provider inside a server-side route or action and store
SALAD_CLOUD_API_KEY in .env.local or your hosting platform’s secret settings.
Step 4: Generate Text and Test the Connection
Createtest.js. This example works with either provider.js above:
test.js
Streaming Chat Responses
Createstream.js to display text as it is generated:
stream.js
Troubleshooting
- Unsupported model version: check
npm ls ai @saladtechnologies-oss/ai-sdk-provider. Useai@7with SaladCloud provider0.2.0. - Missing API key or HTTP 401: load
.envwith--env-fileand use an organization-specific AI Gateway key inSALAD_CLOUD_API_KEY. For self-hosted deployments, check the separateSalad-Api-Keyheader configuration. - Unexpected endpoint: remove an old
SALAD_CLOUD_BASE_URLoverride if you intend to use the shared AI Gateway.