> 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 Integration

Learn about Vercel AI SDK and check out a sample implementation with nexos.ai.

Connect the Vercel AI SDK to nexos.ai to power your chatbots, streaming responses, and content generation with any model in your workspace. This guide walks through a sample setup in TypeScript.

## What is Vercel AI SDK?

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 of Vercel AI SDK 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 Models](https://docs.nexos.ai/gateway-api/models) You can use either `nexos_model_id`or `id` as model.

## FAQ

### Which other integrations are available in nexos.ai Gateway?

nexos.ai Gateway supports integrations with the following coding tools:

* [CrewAI](https://docs.nexos.ai/gateway-api/integrations/crewai)
* [Codex CLI](https://docs.nexos.ai/gateway-api/integrations/codex-cli)
* [OpenCode](https://docs.nexos.ai/gateway-api/integrations/opencode)
* [Claude Code](https://docs.nexos.ai/gateway-api/integrations/claude-code)
* [Claude Cowork](https://docs.nexos.ai/gateway-api/integrations/claude-cowork)
* [Bubble](https://docs.nexos.ai/gateway-api/integrations/bubble)
* [GitLab CI](https://docs.nexos.ai/gateway-api/integrations/gitlab-ci)
* [OpenAI Agents SDK](https://docs.nexos.ai/gateway-api/integrations/openai-agents-sdk)
* [Streamlit](https://docs.nexos.ai/gateway-api/integrations/streamlit)
* [ProxyAI](https://docs.nexos.ai/gateway-api/integrations/proxyai)
* [Langfuse](https://docs.nexos.ai/gateway-api/integrations/langfuse)
* [LangGraph](https://docs.nexos.ai/gateway-api/integrations/langgraph)
* [LangChain](https://docs.nexos.ai/gateway-api/integrations/langchain)
* [Roo Code](https://docs.nexos.ai/gateway-api/integrations/roo-code)
* [n8n](https://docs.nexos.ai/gateway-api/integrations/n8n)


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
