POST/chat/completions

Completions

This endpoint creates a model response for the given chat conversation.

Request body

  • Name
    messages
    Type
    array
    Required
    Description

    A list of messages comprising the conversation so far. Example Python code.

  • Name
    model
    Type
    string
    Required
    Description

    Name of the Mind that you created.

  • Name
    stream
    Type
    boolean
    Description

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

  • Name
    frequency_penalty
    Type
    number
    Description

    This setting ranges from -2.0 to 2.0. Positive values make the model less likely to repeat phrases it has already used.

  • Name
    max_tokens
    Type
    integer
    Description

    This parameter sets the maximum number of tokens that can be generated in the chat completion. It's limited by the model's total allowable context length, which includes both the input and generated tokens. Here's an example of Python code to count tokens.

  • Name
    temperature
    Type
    number
    Description

    This parameter controls the randomness of the output with values ranging from 0 to 2. A higher value, increases randomness in the output, while a lower value, like 0.1, results in more focused and deterministic output.

  • Name
    tools
    Type
    array
    Description

    This setting allows you to specify a list of tools that the model can call, currently limited to functions.

Request

POST
/chat/completions
curl https://mdb.ai/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MINDS_API_KEY" \
-d '{
  "model": "<name of the mind that you created>",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user",
      "content": "Hello!"
    }
  ],
  "stream": false
}'

Response

{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1702685778,
  "model": "<name of the mind that you created>",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I assist you today?"
      }
    }
  ]
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 9,
    "total_tokens": 18
  },
  "system_fingerprint": null
}

Was this page helpful?