Conversations

Send message (OpenAI format).

Changed on

Sends a message using the OpenAI-compatible request and response format. Use this if you are migrating from OpenAI or want to use existing OpenAI client libraries. Supports streaming for real-time responses.

Notes: This is a convenience endpoint for OpenAI compatibility. For full CustomGPT features, use the native message endpoint.

post/api/v1/projects/{projectId}/chat/completions

Request

Path parameters

projectIdinteger required

The unique identifier of the agent to send the message to.

Request body

modelstring nullable

ID of the model to use

streamboolean

Whether to stream the response

langstring

Response language

external_idstring nullable

External identifier

is_inline_citationboolean

Whether to include inline citations

labels_exclusiveboolean

If true, search only pages with provided labels. If false, search pages with provided labels plus unlabeled pages.

Example request

{
  "labels": [
    "27",
    "billing"
  ],
  "sub_personas": {
    "persona-summary": "Use a concise analyst tone.",
    "task-planner": "Extract risks first."
  }
}

Response

OpenAI-compatible chat completion response.

Non-streaming (stream: false or omitted): Returns a single JSON object with the complete response.

Streaming (stream: true): Returns Server-Sent Events (SSE) with text/event-stream content type.

Each SSE event is prefixed with data: followed by a JSON object:

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1743037634,"model":"gpt-4","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}

The stream ends with:

data: [DONE]

Key fields per chunk:

  • id: unique completion ID
  • object: always chat.completion.chunk
  • created: Unix timestamp
  • choices[0].delta.content: incremental text fragment
  • choices[0].finish_reason: null during stream, stop on final chunk

JavaScript client example:

const response = await fetch(
  'https://app.customgpt.ai/api/v1/projects/{projectId}/chat/completions',
  {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      messages: [{ role: 'user', content: 'Hello' }],
      stream: true
    })
  }
);

const reader = response.body.getReader();
const decoder = new TextDecoder();

while (true) {
  const { done, value } = await reader.read();
  if (done) break;

  const lines = decoder.decode(value).split('\n');
  for (const line of lines) {
    if (!line.startsWith('data: ')) continue;
    const payload = line.slice(6);
    if (payload === '[DONE]') break;

    const chunk = JSON.parse(payload);
    const text = chunk.choices[0]?.delta?.content || '';
    process.stdout.write(text);
  }
}
idstring
objectstring
createdinteger
modelstring nullable

Example response

{
  "id": "176",
  "object": "chat.completion",
  "created": 1743037634,
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "Hello! How can I assist you today?"
      },
      "finish_reason": "stop"
    }
  ]
}

Changes

    • warning

      added the new 422.00 enum value to the / response property for the response status

    • warning

      added the new 422.00 enum value to the / response property for the response status

    • warning

      added the new 422.00 enum value to the / response property for the response status

    • warning

      added the new 422.00 enum value to the / response property for the response status

    • warning

      added the new 422.00 enum value to the / response property for the response status

    • warning

      added the new 422.00 enum value to the / response property for the response status

    • info

      added the new optional request property

    • info

      added the new optional request property

    • info

      added the new optional request property

    • info

      added the media type text/event-stream for the response with the status

    • info

      endpoint added