---
title: "创建租户"
method: POST
path: "/tenants"
tags: ["租户管理"]
---

# 创建租户

`POST /tenants`

创建新的租户

## Request body

- GithubComTencentWeKnoraInternalTypesTenant
  - `agent_config` GithubComTencentWeKnoraInternalTypesAgentConfig
    - `allowed_tools` string[] — List of allowed tool names
    - `knowledge_bases` string[] — Accessible knowledge base IDs
    - `knowledge_ids` string[] — Accessible knowledge IDs (individual documents)
    - `max_iterations` integer — Maximum number of ReAct iterations
    - `reflection_enabled` boolean — Whether to enable reflection
    - `system_prompt_web_disabled` string — Custom prompt when web search is disabled
    - `system_prompt_web_enabled` string — Custom prompt when web search is enabled
    - `temperature` number — LLM temperature for agent
    - `use_custom_system_prompt` boolean — Whether to use custom system prompt instead of default
    - `web_search_enabled` boolean — Whether web search tool is enabled
    - `web_search_max_results` integer — Maximum number of web search results (default: 5)
  - `api_key` string — API key
  - `business` string — Business
  - `context_config` GithubComTencentWeKnoraInternalTypesContextConfig
    - `compression_strategy` 'sliding_window' | 'smart'
    - `max_tokens` integer — Maximum tokens allowed in LLM context
    - `recent_message_count` integer — For sliding_window: number of messages to keep For smart: number of recent messages to keep uncompressed
    - `summarize_threshold` integer — Summarize threshold: number of messages before summarization
  - `conversation_config` GithubComTencentWeKnoraInternalTypesConversationConfig
    - `context_template` string — ContextTemplate is the prompt template for summarizing retrieval results
    - `embedding_top_k` integer
    - `enable_query_expansion` boolean
    - `enable_rewrite` boolean
    - `fallback_prompt` string
    - `fallback_response` string
    - `fallback_strategy` string — Fallback strategy
    - `keyword_threshold` number
    - `max_completion_tokens` integer — MaxTokens is the maximum number of tokens to generate
    - `max_rounds` integer — Retrieval & strategy parameters
    - `prompt` string
    - `rerank_model_id` string
    - `rerank_threshold` number
    - `rerank_top_k` integer
    - `rewrite_prompt_system` string — Rewrite prompts
    - `rewrite_prompt_user` string
    - `summary_model_id` string — Model configuration
    - `temperature` number — Temperature controls the randomness of the model output
    - `use_custom_context_template` boolean
    - `use_custom_system_prompt` boolean — Prompt is the system prompt for normal mode
    - `vector_threshold` number
  - `created_at` string — Creation time
  - `deleted_at` GormDeletedAt
    - `time` string
    - `valid` boolean — Valid is true if Time is not NULL
  - `description` string — Description
  - `id` integer — ID
  - `name` string — Name
  - `retriever_engines` GithubComTencentWeKnoraInternalTypesRetrieverEngines
    - `engines` GithubComTencentWeKnoraInternalTypesRetrieverEngineParams[]
      - `retriever_engine_type` 'postgres' | 'elasticsearch' | 'infinity' | 'elasticfaiss' | 'qdrant'
      - `retriever_type` 'keywords' | 'vector' | 'websearch'
  - `status` string — Status
  - `storage_quota` integer — Storage quota (Bytes), default is 10GB, including vector, original file, text, index, etc.
  - `storage_used` integer — Storage used (Bytes)
  - `updated_at` string — Last updated time
  - `web_search_config` GithubComTencentWeKnoraInternalTypesWebSearchConfig
    - `api_key` string — API密钥（如果需要）
    - `blacklist` string[] — 黑名单规则列表
    - `compression_method` string — 压缩方法：none, summary, extract, rag
    - `document_fragments` integer — 文档片段数量（用于RAG压缩）
    - `embedding_dimension` integer — 嵌入维度（用于RAG压缩）
    - `embedding_model_id` string — RAG压缩相关配置
    - `include_date` boolean — 是否包含日期
    - `max_results` integer — 最大搜索结果数
    - `provider` string — 搜索引擎提供商ID
    - `rerank_model_id` string — 重排模型ID（用于RAG压缩）

## Response `201`

创建的租户

- object

## Other responses

- `400` — 请求参数错误

## Changes

- **2025-12-16** `edf61e68559d` — 2 info
  - api tag `租户管理` added
  - api tag `空间管理` removed

[Change history](https://skmtc.dev/tencentblueking/apis/weknora-api/changes/tenants/post.md)

---

[API](https://skmtc.dev/tencentblueking/apis/weknora-api.md) · [All operations](https://skmtc.dev/tencentblueking/apis/weknora-api/llms.txt) · [OpenAPI document](https://skmtc.dev/tencentblueking/apis/weknora-api/revisions/a7ea016b0504?raw)
