Chat via SSE
POST https://chat.agentweave.ai/api/v1/chat/agent/{agent_id}
Request
Path Parameters
agent_id: your agent id
Request Head
Authorization: AgentWeave User Access Token OR Api Key
Request Body
- content (REQUIRED): user input text.
- type (REQUIRED): "text" OR "media", select agent output type.
- id (OPTIONAL): uuidv4 that you generated to identify the input text.
- thread_id (OPTIONAL): a thread saves your previous messages, leave blank to start a new conversation, all subsequent messages related to this conversation must return the
thread_idfrom the previous response as is to maintain context consistency. Thethread_iduses the ULID format. - org_id (OPTIONAL): Specify the user's organization targeted for point deduction. Will be used in credit deduction. Leave blank if the user does not use organization credits.
- pay_account (OPTIONAL): REQUIRED when
org_idis provided. Accepts"Person"or"Org"to determine whether credits are deducted from the user or the organization. - file (OPTIONAL):
- file_url (OPTIONAL): to upload a file, you must provide
file_url, and thefile_urlmust be publicly accessible. See Upload File section to upload file to the agent. Uploading file does not cost credits.
- file_url (OPTIONAL): to upload a file, you must provide
Example Request Body
{
"content": "describe chatgpt",
"type": "text"
}
Response
- action: the event type. "send_message.delta" means a generated text segment, "send_message.completed" represents the generation is completed, and the content contains the full output. "send_message.heartbeat" indicates a heartbeat event, it does not include the message field.
- message:
- agent_id
- client_message_id: uuidv4 to identify the client's input text.
- content: agent output text.
- speech_content: {}.
- from: "assistant".
- id: uuidv4 that identifies the output text.
- thread_id: thread that this message belongs to, a thread saves your previous messages.
- timestamp: the millisecond timestamp when the output is generated.
- type: "text".
- user_id: agent_id.
- agent_id
- result:
- code: 201000 means success, other indicates an error.
- message: "Successfully." or error messages.
Example Response
data: {
action: "send_message.delta",
message: {
agent_id: "open_chat_openai_c533c890-c1f0-444c-9bab-15cbae364a92",
client_message_id: "d6be96fa-5a90-4c11-a661-d7ae96a368eb",
content: "the",
speech_content: {},
from: "assistant",
id: "a11cee33-68b8-4345-a658-c0736c94e8be",
thread_id: "01KATMZEAPX5201F9X5SBKKH6N",
timestamp: 1764031265272,
type: "text",
user_id: "open_chat_openai_c533c890-c1f0-444c-9bab-15cbae364a92"
},
agent_id: "open_chat_openai_c533c890-c1f0-444c-9bab-15cbae364a92",
result: {
code: 201000,
message: "Successfully."
}
}