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
- Go to CloudBase Console
- Select "AI Agent" → Select the corresponding Agent
- 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
| Parameter | Type | Required | Description |
|---|---|---|---|
threadId | string | No | Session ID for multi-turn conversations |
runId | string | No | Run ID |
messages | array | Yes | Message list containing id, role, content |
tools | array | No | Client tools list |
context | array | No | Context information |
state | object | No | Custom state data |