OpenAI compatibility
Use the SambaNova Cloud API with OpenAI’s client libraries to easily upgrade your existing applications to use the fastest inference on the best open source models!
Download the library
Run the command below to download the library.
Use SambaNova APIs with OpenAI client libraries
Switching to SambaNova APIs with OpenAI’s client libraries is as simple as setting two values, as shown below. Start a new file and create the client variable by passing the base_url
and api_key
. The api_key
should be saved in a secure location.
-
Set the
base_url
to the“https://api.sambanova.ai/v1”
. -
Set the
api_key
to the"YOUR SAMBANOVA CLOUD API KEY"
.
Don’t have a SambaNova Cloud API key? Get yours from the SambaNova Cloud portal.
Now you can make an API request to a model and choose how to receive your output.
Non-streaming example
The following code demonstrates using the OpenAI python client for non-streaming completions.
Streaming example
The following code demonstrates using the OpenAI python client for streaming completions.
Unsupported OpenAI features
The following features are not yet supported and will be ignored:
-
logprobs
-
top_logprobs
-
n
-
presence_penalty
-
frequency_penalty
-
logit_bias
-
seed
Feature differences
temperature
: The SambaNova Cloud API supports a value between 0 and 1.
Features unsupported by OpenAI clients
The SambaNova API supports the top_k
parameter. This is not supported by the OpenAI client.