---
title: "Generate AI assistant spec from a prompt."
method: POST
path: "/ai_assistants/generate_spec"
tags: ["AI Assistants"]
---

# Generate AI assistant spec from a prompt.

`POST /ai_assistants/generate_spec`

## Request

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

Uses an LLM with guided JSON to generate one or more AI assistant configurations
from a natural language description. The returned specs map to every field in the
create-assistant UI and can be used directly with the create_ai_assistant endpoint.

## Request body

- object
  - `prompt` string, required: Natural language description of the desired assistant(s).
  - `llm` string: Optional LLM model override for generation.
  - `count` integer: Number of assistant configurations to generate (default 1).

## Response `200`

Generated assistant configurations.

- object
  - `assistants` AiAssistantSpec[]
    - `name` string, required
    - `description` string, required
    - `system_prompt` string, required
    - `llm` string
    - `history_management` 'compactification' | 'truncation' | 'semantic_retrieval'
    - `history_max_chars` integer
    - `history_recent_chars` integer
    - `history_retrieval_chars` integer
    - `notification_email` string
    - `allowed_tool_actions` string[]
    - `allowed_trigger_types` string[]
    - `default_wake_period` integer
    - `auto_memory_block` boolean
    - `auto_start` boolean: Whether to auto-start the assistant after creation. Only true when user explicitly asks for it to be started/run/launched.
  - `passed` boolean: Whether the user prompt was minimally sufficient to create the assistant. Callers MUST NOT create any assistants when passed is false; only show `response` to the user.
  - `dialog` 'none' | 'text' | 'ui': Confirmation strategy the caller should use before creating the assistant. - "none": user gave everything needed; create directly and show `response`. - "text": confirm in chat with the user before creating. - "ui": open the full create-assistant dialog pre-filled from the spec. Always "text" when passed=false.
  - `response` string: When passed=false, a clarifying question describing what info is missing. When passed=true, a human-language message keyed to `dialog`. May include the literal tokens `{artifact_url}` and `{artifact_name}` which the caller substitutes after creation.
  - `llm_used` string: The actual model that generated the specs (populated when llm=auto).

## 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)
