Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.salad.com/llms.txt

Use this file to discover all available pages before exploring further.

Last Updated: May 18, 2026

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. The Vercel AI SDK works with SaladCloud in two ways:
  • Salad AI Gateway - no infrastructure to deploy or manage. Sign up for access, point your app at a single shared endpoint, and use your Salad API key directly. Currently in closed beta with monthly flat-rate access.
  • 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:

Step-by-Step Setup

Step 1: Choose Your Backend

Salad AI Gateway is the fastest way to get started - no container groups to deploy, no cold starts to wait for.
  1. Sign up for early access at salad.com/ai-gateway.
  2. Once approved, find your Salad API key in the portal.
Available models:
ModelDescription
qwen3.6-35b-a3bQwen 3.6 35B-A3B - best for agentic tasks, coding, and complex reasoning
qwen3.6-27bQwen 3.6 27B - strong balance of capability and speed
qwen3.5-9bQwen 3.5 9B - fastest response times, suited for lighter tasks

Step 2: Install the Dependencies

In your project directory, install the Vercel AI SDK and the OpenAI-compatible provider:
npm install ai @ai-sdk/openai-compatible
The Vercel AI SDK uses ES modules. Make sure your package.json has "type": "module" set:
npm pkg set type=module
To use environment variables for your API key and endpoint, also install dotenv:
npm install dotenv

Step 3: Configure the SaladCloud Provider

Store your credentials in a .env file:
SALAD_API_KEY=your-salad-api-key
Create a provider instance pointing to the AI Gateway endpoint:
import { createOpenAICompatible } from '@ai-sdk/openai-compatible'
import dotenv from 'dotenv'
dotenv.config()

const saladcloud = createOpenAICompatible({
  name: 'saladcloud',
  baseURL: 'https://ai.salad.cloud/v1',
  apiKey: process.env.SALAD_API_KEY,
})
No custom headers are needed - your Salad API key in apiKey is all that’s required.

Step 4: Generate Text and Test the Connection

Use generateText to test that your setup works:
import { createOpenAICompatible } from '@ai-sdk/openai-compatible'
import { generateText } from 'ai'
import dotenv from 'dotenv'
dotenv.config()

const saladcloud = createOpenAICompatible({
  name: 'saladcloud',
  baseURL: process.env.SALAD_BASE_URL,
  headers: {
    'Salad-Api-Key': process.env.SALAD_API_KEY,
  },
})

const { text } = await generateText({
  model: saladcloud('qwen3.6-35b-a3b'),
  prompt: 'Explain distributed GPU computing in one paragraph.',
})

console.log(text)
Run it with:
node test.js
If you see a response, your setup is complete.

Streaming Chat Responses

Use streamText for chat interfaces that display responses as they are generated:
import { createOpenAICompatible } from '@ai-sdk/openai-compatible'
import { streamText } from 'ai'
import dotenv from 'dotenv'
dotenv.config()
const saladcloud = createOpenAICompatible({
  name: 'saladcloud',
  baseURL: process.env.SALAD_BASE_URL,
  headers: {
    'Salad-Api-Key': process.env.SALAD_API_KEY,
  },
})

const result = streamText({
  model: saladcloud('qwen3.6-35b-a3b'),
  messages: [
    { role: 'system', content: 'You are a helpful coding assistant.' },
    { role: 'user', content: 'How do I read a file in Python?' },
  ],
})

for await (const chunk of result.textStream) {
  process.stdout.write(chunk)
}