Skip to main content
POST
/
chat
/
completions
JavaScript
import SambaNova from 'sambanova';

const client = new SambaNova({
  apiKey: 'My API Key',
});

const completion = await client.chat.completions.create({
  messages: [{ content: 'create a poem using palindromes', role: 'user' }],
  model: 'string',
});

console.log(completion);
{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "content": "In madam moon's silver glow,  Aha, a palindrome to know,  Radar spins, a circular tale,  Level heads prevail, without fail.  A man, a plan, a canal, Panama!  Able was I ere I saw Elba,  A Santa at NASA, a curious sight,  Do geese see God, in the pale moonlight?  Mr. Owl ate my metal worm,  Do nine men interpret? Nine men, I nod,  Never odd or even, a palindrome's might,  Madam, in Eden, I'm Adam.  Aibohphobia, a fear to confess,  A palindrome's symmetry, I must address,  Refer, a word that reads the same,  A palindrome's beauty, in its circular game.  In the stillness of the night,  Ava, a palindrome, shining bright,  Hannah, a name that reads the same,  A palindrome's magic, in its circular flame.  Note: Please keep in mind that creating a poem using palindromes can be a challenging task,  and the resulting poem may not be as cohesive or flowing as one that doesn't rely on palindromes.  However, I hope you enjoy the attempt!",
        "role": "assistant"
      }
    }
  ],
  "created": 1737583288.6076705,
  "id": "83a7809d-e18f-44f9-9ab7-2bc494c6c661",
  "model": "Meta-Llama-3.3-70B-Instruct",
  "object": "chat.completion",
  "system_fingerprint": "fastcoe",
  "usage": {
    "acceptance_rate": 4.058139324188232,
    "completion_tokens": 350,
    "completion_tokens_after_first_per_sec": 248.09314856382406,
    "completion_tokens_after_first_per_sec_first_ten": 249.67922929952655,
    "completion_tokens_per_sec": 238.91966176995348,
    "end_time": 1737583289.7345645,
    "is_last_response": true,
    "prompt_tokens": 43,
    "start_time": 1737583288.264706,
    "time_to_first_token": 0.06312894821166992,
    "total_latency": 1.4649275719174653,
    "total_tokens": 393,
    "total_tokens_per_sec": 268.27264878740493
  }
}

Authorizations

Authorization
string
header
required

SambaNova API Key

Body

application/json

Chat prompt and parameters

chat completions request object

model
required

The model ID to use (e.g. Meta-Llama-3.3-70B-Instruct). See available models

messages
Messages · array
required

A list of messages comprising the conversation so far.

Minimum length: 1
  • System Message
  • User Message
  • Assistant Message
  • Tool Message
Examples:
[
{
"role": "user",
"content": "create a poem using palindromes"
}
]
max_tokens
integer | null

The maximum number of tokens that can be generated in the chat completion. The total length of input tokens and generated tokens is limited by the model's context length.

Example:

2048

max_completion_tokens
integer | null

The maximum number of tokens that can be generated in the chat completion. The total length of input tokens and generated tokens is limited by the model's context length.

Example:

2048

temperature
number | null
default:0.7

What sampling temperature to use, determines the degree of randomness in the response. between 0 and 2, Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. Is recommended altering this, top_p or top_k but not more than one of these.

Required range: 0 <= x <= 1
Example:

0.7

top_p
number | null

Cumulative probability for token choices. An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. Is recommended altering this, top_k or temperature but not more than one of these.

Required range: 0 <= x <= 1
Example:

1

top_k
integer | null

Amount limit of token choices. An alternative to sampling with temperature, the model considers the results of the first K tokens with higher probability. So 10 means only the first 10 tokens with higher probability are considered. Is recommended altering this, top_p or temperature but not more than one of these.

Required range: 1 <= x <= 100
Example:

5

presence_penalty
number | null
default:0

Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.

Required range: -2 <= x <= 2
frequency_penalty
number
default:0

Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.

Required range: -2 <= x <= 2
do_sample
boolean | null

If true, sampling is enabled during output generation. If false, deterministic decoding is used.

stop

Sequences where the API will stop generating tokens. The returned text will not contain the stop sequence.

Example:

"\n"

stream
boolean | null
default:false

If set, partial message deltas will be sent. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message.

stream_options
object | null

Options for streaming response. Only set this when setting stream as true

response_format
object

An object specifying the format that the model must output. Setting to { "type": "json_object"} enables JSON mode, which will check the message the model generates is valid JSON. Important: when using JSON mode, you must also instruct the model to produce JSON yourself via a system or user message. Setting to { "type": "json_schema", "json_schema": {<your_schema>}"} enables JSON schema mode, which will check the message the model generates is valid object of type <your_schema>. Specifies that the model should produce output as plain text.

  • ResponseFormatText
  • ResponseFormatJSONObject
  • ResponseFormatJSONSchema
reasoning_effort
enum<string> | null

Value specifying the amount of reasoning the model is allowed to do, increasing it will increase the number of output reasoning tokens generated by the model, but will improve quality of the responses. allowed values are 'low', 'medium', 'high'

Available options:
low,
medium,
high
tool_choice

Controls which (if any) tool is called by the model. none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools. Specifying a particular tool via {"type": "function", "function": {"name": "my_function"}} forces the model to call that tool.

Available options:
none,
auto,
required
parallel_tool_calls
boolean | null

Whether to enable parallel function calling during tool use.

tools
Tool · object[] | null

A list of tools the model may call. Use this to provide a list of functions the model may generate JSON inputs for.

Maximum length: 128
logprobs
boolean | null
default:false

This is not yet supported by our models. Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the content of message.

top_logprobs
integer | null

This is not yet supported by our models. An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true if this parameter is used.

Required range: 0 <= x <= 20
n
integer | null
default:1

This is not yet supported by our models. How many chat completion choices to generate for each input message.

Required range: 1 <= x <= 1
Example:

1

logit_bias
object | null

This is not yet supported by our models. Modify the likelihood of specified tokens appearing in the completion.

seed
integer | null

This is not yet supported by our models.

Response

Successful Response, or model output error (when unsuccessful tool calling or structured response generation)

  • Chat Completion Response
  • Chat Completion Stream Response
  • ModelOutputError
  • GeneralError

chat completion response returned by the model

choices
Chat Completion Choice · object[]
required
Minimum length: 1
created
number
required

The Unix timestamp (in seconds) of when the chat completion was created.

id
string
required

A unique identifier for the chat completion.

model
string
required

The model used for the chat completion.

object
enum<string>
required

The object type, always chat.completion.

Available options:
TitleConst
Objectchat.completion
system_fingerprint
string
required

Backend configuration that the model runs with.

usage
object | null
required

Usage metrics for the completion, embeddings,transcription or translation request

Examples:
{
"acceptance_rate": 4.058139324188232,
"completion_tokens": 350,
"completion_tokens_after_first_per_sec": 248.09314856382406,
"completion_tokens_after_first_per_sec_first_ten": 249.67922929952655,
"completion_tokens_after_first_per_sec_graph": 452.5030493415834,
"completion_tokens_per_sec": 238.91966176995348,
"end_time": 1737583289.7345645,
"is_last_response": true,
"prompt_tokens_details": { "cached_tokens": 0 },
"prompt_tokens": 43,
"start_time": 1737583288.264706,
"time_to_first_token": 0.06312894821166992,
"total_latency": 1.4649275719174653,
"total_tokens": 393,
"total_tokens_per_sec": 268.27264878740493
}
{ "prompt_tokens": 43, "total_tokens": 393 }
I