---
title: "Create an AI assistant."
method: POST
path: "/ai_assistants"
tags: ["AI Assistants"]
---

# Create an AI assistant.

`POST /ai_assistants`

## Request

- Base URL: `https://h2ogpte.genai.h2o.ai/api/v1`
- URL: `https://h2ogpte.genai.h2o.ai/api/v1/ai_assistants`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/h2o/apis/h2ogpte-rest-api/docs/ai_assistants/post.ts> (a function with typed inputs; its response is checked against the schema)

Creates a new persistent AI assistant with wake/sleep lifecycle.

## Request body

- AiAssistantCreateRequest
  - `name` string, required
  - `description` string
  - `system_prompt` string
  - `llm` string, required
  - `llm_args` object
  - `custom_tool_definition` string
  - `mcp_servers` object[]
  - `credential_ids` string[]
  - `memory_block_id` string, uuid
  - `notification_email` string
  - `history_management` 'compactification' | 'truncation' | 'semantic_retrieval'
  - `history_max_chars` integer
  - `history_recent_chars` integer: Maximum characters of recent chat history kept uncompacted (default 10000)
  - `history_retrieval_chars` integer: Maximum characters retrieved from vector DB for semantic retrieval (default 100000)
  - `allowed_tool_actions` string[], nullable: List of allowed tool action names. NULL means all actions allowed (default). Empty array means no actions allowed.
  - `allowed_trigger_types` string[], nullable: List of allowed trigger types. NULL means all triggers allowed (default). Valid values: user_message, forum_post, forum_mention, scheduled_task, manual, webhook, custom_event, assistant_message, periodic, document_uploaded, document_processed, collection_updated, chat_completed, user_login, email_received, file_watch, approval_response.
  - `default_wake_period` integer, nullable: Default periodic wake interval in seconds. When set, the system automatically wakes the assistant at this interval with its name and description as context. Min 60 (1 min), max 86400 (24 hours). Default NULL (no periodic wake).

## Response `201`

Successful operation

- AiAssistant
  - `id` string, uuid
  - `name` string
  - `description` string
  - `system_prompt` string
  - `llm` string
  - `llm_args` object
  - `status` 'stopped' | 'running' | 'sleeping' | 'error'
  - `custom_tool_definition` string
  - `mcp_servers` object[]
  - `credential_ids` string[]
  - `memory_block_id` string, uuid
  - `notification_email` string
  - `history_management` 'compactification' | 'truncation' | 'semantic_retrieval'
  - `history_max_chars` integer
  - `history_recent_chars` integer
  - `history_retrieval_chars` integer
  - `allowed_tool_actions` string[], nullable: List of allowed tool action names. NULL means all actions allowed.
  - `allowed_trigger_types` string[], nullable: List of allowed trigger types. NULL means all triggers allowed.
  - `current_chat_session_id` string, uuid
  - `wake_count` integer
  - `last_wake_at` string, date-time
  - `last_sleep_at` string, date-time
  - `error_message` string
  - `user_id` string, uuid
  - `username` string
  - `created_at` string, date-time
  - `updated_at` string, date-time
  - `is_owner` boolean
  - `user_access_mode` string
  - `forum_count` integer

## Other responses

- `401`: Unauthorized - Invalid or missing API key
- `default`: Unexpected error

---

[API](https://skmtc.dev/h2o/apis/h2ogpte-rest-api.md) - [All operations](https://skmtc.dev/h2o/apis/h2ogpte-rest-api/llms.txt) - [OpenAPI document](https://skmtc.dev/h2o/apis/h2ogpte-rest-api/revisions/a82a117320f4?raw)
