Agents API

Create, manage, and chat with AI agents.

Base URL: https://api.bluenexus.ai/api/v1/agents

POST /agents

Create a new agent.

Auth: Bearer token with agents-all scope

{
  "name": "Support Agent",
  "llm": "bluenexus/glm-4.7-flash-tee",
  "personality": "You are a helpful support agent.",
  "description": "Handles support queries",
  "temperature": 0.7,
  "firstPrompt": "Hello! How can I help?",
  "enabledBuiltInTools": ["provider-tools", "skills"],
  "billingAccountType": "owner",
  "usageLimits": {
    "dailyMessagesPerUser": 100,
    "monthlyCreditsCap": 5000,
    "limitReachedMessage": "Limit reached."
  }
}

Response (201): Full agent object with id, accountId, timestamps.


GET /agents

List agents.

Auth: Bearer token with agents-all or agents-use scope

Query Parameters: page, limit, sortBy, sortOrder

Response (200): Paginated list of agents.


GET /agents/:agentId

Get an agent. Use default for the account's default agent.

Auth: Bearer token with agents-all or agents-use scope


PUT /agents/:agentId

Update an agent.

Auth: Bearer token with agents-all scope


DELETE /agents/:agentId

Delete an agent. If this was the default agent, it's cleared.

Auth: Bearer token with agents-all scope


POST /agents/:agentId/chat/completions

Chat with an agent. OpenAI-compatible format.

Auth: Bearer token with agents-all or agents-use scope Rate limit: 30 requests/minute Credit guard: Requires positive balance

{
  "messages": [
    {"role": "user", "content": "What's on my calendar today?"}
  ],
  "stream": false,
  "temperature": 0.7,
  "max_tokens": 1000,
  "conversationId": "conv-xyz"
}

Response (200):

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1713000000,
  "model": "bluenexus/glm-4.7-flash-tee",
  "choices": [
    {
      "index": 0,
      "message": {"role": "assistant", "content": "..."},
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 150,
    "completion_tokens": 45,
    "total_tokens": 195
  }
}

Response Headers:

  • X-Credits-Consumed — Credits used
  • X-Credits-Remaining — Balance remaining
  • X-Conversation-Id — Conversation ID for follow-up messages

Streaming (stream: true): Returns Server-Sent Events with delta objects and a final [DONE] event.