SambaNova
Learn how to use the SambaNova provider for the AI SDK.
sambanova-ai-provider contains language model support for the SambaNova API.
API keys can be obtained from the SambaNova Cloud Platform.
Setup
The SambaNova provider is available via the sambanova-ai-provider module. You can install it with:
$ pnpm add sambanova-ai-provider
$ npm install sambanova-ai-provider
$ yarn add sambanova-ai-provider
$ bun add sambanova-ai-provider
Environment variables
Create a .env file with a SAMBANOVA_API_KEY variable.
Provider Instance
You can import the default provider instance sambanova from sambanova-ai-provider:
If you need a customized setup, you can import createSambaNova from sambanova-ai-provider and create a provider instance with your settings:
You can use the following optional settings to customize the SambaNova provider instance:
-
baseURL string
Use a different URL prefix for API calls, e.g. to use proxy servers. The default prefix is
https://api.sambanova.ai/v1. -
apiKey string
API key that is being sent using the
Authorizationheader. It defaults to theSAMBANOVA_API_KEYenvironment variable. -
headers Record<string,string>
Custom headers to include in the requests.
-
fetch (input: RequestInfo, init?: RequestInit) => Promise<Response>
Custom fetch implementation. Defaults to the global
fetchfunction. You can use it as a middleware to intercept requests, or to provide a custom fetch implementation for e.g. testing.
Models
You can use SambaNova models on a provider instance.
The first argument is the model id, e.g. Meta-Llama-3.1-70B-Instruct.
Tested models and capabilities
This provider is capable of generating and streaming text, and interpreting image inputs.
At least it has been tested with the following features (which use the /chat/completions endpoint):
| Chat completion | Image input |
|---|---|
Image input
You need to use any of the following models for visual understanding:
- Llama3.2-11B-Vision-Instruct
- Llama3.2-90B-Vision-Instruct
SambaNova does not support URLs, but the ai-sdk is able to download the file and send it to the model.
Example Usage
Basic demonstration of text generation using the SambaNova provider.
You will get an output text similar to this one:
Intercepting Fetch Requests
This provider supports Intercepting Fetch Requests.
Example
And you will get an output like this: