Skip to content
Start Trading

Create Message

ThreadCreateMessageResponse v1().omniAi().threads().createMessage(ThreadCreateMessageParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
POST/v1/omni-ai/threads/{thread_id}/messages

Append a user message to an existing thread and start an assistant response. Poll the returned response_id via GET /omni-ai/responses/{response_id} for assistant output.

A message sent while another response is active is accepted, and its response is queued. Omni reads the message at the next safe point of the active response. The active response then ends steered if it showed text, or merged if it did not, and the response for the newest message answers everything sent so far. Earlier queued responses that it answers also end merged. Some requests, such as research, do not steer: their responses, and the responses for messages sent after them, start in order after the earlier responses end.

The first accepted selected-account message links an unlinked thread. A linked thread keeps its account regardless of omission or another selection. A changed scope also returns 409 without accepting a turn.

ParametersExpand Collapse
ThreadCreateMessageParams params
Optional<String> threadId
String text
Optional<Long> accountId

Selected account for creation or the first account-linked turn. Omit for an unlinked conversation. An existing account link remains authoritative even when another account is selected.

formatint64
minimum1
Optional<List<Capability>> capabilities
PREFILL_ORDER("PREFILL_ORDER")
OPEN_CHART("OPEN_CHART")
OPEN_SCREENER("OPEN_SCREENER")
OPEN_ENTITLEMENT_CONSENT("OPEN_ENTITLEMENT_CONSENT")
Optional<TurnContext> context

Snapshots for this instant-chat message. Omission does not remove earlier attachments.

ReturnsExpand Collapse
class ThreadCreateMessageResponse:

Response payload for continuing a thread with a new message.

String responseId
String threadId
String userMessageId
long userMessageSeq

The seq the user message has in the thread’s message list. Always present. Use it to place the sent prompt among the listed messages before a list refresh includes it.

formatint64

Create Message

package com.clearstreet.api.example;

import com.clearstreet.api.client.ClearStreetClient;
import com.clearstreet.api.client.okhttp.ClearStreetOkHttpClient;
import com.clearstreet.api.models.v1.omniai.threads.ThreadCreateMessageParams;
import com.clearstreet.api.models.v1.omniai.threads.ThreadCreateMessageResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        ClearStreetClient client = ClearStreetOkHttpClient.builder()
            .fromEnv()
            .apiKey("My API Key")
            .build();

        ThreadCreateMessageParams params = ThreadCreateMessageParams.builder()
            .threadId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
            .text("Compare that to AMD.")
            .build();
        ThreadCreateMessageResponse response = client.v1().omniAi().threads().createMessage(params);
    }
}
{
  "data": {
    "response_id": "019dbaec-8dd3-7fa3-89d0-5303609f125f",
    "thread_id": "019dbae9-73b3-7fe0-bd14-25fe57e91475",
    "user_message_id": "019dbaec-8dd4-7f91-bce2-3ec8fba79eb7",
    "user_message_seq": 3
  },
  "metadata": {
    "request_id": "48775400-61f4-4c6c-bc6d-8f4996c571c7"
  }
}
{
  "error": {
    "code": 400,
    "message": "account_id must be positive"
  },
  "metadata": {
    "request_id": "9fbd975d-be1e-4710-9004-1f54d0d4dfb6"
  }
}
{
  "error": {
    "code": 400,
    "message": "Failed to parse the request body as JSON: EOF while parsing an object at line 3 column 0"
  },
  "metadata": {
    "request_id": "8cf61bb3-a8c6-4f3e-abe8-5a5327001b55"
  }
}
Returns Examples
{
  "data": {
    "response_id": "019dbaec-8dd3-7fa3-89d0-5303609f125f",
    "thread_id": "019dbae9-73b3-7fe0-bd14-25fe57e91475",
    "user_message_id": "019dbaec-8dd4-7f91-bce2-3ec8fba79eb7",
    "user_message_seq": 3
  },
  "metadata": {
    "request_id": "48775400-61f4-4c6c-bc6d-8f4996c571c7"
  }
}
{
  "error": {
    "code": 400,
    "message": "account_id must be positive"
  },
  "metadata": {
    "request_id": "9fbd975d-be1e-4710-9004-1f54d0d4dfb6"
  }
}
{
  "error": {
    "code": 400,
    "message": "Failed to parse the request body as JSON: EOF while parsing an object at line 3 column 0"
  },
  "metadata": {
    "request_id": "8cf61bb3-a8c6-4f3e-abe8-5a5327001b55"
  }
}