POST
/
v2
/
threads
/
{threadId}
/
messages
curl --request POST \
  --url https://api.langtail.com/v2/threads/{threadId}/messages \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <x-api-key>' \
  --data '{
  "message": {
    "role": "assistant",
    "name": "<string>",
    "content": "<string>",
    "function_call": {
      "name": "<string>",
      "arguments": "<string>"
    },
    "tool_calls": [
      {
        "id": "<string>",
        "type": "function",
        "function": {
          "name": "<string>",
          "arguments": "<string>"
        }
      }
    ],
    "tool_choice": "auto",
    "tool_call_id": "<string>"
  },
  "metadata": {
    "user_id": "user_123",
    "conversation_topic": "product_inquiry",
    "priority": "high"
  }
}'
{
  "id": "<string>",
  "createdAt": "2023-11-07T05:31:56Z",
  "threadId": "<string>",
  "content": [
    {
      "role": "user",
      "content": "Hello"
    }
  ],
  "metadata": {},
  "requestLog": {
    "id": "<string>",
    "createdAt": "2023-11-07T05:31:56Z",
    "request": {},
    "response": {}
  },
  "requestLogId": "<string>"
}

Use this endpoint to add a message to a thread without calling the LLM.

In most cases, you should use the Invoke Assistant API to add messages and get a response from the LLM. However, this endpoint is useful when you need to add messages without immediate LLM processing, such as for creating placeholder messages or updating thread content separately.

Headers

X-API-Key
string
required

Your Langtail API Key

Example:

"<LANGTAIL_API_KEY>"

Path Parameters

threadId
string
required

The ID of the thread.

Body

application/json

Response

200
application/json
Successful response

The response is of type object.