NVIDIA NIM
Use NVIDIA NIM OpenAI compatible API with the AI SDK.
NVIDIA NIM provides optimized inference microservices for deploying foundation models. It offers an OpenAI-compatible API that you can use with the AI SDK.
Setup
The NVIDIA NIM provider is available via the @ai-sdk/openai-compatible module as it is compatible with the OpenAI API.
You can install it with:
$ pnpm add @ai-sdk/openai-compatible
$ npm install @ai-sdk/openai-compatible
$ yarn add @ai-sdk/openai-compatible
$ bun add @ai-sdk/openai-compatible
Provider Instance
To use NVIDIA NIM, you can create a custom provider instance with the createOpenAICompatible function from @ai-sdk/openai-compatible:
You can obtain an API key and free credits by registering at NVIDIA Build. New users receive 1,000 inference credits to get started.
Language Models
You can interact with NIM models using a provider instance. For example, to use DeepSeek-R1, a powerful open-source language model:
Example - Generate Text
You can use NIM language models to generate text with the generateText function:
Example - Stream Text
NIM language models can also generate text in a streaming fashion with the streamText function:
NIM language models also support structured data generation with Output.
Model support for tool calls and structured output varies. For example, the
meta/llama-3.3-70b-instruct
model supports structured output capabilities. Check each model's
documentation on NVIDIA Build for specific supported features.