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

# Vercel AI SDK

> Use the Vercel AI SDK with Concentrate Responses or OpenAI-compatible Chat.

The Vercel AI SDK is a JavaScript and TypeScript library. Configure either the OpenAI provider for the [Responses API](/docs/api-reference/endpoint/create-response) or the OpenAI-compatible provider for [Chat Completions](/docs/api-reference/endpoint/chat-completions). Both use `https://api.concentrate.ai/v1`.

## Install

```bash theme={null}
npm install ai @ai-sdk/openai @ai-sdk/openai-compatible zod
```

Set `CONCENTRATE_API_KEY` in your server environment. Do not expose it in browser code.

## Use Responses

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

const concentrate = createOpenAI({
  baseURL: "https://api.concentrate.ai/v1",
  apiKey: process.env.CONCENTRATE_API_KEY,
});

const result = await generateText({
  model: concentrate.responses("claude-sonnet-4-6"),
  prompt: "Say hello in one sentence.",
});
console.log(result.text);
```

## Use compatible Chat

```typescript theme={null}
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { generateText } from "ai";

const concentrateChat = createOpenAICompatible({
  name: "concentrate",
  baseURL: "https://api.concentrate.ai/v1",
  apiKey: process.env.CONCENTRATE_API_KEY,
  includeUsage: true,
  supportsStructuredOutputs: true,
});

const result = await generateText({
  model: concentrateChat.chatModel("claude-sonnet-4-6"),
  prompt: "Say hello in one sentence.",
});
console.log(result.text);
```

The examples below use the `concentrate` Responses provider from **Use Responses**.

## Stream text

```typescript theme={null}
import { streamText } from "ai";

const result = streamText({
  model: concentrate.responses("claude-sonnet-4-6"),
  prompt: "Tell me a short story.",
});
for await (const text of result.textStream) {
  process.stdout.write(text);
}
```

## Call a function

```typescript theme={null}
import { generateText, tool } from "ai";
import { z } from "zod";

const result = await generateText({
  model: concentrate.responses("claude-sonnet-4-6"),
  prompt: "Use get_weather for Paris.",
  tools: {
    get_weather: tool({
      description: "Get weather for a city",
      inputSchema: z.object({ city: z.string() }),
    }),
  },
  toolChoice: { type: "tool", toolName: "get_weather" },
});
const call = result.toolCalls.find((item) => item.toolName === "get_weather");
console.log(call?.input.city);
```

To have the SDK run the function, add an `execute` handler to the tool. See [Vercel's tool calling guide](https://ai-sdk.dev/docs/ai-sdk-core/tools-and-tool-calling).

## Get structured JSON

```typescript theme={null}
import { generateText, Output } from "ai";
import { z } from "zod";

const result = await generateText({
  model: concentrate.responses("claude-sonnet-4-6"),
  prompt: "Return JSON with status set to ready.",
  output: Output.object({
    schema: z.object({ status: z.string() }),
  }),
});
console.log(result.output.status);
```

## Explore more

* Send images with [multimodal input](/docs/api-reference/endpoint/multi-modal).
* Find a model in the [model catalog](/docs/api-reference/endpoint/supported-models).
