pip install openai
base_url
and api_key
. The api_key
should be saved in a secure location.
base_url
to the “https://api.sambanova.ai/v1”
.
api_key
to the "YOUR SAMBACLOUD API KEY"
.
from openai import OpenAI
client = OpenAI(
base_url="https://api.sambanova.ai/v1",
api_key="YOUR SAMBACLOUD API KEY"
)
completion = client.chat.completions.create(
model="Meta-Llama-3.1-8B-Instruct",
messages = [
{"role": "system", "content": "Answer the question in a couple sentences."},
{"role": "user", "content": "Share a happy story with me"}
]
)
print(completion.choices[0].message)
completion = client.chat.completions.create(
model="Meta-Llama-3.1-8B-Instruct",
messages = [
{"role": "system", "content": "Answer the question in a couple sentences."},
{"role": "user", "content": "Share a happy story with me"}
],
stream= True
)
for chunk in completion:
print(chunk.choices[0].delta.content)
logprobs
top_logprobs
n
presence_penalty
frequency_penalty
logit_bias
seed
temperature
: The SambaCloud API supports a value between 0 and 1.
top_k
parameter. This is not supported by the OpenAI client.