Skip to main content
The AI SDK’s OpenAI provider calls NagaAI on the Responses API, and its Anthropic provider calls Messages. The AI SDK provider docs describe the options.

Before you start

You need a NagaAI API key exported as NAGA_API_KEY, and the SDK packages:

Connect the AI SDK

1

Run a request in each format

Each call prints one sentence. The Anthropic provider adds /messages to its base URL, so its baseURL ends in /v1.
2

Check the requests

Both requests appear in Logs in your dashboard.
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.

Use Chat Completions

Use Chat Completions only for code that needs it, such as a tool built on that format. naga.chat("anthropic/claude-haiku-5.5") sends the same request to /v1/chat/completions. createOpenAICompatible from @ai-sdk/openai-compatible also works with baseURL: "https://api.naga.ac/v1". Set includeUsage: true there to get token usage in streams.

Troubleshooting

400 on the second turn

The OpenAI provider sent a reference to a stored response, and NagaAI keeps none. Set providerOptions: { openai: { store: false } } on the call.

401 invalid_api_key

NAGA_API_KEY is missing or wrong in the environment that runs your code. Use an API key rather than a provisioning key.