Introduction
The Vercel AI SDK is a popular framework for building AI-powered applications in JavaScript and TypeScript. It provides a unified interface for text generation, streaming, structured output, and tool calling - and includes an@ai-sdk/openai-compatible package for connecting to any OpenAI-compatible endpoint, including SaladCloud.
Using the Vercel AI SDK with SaladCloud lets you:
- Build production apps powered by self-hosted models at SaladCloud’s per-hour pricing
- Stream responses to chat interfaces with built-in streaming support
- Use any framework - Next.js, Express, Hono, plain Node.js, or any other JavaScript runtime
Prerequisites
Before getting started, make sure you have:- A SaladCloud account with an active LLM deployment
- Node.js 18+ installed
Step-by-Step Setup
Step 1: Deploy an LLM Recipe on SaladCloud
First, deploy an OpenAI-compatible LLM server on SaladCloud.- Go to the SaladCloud portal and create an account if you do not already have one.
- Create an organization or choose an existing one, then click “Deploy a container group”.
- Select an LLM recipe. The Qwen3.5-35B-A3B (llama.cpp) recipe is a strong choice for general-purpose app development. On the recipe page, provide a name and deploy - the rest is preconfigured with recommended settings.
- Once deployed, your endpoint will be live and serving an OpenAI-compatible API.
- qwen3.5-35B-A3B - A powerful Mixture of Experts model optimized for instruction-following tasks.
- llama.cpp - Supports GGUF models
- sglang - High-performance inference
- vllm - Popular LLM serving framework
- ollama - Simple model management
- tgi - Hugging Face Text Generation Inference server
https://your-endpoint.salad.cloud).
Step 2: Install the Dependencies
In your project directory, install the Vercel AI SDK and the OpenAI-compatible provider:package.json has "type": "module" set:
dotenv:
Step 3: Configure the SaladCloud Provider
Create a provider instance pointing to your SaladCloud endpoint. If you set SaladCloud to authenticate, you need to do that via theSalad-Api-Key request header - pass it through the headers option rather than apiKey:
.env file (never hardcode secrets):
Step 4: Generate Text and Test the Connection
UsegenerateText to test that your setup works:
Streaming Chat Responses
UsestreamText for chat interfaces that display responses as they are generated: