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 thebase_url and api_key. The api_key should be saved in a secure location.
-
Set the
base_urlto the“https://api.sambanova.ai/v1”. -
Set the
api_keyto the"YOUR SAMBANOVA CLOUD API KEY".
Don’t have a SambaNova Cloud API key? Get yours from the SambaNova Cloud portal.
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 thetop_k parameter. This is not supported by the OpenAI client.