Agent Chat Completions
Chat with your agents using an OpenAI-compatible API.
Required scope: agents-all or agents-use
Basic Request
curl -X POST https://api.bluenexus.ai/api/v1/agents/AGENT_ID/chat/completions \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "What meetings do I have today?"}
]
}'
Use default as the agent ID to use the account's default agent:
curl -X POST https://api.bluenexus.ai/api/v1/agents/default/chat/completions \
...
Response
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1713000000,
"model": "bluenexus/glm-4.7-flash-tee",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Here are your meetings for today:\n\n1. Team Standup - 9:00 AM\n2. Product Review - 2:00 PM"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 150,
"completion_tokens": 45,
"total_tokens": 195
}
}
Response Headers
| Header | Description |
|---|---|
X-Credits-Consumed |
Credits used for this request |
X-Credits-Remaining |
Remaining credit balance |
X-Conversation-Id |
Conversation ID for multi-turn chat |
Streaming
Enable SSE streaming for real-time responses:
curl -X POST https://api.bluenexus.ai/api/v1/agents/AGENT_ID/chat/completions \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "Summarize my Slack messages"}
],
"stream": true
}'
Response (Server-Sent Events):
data: {"choices":[{"delta":{"role":"assistant"}}]}
data: {"choices":[{"delta":{"content":"Here"}}]}
data: {"choices":[{"delta":{"content":" are"}}]}
data: {"choices":[{"delta":{"content":" your"}}]}
data: [DONE]
Multi-Turn Conversations
Use the conversationId to maintain context across messages:
# First message
curl -X POST https://api.bluenexus.ai/api/v1/agents/AGENT_ID/chat/completions \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "What Jira tickets are assigned to me?"}
]
}'
# Response header: X-Conversation-Id: conv-xyz
# Follow-up (same conversation)
curl -X POST https://api.bluenexus.ai/api/v1/agents/AGENT_ID/chat/completions \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "Close the first one"}
],
"conversationId": "conv-xyz"
}'
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
messages |
array | Yes | Conversation messages (role + content) |
stream |
boolean | No | Enable SSE streaming (default: false) |
temperature |
number | No | Override agent's temperature |
max_tokens |
number | No | Max response tokens |
conversationId |
string | No | Continue a multi-turn conversation |
Rate Limit
30 requests per minute per account. Returns 429 Too Many Requests if exceeded.
Next Steps
- Creating Agents — Set up agents
- Deploying Agents — Deploy to messaging platforms
- LLM Access — Direct LLM API without agents