Create Chat Completion

POST /v1/chat/completions

Generate a chat completion based on the provided messages and model parameters.

application/json

Body Required

  • model string Required

    The ID of the model to use for chat completion.

  • messages array[object] Required

    A list of messages comprising the conversation so far.

    Hide messages attributes Show messages attributes object
    • role string Required

      The role of the message author.

      Values are system, user, assistant, or tool.

    • content string | null | array[object] Required

      The content of the message. Can be a string, an array of content parts, or null for function messages.

      One of:
      Hide attributes Show attributes object
      • type string Required

        Values are text or image_url.

      • text string
      • Hide image_url attributes Show image_url attributes object
        • url string Required
        • detail string

          Values are auto, low, or high. Default value is auto.

    • name string

      The name of the author of this message. May be omitted in most cases.

    • Tool call ID if this message is a tool response.

    • tool_calls array[object]

      A list of tool calls made by the assistant.

      Hide tool_calls attributes Show tool_calls attributes object
      • id string Required

        The ID of the tool call.

      • type string Required

        The type of the tool call. Currently, only 'function' is supported.

        Value is function.

      • function object Required
        Hide function attributes Show function attributes object
        • name string Required

          The name of the function to call.

        • arguments string Required

          The arguments to be passed to the function, represented as a JSON string.

    • The function call made by the assistant. Deprecated: use tool_calls instead.

      Hide function_call attributes Show function_call attributes object
  • 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.

    Minimum value is 0, maximum value is 2. Default value is 1.0.

  • top_p number

    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.

    Minimum value is 0, maximum value is 1. Default value is 1.0.

  • n integer

    How many chat completion choices to generate for each input message.

    Minimum value is 1. Default value is 1.

  • stream boolean

    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.

    Default value is false.

  • max_tokens integer

    The maximum number of tokens to generate in the chat completion.

    Minimum value is 1.

  • 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.

    Minimum value is -2, maximum value is 2. Default value is 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.

    Minimum value is -2, maximum value is 2. Default value is 0.

  • Modify the likelihood of specified tokens appearing in the completion.

    Hide logit_bias attribute Show logit_bias attribute object
    • * number Additional properties

      Modify the likelihood of specified tokens appearing in the completion.

  • user string

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

  • tools array[object]

    A list of tools the model may call. Currently, only functions are supported as a tool.

    Hide tools attributes Show tools attributes object
    • type string Required

      The type of tool. Currently, only 'function' is supported.

      Value is function.

    • function object Required
      Hide function attributes Show function attributes object
      • name string Required

        The name of the function to be called.

      • parameters object Required

        The parameters the function accepts, described as a JSON Schema object.

      • A description of what the function does.

  • tool_choice string | object

    Controls how the model uses tools.

    One of:

    Controls how the model uses tools. 'auto' allows the model to use tools when appropriate, 'none' disables tool usage.

    Values are auto or none.

