import os
from cerebras.cloud.sdk import Cerebras
client = Cerebras(
api_key=os.environ.get("CEREBRAS_API_KEY"), # This is the default and can be omitted
)
completion = client.completions.create(
prompt="It was a dark and stormy night",
max_tokens=100,
model="llama3.1-8b",
logprobs=5,
)
print(completion)
{
"id": "chatcmpl-b8718798-d389-4421-9242-13b07e84983b",
"choices": [
{
"finish_reason": "length",
"index": 0,
"text": " when I stumbled upon a small, quirky shop tucked away in a quiet alley. The sign above the door read \"Curios and Wonders,\" and the windows were filled with a dazzling array of strange and exotic items. I pushed open the door and stepped inside, my eyes adjusting to the dim light within.\n\nThe shop was a treasure trove of oddities, with shelves upon shelves of peculiar objects that seemed to defy explanation. There were vintage taxidermy animals, antique medical equipment, and",
"logprobs": {
"text_offset": [0, 5, 7, 16, 21, 23],
"token_logprobs": [-0.15, -0.08, -0.22, -0.11, -0.19, -0.05],
"tokens": [" when", " I", " stumbled", " upon", " a", " small"],
"top_logprobs": [
{
" when": -0.15,
",": -1.8,
".": -2.3,
" and": -2.9,
" as": -3.2
},
{
" I": -0.08,
" the": -2.1,
" a": -2.7,
" she": -3.4,
" he": -3.6
},
{
" stumbled": -0.22,
" walked": -1.5,
" discovered": -2.8,
" came": -3.1,
" found": -3.5
}
// ... (remaining tokens omitted for brevity)
]
}
}
],
"created": 1731597024,
"model": "llama3.1-8b",
"system_fingerprint": "fp_e8eacef18a",
"object": "text_completion",
"usage": {
"prompt_tokens": 10,
"completion_tokens": 100,
"total_tokens": 110
},
"time_info": {
"queue_time": 4.673e-05,
"prompt_time": 0.0004940576161616161,
"completion_time": 0.045957338383838385,
"total_time": 0.058876991271972656,
"created": 1731597024
}
}
import os
from cerebras.cloud.sdk import Cerebras
client = Cerebras(
api_key=os.environ.get("CEREBRAS_API_KEY"), # This is the default and can be omitted
)
completion = client.completions.create(
prompt="It was a dark and stormy night",
max_tokens=100,
model="llama3.1-8b",
logprobs=5,
)
print(completion)
{
"id": "chatcmpl-b8718798-d389-4421-9242-13b07e84983b",
"choices": [
{
"finish_reason": "length",
"index": 0,
"text": " when I stumbled upon a small, quirky shop tucked away in a quiet alley. The sign above the door read \"Curios and Wonders,\" and the windows were filled with a dazzling array of strange and exotic items. I pushed open the door and stepped inside, my eyes adjusting to the dim light within.\n\nThe shop was a treasure trove of oddities, with shelves upon shelves of peculiar objects that seemed to defy explanation. There were vintage taxidermy animals, antique medical equipment, and",
"logprobs": {
"text_offset": [0, 5, 7, 16, 21, 23],
"token_logprobs": [-0.15, -0.08, -0.22, -0.11, -0.19, -0.05],
"tokens": [" when", " I", " stumbled", " upon", " a", " small"],
"top_logprobs": [
{
" when": -0.15,
",": -1.8,
".": -2.3,
" and": -2.9,
" as": -3.2
},
{
" I": -0.08,
" the": -2.1,
" a": -2.7,
" she": -3.4,
" he": -3.6
},
{
" stumbled": -0.22,
" walked": -1.5,
" discovered": -2.8,
" came": -3.1,
" found": -3.5
}
// ... (remaining tokens omitted for brevity)
]
}
}
],
"created": 1731597024,
"model": "llama3.1-8b",
"system_fingerprint": "fp_e8eacef18a",
"object": "text_completion",
"usage": {
"prompt_tokens": 10,
"completion_tokens": 100,
"total_tokens": 110
},
"time_info": {
"queue_time": 4.673e-05,
"prompt_time": 0.0004940576161616161,
"completion_time": 0.045957338383838385,
"total_time": 0.058876991271972656,
"created": 1731597024
}
}
""llama3.1-8bllama-3.3-70bqwen-3-32bqwen-3-235b-a22b-instruct-2507 (preview)data: [DONE] message.Default: falsefalsenullnullroot, fcall, nofcall, insidevalue, value, object, array, string, number, funcarray, func, ws.Default: nullseed and parameters should return the same result. Determinism is not guaranteed.Default: nullnulltop_p but not both.Default: 1.0temperature but not both.Default: 1.0return_raw_tokens=True.Default: falsenulllogprobs is 5, the API will return a list of the 5 most likely tokens. The API will always return the logprob of the sampled token, so there may be up to logprobs+1 elements in the response.The max value is 20.Default: nulllogprobs to 0 is different than null. When set to null, log probabilities are disabled entirely. When set to 0, log probabilities are enabled but it does not return top_logprobs.Show properties
stop if the model hit a natural stop point or a provided stop sequence, length if the maximum number of tokens specified in the request was reached, or content_filter if content was omitted due to a flag from our content filters.Show properties
top_logprobs returned.seed request parameter to understand when backend changes have been made that might impact determinism.import os
from cerebras.cloud.sdk import Cerebras
client = Cerebras(
api_key=os.environ.get("CEREBRAS_API_KEY"), # This is the default and can be omitted
)
completion = client.completions.create(
prompt="It was a dark and stormy night",
max_tokens=100,
model="llama3.1-8b",
logprobs=5,
)
print(completion)
{
"id": "chatcmpl-b8718798-d389-4421-9242-13b07e84983b",
"choices": [
{
"finish_reason": "length",
"index": 0,
"text": " when I stumbled upon a small, quirky shop tucked away in a quiet alley. The sign above the door read \"Curios and Wonders,\" and the windows were filled with a dazzling array of strange and exotic items. I pushed open the door and stepped inside, my eyes adjusting to the dim light within.\n\nThe shop was a treasure trove of oddities, with shelves upon shelves of peculiar objects that seemed to defy explanation. There were vintage taxidermy animals, antique medical equipment, and",
"logprobs": {
"text_offset": [0, 5, 7, 16, 21, 23],
"token_logprobs": [-0.15, -0.08, -0.22, -0.11, -0.19, -0.05],
"tokens": [" when", " I", " stumbled", " upon", " a", " small"],
"top_logprobs": [
{
" when": -0.15,
",": -1.8,
".": -2.3,
" and": -2.9,
" as": -3.2
},
{
" I": -0.08,
" the": -2.1,
" a": -2.7,
" she": -3.4,
" he": -3.6
},
{
" stumbled": -0.22,
" walked": -1.5,
" discovered": -2.8,
" came": -3.1,
" found": -3.5
}
// ... (remaining tokens omitted for brevity)
]
}
}
],
"created": 1731597024,
"model": "llama3.1-8b",
"system_fingerprint": "fp_e8eacef18a",
"object": "text_completion",
"usage": {
"prompt_tokens": 10,
"completion_tokens": 100,
"total_tokens": 110
},
"time_info": {
"queue_time": 4.673e-05,
"prompt_time": 0.0004940576161616161,
"completion_time": 0.045957338383838385,
"total_time": 0.058876991271972656,
"created": 1731597024
}
}
Was this page helpful?