Skip to main content

Chat Completions

POST 

/v1/chat/completions

Follows the exact same API spec as OpenAI's Chat API https://platform.openai.com/docs/api-reference/chat

Request​

Body

required

    model stringrequired

    ID of the model to use

    messages

    object[]

    required

    A list of messages comprising the conversation so far

  • Array [

  • oneOf

    role stringrequired

    The role of the message author

    Possible values: [user]

    content

    object

    required

    The contents of the message

    anyOf

    The text contents of the message

    string

    name string

    An optional name for the participant

  • ]

  • frequency_penalty numbernullable

    Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far

    Possible values: >= -2 and <= 2

    Default value: 0

    logit_bias

    object

    nullable

    Modify the likelihood of specified tokens appearing in the completion

    property name* integer
    logprobs booleannullable

    Whether to return log probabilities of the output tokens (must be paired with top_logprobs set and viceversa)

    Default value: false
    top_logprobs integernullable

    An integer between 0 and 20 specifying the number of most likely tokens to return at each token position (must be paired with logprobs set to true and viceversa)

    Possible values: <= 20

    max_tokens integernullable

    The maximum number of tokens that can be generated in the chat completion

    Default value: 16
    n integernullable

    How many chat completion choices to generate for each input message

    Possible values: >= 1 and <= 128

    Default value: 1
    presence_penalty numbernullable

    Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far

    Possible values: >= -2 and <= 2

    Default value: 0

    response_format

    object

    nullable

    An object specifying the format that the model must output

    type string

    The type of response format

    Possible values: [text, json_object, json_schema]

    json_schema

    object

    The JSON schema for the response format

    name string
    description string
    schema object
    strict boolean
    Default value: false
    seed integernullable

    If specified, our system will make a best effort to sample deterministically

    stop

    object

    Up to 4 sequences where the API will stop generating further tokens

    oneOf

    string

    stream booleannullable

    If set, partial message deltas will be sent

    Default value: false

    stream_options

    object

    nullable

    Options for streaming response

    include_usage boolean

    If set, an additional chunk will be streamed with usage statistics

    temperature numbernullable

    What sampling temperature to use, between 0 and 2

    Possible values: <= 2

    Default value: 1
    top_p numbernullable

    An alternative to sampling with temperature, called nucleus sampling

    Possible values: <= 1

    Default value: 1

    tools

    object[]

    nullable

    A list of tools the model may call

  • Array [

  • type stringrequired

    The type of the tool

    Possible values: [function]

    function

    object

    required

    name stringrequired

    The name of the function to be called

    description string

    A description of what the function does

    parameters object

    The parameters the functions accepts, described as a JSON Schema object

    strict boolean

    Whether to enable strict schema adherence

    Default value: false
  • ]

  • tool_choice

    object

    Controls which (if any) tool is called by the model

    oneOf

    Controls which (if any) tool is called by the model

    string

    Possible values: [none, auto, required]

    parallel_tool_calls booleannullable

    Whether to enable parallel function calling during tool use

    Default value: true
    user stringnullable

    A unique identifier representing your end-user

Responses​

Successful Response

Schema

    id stringrequired

    A unique identifier for the chat completion

    object stringrequired

    The object type, which is always chat.completion

    Possible values: [chat.completion]

    created integerrequired

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

    model stringrequired

    The model used for the chat completion

    choices

    object[]

    required

    A list of chat completion choices

  • Array [

  • index integerrequired

    The index of the choice in the list of choices

    message

    object

    required

    role stringrequired

    The role of the message author

    Possible values: [assistant]

    content stringnullable

    The contents of the message

    name string

    An optional name for the participant

    tool_calls

    object[]

    The tool calls generated by the model

  • Array [

  • id stringrequired

    The ID of the tool call

    type stringrequired

    The type of the tool

    Possible values: [function]

    function

    object

    required

    name stringrequired

    The name of the function to call

    arguments stringrequired

    The arguments to call the function with, as generated by the model in JSON format

  • ]

  • function_call

    object

    deprecated

    Deprecated and replaced by tool_calls

    name stringrequired

    The name of the function to call

    arguments stringrequired

    The arguments to call the function with

    logprobs objectnullable

    Log probability information for the choice

    finish_reason stringrequired

    The reason the model stopped generating tokens

    Possible values: [stop, length, tool_calls, content_filter, function_call]

  • ]

  • usage

    object

    required

    prompt_tokens integerrequired

    Number of tokens in the prompt

    completion_tokens integerrequired

    Number of tokens in the generated completion

    total_tokens integerrequired

    Total number of tokens used in the request

    system_fingerprint string

    This fingerprint represents the backend configuration

Loading...