Responses

  • 200 application/json

    Successful Response

    Hide response attributes Show response attributes object
    • id string Required

      A unique identifier for the chat completion.

    • object string Required

      The object type, which is always 'chat.completion'.

      Value is chat.completion.

    • created integer Required

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

    • model string Required

      The model used for the chat completion.

    • choices array[object] Required

      An array of chat completion choices.

      Hide choices attributes Show choices attributes object
      • index integer Required

        The index of the choice in the array of choices.

      • message object Required
        Hide message attributes Show message attributes object
        • role string Required

          The role of the message author.

          Values are system, user, assistant, or tool.

        • content string | null | array[object] Required

          The content of the message. Can be a string, an array of content parts, or null for function messages.

          One of:
          Hide attributes Show attributes object
          • type string Required

            Values are text or image_url.

          • text string
          • Hide image_url attributes Show image_url attributes object
            • url string Required
            • detail string

              Values are auto, low, or high. Default value is auto.

        • name string

          The name of the author of this message. May be omitted in most cases.

        • Tool call ID if this message is a tool response.

        • tool_calls array[object]

          A list of tool calls made by the assistant.

          Hide tool_calls attributes Show tool_calls attributes object
          • id string Required

            The ID of the tool call.

          • type string Required

            The type of the tool call. Currently, only 'function' is supported.

            Value is function.

          • function object Required
            Hide function attributes Show function attributes object
            • name string Required

              The name of the function to call.

            • arguments string Required

              The arguments to be passed to the function, represented as a JSON string.

        • The function call made by the assistant. Deprecated: use tool_calls instead.

          Hide function_call attributes Show function_call attributes object
      • finish_reason string Required

        The reason the chat completion finished.

        Values are stop, length, tool_calls, content_filter, or function_call.

    • usage object

      Usage statistics for the chat completion.

      Hide usage attributes Show usage attributes object
      • prompt_tokens integer Required

        The number of tokens in the prompt.

      • completion_tokens integer Required

        The number of tokens in the generated completion.

      • total_tokens integer Required

        The total number of tokens used in the request and response.

  • 400 application/json

    Bad Request

    Hide response attribute Show response attribute object
    • error object Required
      Hide error attributes Show error attributes object
      • message string Required

        A human-readable error message.

      • type string Required

        The type of error that occurred.

      • param string | null Required

        The parameter that caused the error, if applicable.

      • code string Required

        A machine-readable error code.

  • 401 application/json

    Unauthorized

    Hide response attribute Show response attribute object
    • error object Required
      Hide error attributes Show error attributes object
      • message string Required

        A human-readable error message.

      • type string Required

        The type of error that occurred.

      • param string | null Required

        The parameter that caused the error, if applicable.

      • code string Required

        A machine-readable error code.

  • 429 application/json

    Too Many Requests

    Hide response attribute Show response attribute object
    • error object Required
      Hide error attributes Show error attributes object
      • message string Required

        A human-readable error message.

      • type string Required

        The type of error that occurred.

      • param string | null Required

        The parameter that caused the error, if applicable.

      • code string Required

        A machine-readable error code.

POST /v1/chat/completions
curl \
 -X POST https://api.rimunace.xyz/v1/chat/completions \
 -H "Authorization: $API_KEY" \
 -H "Content-Type: application/json" \
 -d '{"model":"string","messages":[{"role":"system","content":"string","name":"string","tool_call_id":"string","tool_calls":[{"id":"string","type":"function","function":{"name":"string","arguments":"string"}}],"function_call":{"name":"string","arguments":"string"}}],"temperature":1.0,"top_p":1.0,"n":1,"stream":false,"max_tokens":42,"presence_penalty":0,"frequency_penalty":0,"logit_bias":{"additionalProperty1":42.0,"additionalProperty2":42.0},"user":"string","tools":[{"type":"function","function":{"name":"string","parameters":{},"description":"string"}}],"tool_choice":"auto"}'
Request examples
{
  "model": "string",
  "messages": [
    {
      "role": "system",
      "content": "string",
      "name": "string",
      "tool_call_id": "string",
      "tool_calls": [
        {
          "id": "string",
          "type": "function",
          "function": {
            "name": "string",
            "arguments": "string"
          }
        }
      ],
      "function_call": {
        "name": "string",
        "arguments": "string"
      }
    }
  ],
  "temperature": 1.0,
  "top_p": 1.0,
  "n": 1,
  "stream": false,
  "max_tokens": 42,
  "presence_penalty": 0,
  "frequency_penalty": 0,
  "logit_bias": {
    "additionalProperty1": 42.0,
    "additionalProperty2": 42.0
  },
  "user": "string",
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "string",
        "parameters": {},
        "description": "string"
      }
    }
  ],
  "tool_choice": "auto"
}
Response examples (200)
{
  "id": "string",
  "object": "chat.completion",
  "created": 42,
  "model": "string",
  "choices": [
    {
      "index": 42,
      "message": {
        "role": "system",
        "content": "string",
        "name": "string",
        "tool_call_id": "string",
        "tool_calls": [
          {
            "id": "string",
            "type": "function",
            "function": {
              "name": "string",
              "arguments": "string"
            }
          }
        ],
        "function_call": {
          "name": "string",
          "arguments": "string"
        }
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 42,
    "completion_tokens": 42,
    "total_tokens": 42
  }
}
Response examples (400)
{
  "error": {
    "message": "string",
    "type": "string",
    "param": "string",
    "code": "string"
  }
}
Response examples (401)
{
  "error": {
    "message": "string",
    "type": "string",
    "param": "string",
    "code": "string"
  }
}
Response examples (429)
{
  "error": {
    "message": "string",
    "type": "string",
    "param": "string",
    "code": "string"
  }
}