Skip to main content

Overview

The AI Chat API powers the conversational builder experience. It uses Server-Sent Events (SSE) for streaming responses.

Send Message

POST
/builder/ai/chat
Send a message to the AI assistant and receive a streaming response.
Request Body
{
  "projectId": "project_abc123",
  "messages": [
    {
      "role": "user",
      "content": "Create a landing page with a hero section"
    }
  ],
  "model": "hiveku-max",
  "mode": "coder"
}
Parameters
ParameterTypeRequiredDescription
projectIdstringYesThe project context
messagesarrayYesConversation history
modelstringNoModel tier: hiveku-mini, hiveku-max, hiveku-ultra (defaults to user’s selected model)
modestringNoAI mode: code, ask, architect, debug, design, test, security, refactor
Response (SSE Stream) The response is a Server-Sent Events stream:
data: {"type": "text", "content": "I'll create a landing page..."}

data: {"type": "tool_call", "name": "createFile", "args": {"path": "src/app/page.tsx"}}

data: {"type": "tool_result", "content": "File created successfully"}

data: {"type": "text", "content": "I've created the landing page with a hero section."}

data: [DONE]

Stream Event Types

TypeDescription
textAI text response chunk
tool_callAI is calling a tool (file edit, deploy, etc.)
tool_resultResult of a tool execution
reasoningAI reasoning/thinking (when supported by model)
errorError message
[DONE]Stream complete

Get Chat History

GET
/marketing/ai/chat/history/{sessionId}
Retrieve the chat history for a session.
Path Parameters
ParameterTypeDescription
sessionIdstringThe chat session ID

AI Usage

GET
/ai/usage/user/{userId}
Get AI token usage for a specific user.
Path Parameters
ParameterTypeDescription
userIdstringThe user’s ID
Response
{
  "totalTokens": 1250000,
  "inputTokens": 450000,
  "outputTokens": 800000,
  "periodStart": "2025-04-01T00:00:00Z",
  "periodEnd": "2025-04-30T23:59:59Z"
}