> For the complete documentation index, see [llms.txt](https://docs.nexos.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nexos.ai/gateway-api/integrations/vercel-ai-sdk.md).

# Vercel AI SDK

#### **What is Vercel AI SDK?** <a href="#what-is-vercel-ai-sdk" id="what-is-vercel-ai-sdk"></a>

The Vercel AI SDK is a powerful and flexible open-source library designed to help developers build AI-powered user interfaces quickly and efficiently within modern JavaScript/TypeScript web applications.

**Core Purpose:**

* Managing the state and user experience of AI interactions: Especially for streaming responses, which are crucial for responsive AI UIs.
* Building common AI UI patterns: Such as chatbots, text completion fields, and content generation tools.

**Sample implementation using nexos.ai**

* Setup typescript project
* Install dependencies
* Define environments\
  `NEXOS_API_KEY=``team-api-key`\
  `NEXOS_BASE_URL=https://api.nexos.ai/v1`

```
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { generateText } from 'ai';
import dotenv from 'dotenv';

dotenv.config();

let NEXOS_API_KEY = process.env.NEXOS_API_KEY
let NEXOS_BASE_URL= process.env.NEXOS_BASE_URL

if (!NEXOS_API_KEY || !NEXOS_BASE_URL) {
    throw new Error('Please set NEXOS_BASE_URL and NEXOS_API_KEY in your .env file');
}

const provider = createOpenAICompatible({
    name: 'nexos.ai',
    apiKey: NEXOS_API_KEY,
    baseURL: NEXOS_BASE_URL, // e.g. https://api.nexos.ai/v1
});

const { text } = await generateText({
    model: provider('Claude Haiku 4.5'), // or any other OpenAI-compatible model ID available to you 
    prompt: 'Write a vegetarian lasagna recipe for 4 people.',
});

console.log(text);
```

You can use any open AI compatible model. To check what models are available for you, call [Gateway API | nexos.ai documentation](https://docs.nexos.ai/gateway-api#get-v1-models) You can use either `nexos_model_id`or `id` as model.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.nexos.ai/gateway-api/integrations/vercel-ai-sdk.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
