Chat

The chat endpoints allow you to interact with Mingleego assistants, send messages, receive responses, and upload files.

Create chat completion

Creates a completion for the chat message.

POST https://mingleego.com/api/interactions/chat

Request

Headers

HeaderTypeRequiredDescription
x-api-keystringYesYour API key. Get your API key from the API Keys page.
Content-TypestringYesMust be application/json.

Request body

ParameterTypeRequiredDescription
assistantIdstringYesThe ID of the assistant to use for the completion.
promptstringYesThe message prompt to send to the assistant.
fileIdsstring[]NoAn array of file IDs to reference in the chat. These should be file IDs obtained from the file upload endpoint.

Example request

Basic request:

1
2
3
4
5
6
7

Request with file references:

1
2
3
4
5
6
7
8

Response

Returns the assistant's response to the chat message.

Status Code: 200 OK

The response body is a JSON object containing the completion text and an optional file URL.

Response body

FieldTypeDescription
textstringThe text response generated by the assistant.
fileUrlstring | nullIf the assistant generated a file (e.g., an image or document), this field contains the URL to access it. Otherwise, it is null.

Example response

Text-only response:

1
2
3
4

Response with generated file:

1
2
3
4

Response with file analysis:

1
2
3
4

Error responses

Status Code: 400 Bad Request

1
2
3
4

Status Code: 400 Bad Request (invalid request body)

1
2
3
4

Status Code: 500 Internal Server Error

1
2
3
4

Create streaming chat completion

Creates a streaming completion for the chat message using Server-Sent Events (SSE). The response is streamed back as the model generates it, allowing for real-time updates.

POST https://mingleego.com/api/interactions/chat/sse

Request

Headers

HeaderTypeRequiredDescription
x-api-keystringYesYour API key. Get your API key from the API Keys page.
Content-TypestringYesMust be application/json.

Request body

ParameterTypeRequiredDescription
assistantIdstringYesThe ID of the assistant to use for the completion.
promptstringYesThe message prompt to send to the assistant.
fileIdsstring[]NoAn array of file IDs to reference in the chat. These should be file IDs obtained from the file upload endpoint.

Example request

Basic request:

1
2
3
4
5
6
7

Request with file references:

1
2
3
4
5
6
7
8

Response

Returns a Server-Sent Events (SSE) stream. The response is sent incrementally as the model generates the completion.

Status Code: 200 OK

Content-Type: text/event-stream

The response is streamed as SSE events. Each event contains a chunk of the completion text. The final response format is the same as the non-streaming endpoint, with text and fileUrl fields.

Note: The SSE endpoint accepts the same request parameters as the regular chat endpoint. The only difference is the response format (streaming vs. complete response).

Example usage (JavaScript)

To handle streaming responses in JavaScript, you can use the fetch API with streaming:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

When to use streaming

Use the streaming endpoint when:

  • You want to display responses in real time as they're generated
  • You're building interactive chat applications
  • You need to reduce perceived latency for longer responses
  • You want to provide immediate feedback to users

Streaming is especially useful for chat interfaces where users expect to see text appear progressively rather than waiting for the complete response.

Upload file

Uploads a file that can be used in chat interactions. The uploaded file will be processed and made available for the assistant to reference.

POST https://mingleego.com/api/interactions/chat/file

Request

Headers

HeaderTypeRequiredDescription
x-api-keystringYesYour API key. Get your API key from the API Keys page.
AuthorizationstringNoBearer token (optional, can be used in addition to x-api-key).
Content-TypestringYesMust be multipart/form-data.

Request body

The request body must be sent as multipart/form-data.

ParameterTypeRequiredDescription
filefileYesThe file to upload. Supported file types depend on your assistant configuration.

Example request

1
2
3
4

Response

Returns the ID of the uploaded file. This file ID can be used in subsequent chat requests.

Status Code: 200 OK

Response Body: The file ID as a plain text string.

Example response

input_1764951853973_it_services.pdf

The response is the file ID that was assigned to the uploaded file. Use this ID when you need to reference the file in chat interactions.

Usage

After uploading a file, you can reference it in your chat requests. The file will be available for the assistant to read and use in generating responses.

Note: The file ID format may vary, but it typically includes a timestamp and the original filename. Store this ID if you need to reference the file in future requests.