Chat

post/v1/chat/completions

Headers

X-Amz-Cf-Idstring nullable
CF-RAYstring nullable
X-delay-timenumber nullable

Request body

clear_thinkingboolean nullable

When True, removes reasoning content from messages that appear before the latest user message.

disable_reasoningboolean nullable

Disables reasoning for reasoning models. If set to True, the model will not use any reasoning in its response.

frequency_penaltynumber nullable

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.

logit_biasobject nullable

Modify the likelihood of specified tokens appearing in the completion.

Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.

logprobsboolean nullable

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.

max_completion_tokensinteger nullable

An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens.

max_tokensinteger nullable

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. This value is now deprecated in favor of max_completion_tokens.

min_completion_tokensinteger nullable

The minimum number of tokens to generate for a completion. If not specified or set to 0, the model will generate as many tokens as it deems necessary. Setting to -1 sets to max sequence length.

min_tokensinteger nullable

The minimum number of tokens to generate for a completion. If not specified or set to 0, the model will generate as many tokens as it deems necessary. Setting to -1 sets to max sequence length.

modelstring required
model_parametersobject nullable

Model-specific parameters. The accepted keys and values are defined per-model by the model's model_parameters schema. The schema is used downstream to validate the contents of this field. Unsupported for models that declare none.

ninteger nullable

How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep n as 1 to minimize costs.

parallel_tool_callsboolean nullable
presence_penaltynumber nullable

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.

prompt_cache_keystring nullable

An optional opaque string. The requests with the same prompt cache key would highly likely share the same prompt prefixes. Examples would be IDs of chat conversations, IDs of users, the hashes of system prompts, etc.

reasoning_effort'none' | 'low' | 'medium' | 'high'
reasoning_format'none' | 'parsed' | 'text_parsed' | 'raw' | 'hidden'
seedinteger nullable

If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed.

service_tier'auto' | 'default' | 'flex' | 'priority'
streamboolean nullable
temperaturenumber nullable

What sampling temperature to use, 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. We generally recommend altering this or top_p but not both.

top_logprobsinteger nullable

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.

top_pnumber nullable

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. We generally recommend altering this or temperature but not both.

userstring nullable

A unique identifier representing your end-user, which can help Cerebras to monitor and detect abuse.

Example request

{
  "max_completion_tokens": -1,
  "messages": [
    {
      "content": "You are a helpful assistant running on a CS-3 hardware at Cerebras Systems",
      "role": "system"
    },
    {
      "content": "What is Generative AI?",
      "role": "user"
    }
  ],
  "min_tokens": 1000,
  "model": "llama3.1-8b",
  "seed": 0,
  "stop_sequence": null,
  "stream": false,
  "temperature": 0,
  "top_p": 1
}

Response

Successful Response

OR
OR

Example response

{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "content": "Generative AI is a subfield of artificial intelligence that focuses on generating new, original content, such as images, music, text, or videos. These models are trained on large datasets and learn to recognize patterns, relationships, and structures within the data, allowing them to generate new content that is similar in style, tone, or characteristics to the training data. \n \n Generative AI models can be categorized into two main types: Generative Adversarial Networks (GANs) and Variational Autoencoders (VAEs). GANs consist of two neural networks: a generator and a discriminator. The generator creates new content, while the discriminator evaluates the generated content and tells the generator whether it's realistic or not. VAEs are neural networks that learn to compress and reconstruct data. \n \n Generative AI has numerous applications across various industries, including art and design, content generation, data augmentation, and recommendation systems. Some examples of Generative AI in action include Deep Dream Generator, Amper Music, and DALL-E. \n \n In summary, Generative AI is a powerful technology that enables the creation of new, original content using machine learning models. It has the potential to revolutionize various industries and create new opportunities for artists, designers, and content creators.",
        "role": "assistant"
      }
    }
  ],
  "created": 1721088719,
  "id": "response_1721",
  "model": "llama3.1-8b",
  "object": "chat.completion",
  "system_fingerprint": "88719",
  "time_info": {
    "completion_time": 0.44,
    "prompt_time": 0.02,
    "queue_time": 0,
    "total_time": 0.46
  },
  "usage": {
    "completion_tokens": 1020,
    "prompt_tokens": 40,
    "prompt_tokens_details": {
      "cached_tokens": 1020
    },
    "total_tokens": 1060
  }
}

