> ## Documentation Index
> Fetch the complete documentation index at: https://docs.supa.works/llms.txt
> Use this file to discover all available pages before exploring further.

# Vercel AI SDK

> Use the Vercel AI SDK with SUPA's OpenAI-compatible API.

Use the [Vercel AI SDK](https://sdk.vercel.ai/docs) (`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`).

<Note>
  SUPA exposes an OpenAI-compatible HTTP API. Configure the provider with the same host and `/v1` prefix as in the [Quickstart](/quickstart) cURL example: `https://api.supa.works/openai/v1`.
</Note>

## Prerequisites

* A SUPA API key from your [profile page](https://app.supa.works/user)
* Node.js 18+

## Install

```bash theme={null}
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.

```typescript theme={null}
import { createOpenAI } from '@ai-sdk/openai';

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

## Generate text

```typescript theme={null}
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

```typescript theme={null}
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

* See [Tool calls](/examples/tool-calls) for function calling with the AI SDK.
* See [Image attachments](/examples/image-attachments) for vision-style prompts.
* TanStack alternative: [TanStack AI (OpenAI adapter)](/guides/tanstack-ai).
