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

# Vercel AI SDK

> Use NagaAI from the Vercel AI SDK through the OpenAI, OpenAI-compatible or Anthropic provider.

The AI SDK reaches NagaAI through any of its three providers. See the [AI SDK provider docs](https://ai-sdk.dev/providers/ai-sdk-providers/openai).

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

const naga = createOpenAI({
  baseURL: "https://api.naga.ac/v1",
  apiKey: process.env.NAGAAI_API_KEY,
});

// Responses API. store: false is required, see below.
const { text } = await generateText({
  model: naga("deepseek-v4.1-flash"),
  prompt: "Why do HTTP clients retry with backoff? One sentence.",
  providerOptions: { openai: { store: false } },
});
console.log(text);

// Chat Completions
const chat = await generateText({
  model: naga.chat("deepseek-v4.1-flash"),
  prompt: "Why do HTTP clients retry with backoff? One sentence.",
});
console.log(chat.text);

// Messages
const claude = createAnthropic({ baseURL: "https://api.naga.ac/v1", apiKey: process.env.NAGAAI_API_KEY });
const message = await generateText({
  model: claude("claude-sonnet-5"),
  prompt: "Why do HTTP clients retry with backoff? One sentence.",
});
console.log(message.text);
```

<Warning>
  The OpenAI provider stores responses by default and sends earlier turns as references to them. NagaAI keeps no state, so without `store: false` the second turn fails with `400`.
</Warning>

`createOpenAICompatible` from `@ai-sdk/openai-compatible` also works with `baseURL: "https://api.naga.ac/v1"`. Set `includeUsage: true` to get token usage in streams.

The Anthropic provider adds `/messages` to its base URL, so its `baseURL` ends in `/v1`.
