Skip to main content

Calling with cURL

Use cURL to quickly test Agent interfaces.

Prerequisites

  • Agent created
  • API Key obtained (create at CloudBase Console → Settings → API Keys)

Get Agent API Address

  1. Go to CloudBase Console
  2. Select "AI Agent" → Select the corresponding Agent
  3. View the "API Address" in the Agent details page

API address format:

https://{envId}.api.tcloudbasegateway.com/v1/aibot/bots/{agentId}/send-message

Send Message

curl 'https://{envId}.api.tcloudbasegateway.com/v1/aibot/bots/{agentId}/send-message' \
-H 'Authorization: Bearer <YOUR_API_KEY>' \
-H 'Accept: text/event-stream' \
-H 'Content-Type: application/json' \
--data-raw '{
"threadId": "thread-001",
"runId": "run-001",
"messages": [
{ "id": "msg-1", "role": "user", "content": "Hello" }
],
"tools": [],
"context": [],
"state": {}
}'

Response Example

data: {"type":"RUN_STARTED","threadId":"thread-xxx","runId":"run-xxx"}

data: {"type":"TEXT_MESSAGE_START","messageId":"msg-1"}

data: {"type":"TEXT_MESSAGE_CONTENT","messageId":"msg-1","delta":"Hello"}

data: {"type":"TEXT_MESSAGE_CONTENT","messageId":"msg-1","delta":"!"}

data: {"type":"TEXT_MESSAGE_END","messageId":"msg-1"}

data: {"type":"RUN_FINISHED"}

Request Parameters

ParameterTypeRequiredDescription
threadIdstringNoSession ID for multi-turn conversations
runIdstringNoRun ID
messagesarrayYesMessage list containing id, role, content
toolsarrayNoClient tools list
contextarrayNoContext information
stateobjectNoCustom state data