> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chatcsv.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Chat Completion

> Given a list of messages comprising a conversation, the model will return a response.

### Body

<ResponseField name="model" type="string">
  The model used to generate the response.
  `gpt-4o-mini`. Default is `gpt-4o-mini`.
</ResponseField>

<ResponseField name="messages" type="array" required>
  A list of messages

  <Expandable title="Messages object" defaultOpen>
    <ResponseField name="role" type="string" required>
      The role of the messages author. One of `assistant` or `user`
    </ResponseField>

    <ResponseField name="content" type="string" required>
      The contents of the message. `content` is required for all messages, and may
      be null for assistant messages with function calls.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="files" type="array">
  A list of file URLs to ask questions. All URLs must be publicly accessible. We currently support `csv`, `json`, `xlsx`, `txt`, `html`, `xml`, `parquet`, `dta`, `sas`, `sav`.

  If you want a file supporting, get in touch at <a href="mailto:sam@chatcsv.co?subject=FileType">[sam@chatcsv.co](mailto:sam@chatcsv.co)</a>

  <Expandable title="Toggle object" defaultOpen>
    <ResponseField>
      A list of file urls.

      Example: `["https://data.set/titanic.csv"]`
    </ResponseField>
  </Expandable>
</ResponseField>

### Response

Response will be sent as [data-only server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#event_stream_format) as they become available.

Example: `Hey, how can I help?`

<RequestExample>
  ```bash Example Request theme={null}
  curl --no-buffer \
      -X POST \
      -H 'accept: text/event-stream' \
      -H 'Content-Type: application/json' \
      -H 'Authorization: Bearer <token>' \
      -d '{
          "model": "gpt-4o-mini",
          "messages": [
              {
                  "role": "user",
                  "content": "whats your name"
              },
              {
                  "role": "assistant",
                  "content": "bob"
              },
              {
                  "role": "user",
                  "content": "show me some interesting visuals about this data. but start with what q i asked first"
              }
          ],
          "files": [
              "https://raw.githubusercontent.com/datasciencedojo/datasets/master/titanic.csv"
          ]
      }' \
      'https://www.chatcsv.co/api/v1/chat'
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  How may I help you today?
  ```
</ResponseExample>
