zudo-doc

Type to search...

to open search from anywhere

AI Assistant API

作成2026年3月22日Takeshi Takatsudo
このページはまだ翻訳されていません。原文のまま表示しています。

API specification for the AI assistant chat endpoint.

Endpoint

POST /api/ai-chat
Content-Type: application/json

Request Body

interface AiChatRequest {
  message: string;
  history: ChatMessage[];
}

interface ChatMessage {
  role: "user" | "assistant";
  content: string;
}
FieldTypeRequiredDescription
messagestringYesThe user’s current message. Must be non-empty.
historyChatMessage[]YesPrevious conversation messages. Invalid entries are filtered out silently.

Success Response (200)

interface AiChatResponse {
  response: string;
}

The response field contains the assistant’s reply as a markdown string.

Example:

// Request
{
  "message": "How do I add a new page?",
  "history": []
}

// Response
{
  "response": "Create an MDX file in `src/content/docs/`:\n\n1. Add frontmatter with `title`\n2. Write your content in MDX\n3. The page appears in the sidebar automatically"
}

Error Response (400 / 500)

interface AiChatErrorResponse {
  error: string;
}
StatusCondition
400Invalid JSON body
400message is not a non-empty string
400history is not an array
500AI_CHAT_MODE is not set to "local" or "remote"
500Claude CLI or Anthropic API call failed

Environment Variables

VariableRequiredDescription
AI_CHAT_MODEYes"local" or "remote"
ANTHROPIC_API_KEYRemote mode onlyAnthropic API key
PUBLIC_ENABLE_MOCKSNoSet to "true" to enable MSW mock responses (dev mode only, ignored in production)

Backend Modes

Local Mode (AI_CHAT_MODE=local)

Spawns claude -p --model haiku as a subprocess. Documentation context is piped via stdin. 60-second timeout.

Remote Mode (AI_CHAT_MODE=remote)

Calls the Anthropic Messages API with claude-haiku-4-5-20251001. Documentation content is included in the system prompt.

Documentation Context

The endpoint loads llms-full.txt (generated by the llms.txt integration) as context. The file is loaded once and cached in memory.

Revision History

AI Assistant

Ask a question about the documentation.