Skip to main content
Use the Vercel AI SDK (ai and @ai-sdk/openai) with SUPA by pointing the OpenAI provider at SUPA’s base URL and using your SUPA model id (for example google/gemma-3-27b-it).
SUPA exposes an OpenAI-compatible HTTP API. Configure the provider with the same host and /v1 prefix as in the Quickstart cURL example: https://api.supa.works/openai/v1.

Prerequisites

Install

npm install ai @ai-sdk/openai zod
zod is used for tool schemas in the examples below.

Configure the provider

Create an OpenAI provider instance with your SUPA API key and base URL, then pass a SUPA model name to each call.
import { createOpenAI } from '@ai-sdk/openai';

const supa = createOpenAI({
  apiKey: process.env.SUPA_API_KEY,
  baseURL: 'https://api.supa.works/openai/v1',
});

Generate text

import { generateText } from 'ai';

const { text } = await generateText({
  model: supa('google/gemma-3-27b-it'),
  prompt: 'What is a banana?',
});

console.log(text);

Stream text

import { streamText } from 'ai';

const result = streamText({
  model: supa('google/gemma-3-27b-it'),
  prompt: 'Write one paragraph about bananas.',
});

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

Next steps