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

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

const completion = await client.completions.create({
  model: 'string',
  prompt:
    '<|begin_of_text|><|start_header_id|>system<|end_header_id|>\nYou are a helpful assistant.<|eot_id|><|start_header_id|>user<|end_header_id|>\ncreate a poem using palindromes<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n',
});

console.log(completion);
{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "text": "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!"
    }
  ],
  "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

text prompt and parameters

completions request object

model
required

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

prompt
string
required

Prompt to send to the model.

Examples:

"<|begin_of_text|><|start_header_id|>system<|end_header_id|>\nYou are a helpful assistant.<|eot_id|><|start_header_id|>user<|end_header_id|>\ncreate a poem using palindromes<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n"

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

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

  • Completion Response
  • Completion Stream Response

ompletion response returned by the model

choices
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 }