Changes

Changed in 1 of the 51 revisions of this API.331430

  • 130749c46caf331430See the full diff
    • removed subschema #1 from the request property anyOf list

      request-property-any-of-removed

    • the request property became required

      request-property-became-required

    • removed the enum value content of the request property //

      request-property-enum-value-removed

    • removed the enum value json_object of the request property ///

      request-property-enum-value-removed

    • removed the enum value json_schema of the request property ///

      request-property-enum-value-removed

    • removed the enum value text of the request property /////

      request-property-enum-value-removed

    • removed the enum value text of the request property ///

      request-property-enum-value-removed

    • request property list-of-types was narrowed by removing types null from media type application/json

      request-property-list-of-types-narrowed

    • the request property's minItems was increased to 1

      request-property-min-items-increased

    • the response property /// became optional for the status

      response-property-became-optional

    • the response property ///// became optional for the status

      response-property-became-optional

    • the response property ///// became optional for the status

      response-property-became-optional

    • the response property //////// became optional for the status

      response-property-became-optional

    • the response property //////// became optional for the status

      response-property-became-optional

    • the response property /////// became optional for the status

      response-property-became-optional

    • the response property ///// became optional for the status

      response-property-became-optional

    • the response property ///// became optional for the status

      response-property-became-optional

    • the response property / became optional for the status

      response-property-became-optional

    • the response property / became optional for the status

      response-property-became-optional

    • the response property ////// became optional for the status

      response-property-became-optional

    • the response property ////// became optional for the status

      response-property-became-optional

    • the response property ////// became optional for the status

      response-property-became-optional

    • the response property ////// became optional for the status

      response-property-became-optional

    • response property anyOf[subschema #1: ChatCompletionResponse]/choices/items/finish_reason list-of-types was widened by adding types null to media type application/json of response 200

      response-property-list-of-types-widened

    • response property anyOf[subschema #1: ChatCompletionResponse]/choices/items/message/tool_calls/anyOf[subschema #1]/items/function/arguments list-of-types was widened by adding types null to media type application/json of response 200

      response-property-list-of-types-widened

    • response property anyOf[subschema #1: ChatCompletionResponse]/choices/items/message/tool_calls/anyOf[subschema #1]/items/function/name list-of-types was widened by adding types null to media type application/json of response 200

      response-property-list-of-types-widened

    • response property anyOf[subschema #1: ChatCompletionResponse]/choices/items/message/tool_calls/anyOf[subschema #1]/items/id list-of-types was widened by adding types null to media type application/json of response 200

      response-property-list-of-types-widened

    • response property anyOf[subschema #2: ChatChunkResponse]/time_info/anyOf[subschema #1: TimeInfo]/completion_time list-of-types was widened by adding types null to media type application/json of response 200

      response-property-list-of-types-widened

    • response property anyOf[subschema #2: ChatChunkResponse]/time_info/anyOf[subschema #1: TimeInfo]/prompt_time list-of-types was widened by adding types null to media type application/json of response 200

      response-property-list-of-types-widened

    • response property anyOf[subschema #2: ChatChunkResponse]/time_info/anyOf[subschema #1: TimeInfo]/queue_time list-of-types was widened by adding types null to media type application/json of response 200

      response-property-list-of-types-widened

    • response property anyOf[subschema #2: ChatChunkResponse]/time_info/anyOf[subschema #1: TimeInfo]/total_time list-of-types was widened by adding types null to media type application/json of response 200

      response-property-list-of-types-widened

    • the / response's property type changed from object to no type for status

      response-property-type-changed

    • the / response's property type changed from object to no type for status

      response-property-type-changed

    • the / request property's min was set to -1.00

      request-property-min-set

    • the / request property's min was set to -1.00

      request-property-min-set

    • the / request property's min was set to -1.00

      request-property-min-set

    • the / request property's min was set to -1.00

      request-property-min-set

    • the / request property's min was set to 1.00

      request-property-min-set

    • removed the optional property // from the response with the status

      response-optional-property-removed

    • removed the optional property // from the response with the status

      response-optional-property-removed

    • removed the optional property // from the response with the status

      response-optional-property-removed

    • removed the optional property // from the response with the status

      response-optional-property-removed

    • removed the optional property // from the response with the status

      response-optional-property-removed

    • removed the optional property // from the response with the status

      response-optional-property-removed

    • removed the optional property // from the response with the status

      response-optional-property-removed

    • removed the optional property // from the response with the status

      response-optional-property-removed

    • removed the optional property // from the response with the status

      response-optional-property-removed

    • added the new optional request property

      new-optional-request-property

    • added the new optional request property

      new-optional-request-property

    • added the media type application/msgpack to the request body

      request-body-media-type-added

    • added the media type application/vnd.msgpack to the request body

      request-body-media-type-added

    • added the media type application/x-msgpack to the request body

      request-body-media-type-added

    • added to the request property anyOf list

      request-property-any-of-added

    • the / request property's max was increased from 1.50 to 2.00

      request-property-max-increased

    • added the optional property /////// to the response with the status

      response-optional-property-added

    • added the optional property /// to the response with the status

      response-optional-property-added

    • added the optional property ///// to the response with the status

      response-optional-property-added

    • added the optional property /// to the response with the status

      response-optional-property-added

    • added subschema #2 to the / response property anyOf list for the response status

      response-property-any-of-added

    • added subschema #2 to the / response property anyOf list for the response status

      response-property-any-of-added

    • the response property const value chat.completion.chunk was added for the status

      response-property-const-added

    • the response's property default value 0 was removed for the status

      response-property-default-value-removed

    • the response's property default value 0 was removed for the status

      response-property-default-value-removed

    • the response's property default value 0 was removed for the status

      response-property-default-value-removed

    • the response's property default value 0 was removed for the status

      response-property-default-value-removed

    • response property anyOf[subschema #2: ChatChunkResponse]/choices/anyOf[subschema #1]/items/delta/anyOf[subschema #1: ChunkResponseMessage]/tokens deprecated

      response-property-deprecated

    • response property anyOf[subschema #2: ChatChunkResponse]/choices/anyOf[subschema #1]/items/text deprecated

      response-property-deprecated

    • response property anyOf[subschema #2: ChatChunkResponse]/choices/anyOf[subschema #1]/items/tokens deprecated

      response-property-deprecated

    • removed the chat.completion enum value from the / response property for the response status

      response-property-enum-value-removed

    • removed the chat.completion.chunk enum value from the / response property for the response status

      response-property-enum-value-removed

    • removed the content_filter enum value from the /// response property for the response status

      response-property-enum-value-removed

    • removed the function enum value from the /////// response property for the response status

      response-property-enum-value-removed

    • removed the function enum value from the ///////// response property for the response status

      response-property-enum-value-removed

    • removed the length enum value from the /// response property for the response status

      response-property-enum-value-removed

    • removed the stop enum value from the /// response property for the response status

      response-property-enum-value-removed

    • removed the text_completion enum value from the / response property for the response status

      response-property-enum-value-removed

    • removed the tool_calls enum value from the /// response property for the response status

      response-property-enum-value-removed

    This revision also has 4 changes that name no endpoint, such as unreferenced schemas being removed. See the revision's changelog

Of the 51 revisions, 49 have no diff computed.