# Namespaces ## List namespaces. `aisearch.namespaces.list(NamespaceListParams**kwargs) -> SyncV4PagePaginationArray[NamespaceListResponse]` **get** `/accounts/{account_id}/ai-search/namespaces` List namespaces. ### Parameters - `account_id: Optional[str]` - `page: Optional[int]` Page number (1-indexed). - `per_page: Optional[int]` Number of results per page. - `search: Optional[str]` Filter namespaces whose name or description contains this string (case-insensitive). ### Returns - `class NamespaceListResponse: …` - `created_at: datetime` - `name: str` - `description: Optional[str]` Optional description for the namespace. Max 256 characters. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.aisearch.namespaces.list( account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", ) page = page.result[0] print(page.created_at) ``` #### Response ```json { "result": [ { "created_at": "2019-12-27T18:11:19.117Z", "name": "production", "description": "Production environment" } ], "result_info": { "count": 0, "page": 0, "per_page": 0, "total_count": 0 }, "success": true } ``` ## Create namespace. `aisearch.namespaces.create(NamespaceCreateParams**kwargs) -> NamespaceCreateResponse` **post** `/accounts/{account_id}/ai-search/namespaces` Create a new namespace. ### Parameters - `account_id: Optional[str]` - `name: str` - `description: Optional[str]` Optional description for the namespace. Max 256 characters. ### Returns - `class NamespaceCreateResponse: …` - `created_at: datetime` - `name: str` - `description: Optional[str]` Optional description for the namespace. Max 256 characters. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) namespace = client.aisearch.namespaces.create( account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", name="name", ) print(namespace.created_at) ``` #### Response ```json { "result": { "created_at": "2019-12-27T18:11:19.117Z", "name": "production", "description": "Production environment" }, "success": true } ``` ## Read namespace. `aisearch.namespaces.read(strname, NamespaceReadParams**kwargs) -> NamespaceReadResponse` **get** `/accounts/{account_id}/ai-search/namespaces/{name}` Read namespace. ### Parameters - `account_id: Optional[str]` - `name: str` ### Returns - `class NamespaceReadResponse: …` - `created_at: datetime` - `name: str` - `description: Optional[str]` Optional description for the namespace. Max 256 characters. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.aisearch.namespaces.read( name="production", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", ) print(response.created_at) ``` #### Response ```json { "result": { "created_at": "2019-12-27T18:11:19.117Z", "name": "production", "description": "Production environment" }, "success": true } ``` ## Update namespace. `aisearch.namespaces.update(strname, NamespaceUpdateParams**kwargs) -> NamespaceUpdateResponse` **put** `/accounts/{account_id}/ai-search/namespaces/{name}` Update namespace. ### Parameters - `account_id: Optional[str]` - `name: str` - `description: Optional[str]` Optional description for the namespace. Max 256 characters. ### Returns - `class NamespaceUpdateResponse: …` - `created_at: datetime` - `name: str` - `description: Optional[str]` Optional description for the namespace. Max 256 characters. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) namespace = client.aisearch.namespaces.update( name="production", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", ) print(namespace.created_at) ``` #### Response ```json { "result": { "created_at": "2019-12-27T18:11:19.117Z", "name": "production", "description": "Production environment" }, "success": true } ``` ## Delete namespace. `aisearch.namespaces.delete(strname, NamespaceDeleteParams**kwargs) -> object` **delete** `/accounts/{account_id}/ai-search/namespaces/{name}` Delete namespace. ### Parameters - `account_id: Optional[str]` - `name: str` ### Returns - `object` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) namespace = client.aisearch.namespaces.delete( name="production", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", ) print(namespace) ``` #### Response ```json { "result": {}, "success": true } ``` ## Multi-Instance Search `aisearch.namespaces.search(strname, NamespaceSearchParams**kwargs) -> NamespaceSearchResponse` **post** `/accounts/{account_id}/ai-search/namespaces/{name}/search` Multi-Instance Search ### Parameters - `account_id: Optional[str]` - `name: str` - `aisearch_options: AISearchOptions` - `instance_ids: Sequence[str]` - `cache: Optional[AISearchOptionsCache]` - `cache_threshold: Optional[Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"]]` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `enabled: Optional[bool]` - `query_rewrite: Optional[AISearchOptionsQueryRewrite]` - `enabled: Optional[bool]` - `model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `rewrite_prompt: Optional[str]` - `reranking: Optional[AISearchOptionsReranking]` - `enabled: Optional[bool]` - `match_threshold: Optional[float]` - `model: Optional[Literal["@cf/baai/bge-reranker-base", ""]]` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval: Optional[AISearchOptionsRetrieval]` - `boost_by: Optional[Iterable[AISearchOptionsRetrievalBoostBy]]` Metadata fields to boost search results by. Overrides the instance-level boost_by config. Direction defaults to 'asc' for numeric/datetime fields, 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: str` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support asc/desc directions; text/boolean fields support exists/not_exists. - `direction: Optional[Literal["asc", "desc", "exists", "not_exists"]]` Boost direction. 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime fields, 'exists' for text/boolean fields. - `"asc"` - `"desc"` - `"exists"` - `"not_exists"` - `context_expansion: Optional[int]` - `filters: Optional[Dict[str, object]]` - `fusion_method: Optional[Literal["max", "rrf"]]` - `"max"` - `"rrf"` - `keyword_match_mode: Optional[Literal["and", "or"]]` Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. Defaults to 'and'. - `"and"` - `"or"` - `match_threshold: Optional[float]` - `max_num_results: Optional[int]` - `retrieval_type: Optional[Literal["vector", "keyword", "hybrid"]]` - `"vector"` - `"keyword"` - `"hybrid"` - `return_on_failure: Optional[bool]` - `messages: Optional[Iterable[Message]]` - `content: Optional[str]` - `role: Literal["system", "developer", "user", 2 more]` - `"system"` - `"developer"` - `"user"` - `"assistant"` - `"tool"` - `query: Optional[str]` A simple text query string. Alternative to 'messages' — provide either this or 'messages', not both. ### Returns - `class NamespaceSearchResponse: …` - `chunks: List[Chunk]` - `id: str` - `instance_id: str` - `score: float` - `text: str` - `type: str` - `item: Optional[ChunkItem]` - `key: str` - `metadata: Optional[Dict[str, object]]` - `timestamp: Optional[float]` - `scoring_details: Optional[ChunkScoringDetails]` - `fusion_method: Optional[Literal["rrf", "max"]]` - `"rrf"` - `"max"` - `keyword_rank: Optional[float]` - `keyword_score: Optional[float]` - `reranking_score: Optional[float]` - `vector_rank: Optional[float]` - `vector_score: Optional[float]` - `search_query: str` - `errors: Optional[List[Error]]` - `instance_id: str` - `message: str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.aisearch.namespaces.search( name="my-namespace", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", aisearch_options={ "instance_ids": ["my-ai-search"] }, ) print(response.chunks) ``` #### Response ```json { "result": { "chunks": [ { "id": "id", "instance_id": "instance_id", "score": 0, "text": "text", "type": "type", "item": { "key": "key", "metadata": { "foo": "bar" }, "timestamp": 0 }, "scoring_details": { "fusion_method": "rrf", "keyword_rank": 0, "keyword_score": 0, "reranking_score": 0, "vector_rank": 0, "vector_score": 0 } } ], "search_query": "search_query", "errors": [ { "instance_id": "instance_id", "message": "message" } ] }, "success": true } ``` ## Multi-Instance Chat Completions `aisearch.namespaces.chat_completions(strname, NamespaceChatCompletionsParams**kwargs) -> NamespaceChatCompletionsResponse` **post** `/accounts/{account_id}/ai-search/namespaces/{name}/chat/completions` Performs a chat completion request against multiple AI Search instances in parallel, merging retrieved content as context for generating a response. ### Parameters - `account_id: Optional[str]` - `name: str` - `aisearch_options: AISearchOptions` - `instance_ids: Sequence[str]` - `cache: Optional[AISearchOptionsCache]` - `cache_threshold: Optional[Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"]]` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `enabled: Optional[bool]` - `query_rewrite: Optional[AISearchOptionsQueryRewrite]` - `enabled: Optional[bool]` - `model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `rewrite_prompt: Optional[str]` - `reranking: Optional[AISearchOptionsReranking]` - `enabled: Optional[bool]` - `match_threshold: Optional[float]` - `model: Optional[Literal["@cf/baai/bge-reranker-base", ""]]` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval: Optional[AISearchOptionsRetrieval]` - `boost_by: Optional[Iterable[AISearchOptionsRetrievalBoostBy]]` Metadata fields to boost search results by. Overrides the instance-level boost_by config. Direction defaults to 'asc' for numeric/datetime fields, 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: str` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support asc/desc directions; text/boolean fields support exists/not_exists. - `direction: Optional[Literal["asc", "desc", "exists", "not_exists"]]` Boost direction. 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime fields, 'exists' for text/boolean fields. - `"asc"` - `"desc"` - `"exists"` - `"not_exists"` - `context_expansion: Optional[int]` - `filters: Optional[Dict[str, object]]` - `fusion_method: Optional[Literal["max", "rrf"]]` - `"max"` - `"rrf"` - `keyword_match_mode: Optional[Literal["and", "or"]]` Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. Defaults to 'and'. - `"and"` - `"or"` - `match_threshold: Optional[float]` - `max_num_results: Optional[int]` - `retrieval_type: Optional[Literal["vector", "keyword", "hybrid"]]` - `"vector"` - `"keyword"` - `"hybrid"` - `return_on_failure: Optional[bool]` - `messages: Iterable[Message]` - `content: Optional[str]` - `role: Literal["system", "developer", "user", 2 more]` - `"system"` - `"developer"` - `"user"` - `"assistant"` - `"tool"` - `model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `stream: Optional[bool]` ### Returns - `class NamespaceChatCompletionsResponse: …` - `choices: List[Choice]` - `message: ChoiceMessage` - `content: Optional[str]` - `role: Literal["system", "developer", "user", 2 more]` - `"system"` - `"developer"` - `"user"` - `"assistant"` - `"tool"` - `index: Optional[int]` - `chunks: List[Chunk]` - `id: str` - `instance_id: str` - `score: float` - `text: str` - `type: str` - `item: Optional[ChunkItem]` - `key: str` - `metadata: Optional[Dict[str, object]]` - `timestamp: Optional[float]` - `scoring_details: Optional[ChunkScoringDetails]` - `fusion_method: Optional[Literal["rrf", "max"]]` - `"rrf"` - `"max"` - `keyword_rank: Optional[float]` - `keyword_score: Optional[float]` - `reranking_score: Optional[float]` - `vector_rank: Optional[float]` - `vector_score: Optional[float]` - `id: Optional[str]` - `errors: Optional[List[Error]]` - `instance_id: str` - `message: str` - `model: Optional[str]` - `object: Optional[str]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.aisearch.namespaces.chat_completions( name="my-namespace", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", aisearch_options={ "instance_ids": ["my-ai-search"] }, messages=[{ "content": "content", "role": "system", }], ) print(response.id) ``` #### Response ```json { "choices": [ { "message": { "content": "content", "role": "system" }, "index": 0 } ], "chunks": [ { "id": "id", "instance_id": "instance_id", "score": 0, "text": "text", "type": "type", "item": { "key": "key", "metadata": { "foo": "bar" }, "timestamp": 0 }, "scoring_details": { "fusion_method": "rrf", "keyword_rank": 0, "keyword_score": 0, "reranking_score": 0, "vector_rank": 0, "vector_score": 0 } } ], "id": "id", "errors": [ { "instance_id": "instance_id", "message": "message" } ], "model": "model", "object": "object" } ``` ## Domain Types ### Namespace List Response - `class NamespaceListResponse: …` - `created_at: datetime` - `name: str` - `description: Optional[str]` Optional description for the namespace. Max 256 characters. ### Namespace Create Response - `class NamespaceCreateResponse: …` - `created_at: datetime` - `name: str` - `description: Optional[str]` Optional description for the namespace. Max 256 characters. ### Namespace Read Response - `class NamespaceReadResponse: …` - `created_at: datetime` - `name: str` - `description: Optional[str]` Optional description for the namespace. Max 256 characters. ### Namespace Update Response - `class NamespaceUpdateResponse: …` - `created_at: datetime` - `name: str` - `description: Optional[str]` Optional description for the namespace. Max 256 characters. ### Namespace Search Response - `class NamespaceSearchResponse: …` - `chunks: List[Chunk]` - `id: str` - `instance_id: str` - `score: float` - `text: str` - `type: str` - `item: Optional[ChunkItem]` - `key: str` - `metadata: Optional[Dict[str, object]]` - `timestamp: Optional[float]` - `scoring_details: Optional[ChunkScoringDetails]` - `fusion_method: Optional[Literal["rrf", "max"]]` - `"rrf"` - `"max"` - `keyword_rank: Optional[float]` - `keyword_score: Optional[float]` - `reranking_score: Optional[float]` - `vector_rank: Optional[float]` - `vector_score: Optional[float]` - `search_query: str` - `errors: Optional[List[Error]]` - `instance_id: str` - `message: str` ### Namespace Chat Completions Response - `class NamespaceChatCompletionsResponse: …` - `choices: List[Choice]` - `message: ChoiceMessage` - `content: Optional[str]` - `role: Literal["system", "developer", "user", 2 more]` - `"system"` - `"developer"` - `"user"` - `"assistant"` - `"tool"` - `index: Optional[int]` - `chunks: List[Chunk]` - `id: str` - `instance_id: str` - `score: float` - `text: str` - `type: str` - `item: Optional[ChunkItem]` - `key: str` - `metadata: Optional[Dict[str, object]]` - `timestamp: Optional[float]` - `scoring_details: Optional[ChunkScoringDetails]` - `fusion_method: Optional[Literal["rrf", "max"]]` - `"rrf"` - `"max"` - `keyword_rank: Optional[float]` - `keyword_score: Optional[float]` - `reranking_score: Optional[float]` - `vector_rank: Optional[float]` - `vector_score: Optional[float]` - `id: Optional[str]` - `errors: Optional[List[Error]]` - `instance_id: str` - `message: str` - `model: Optional[str]` - `object: Optional[str]` # Instances ## List instances. `aisearch.namespaces.instances.list(strname, InstanceListParams**kwargs) -> SyncV4PagePaginationArray[InstanceListResponse]` **get** `/accounts/{account_id}/ai-search/namespaces/{name}/instances` List instances. ### Parameters - `account_id: Optional[str]` - `name: str` - `namespace: Optional[str]` - `order_by: Optional[Literal["created_at"]]` Order By Column Name - `"created_at"` - `order_by_direction: Optional[Literal["asc", "desc"]]` Order By Direction - `"asc"` - `"desc"` - `page: Optional[int]` - `per_page: Optional[int]` - `search: Optional[str]` Search by id ### Returns - `class InstanceListResponse: …` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: datetime` - `modified_at: datetime` - `ai_gateway_id: Optional[str]` - `aisearch_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `cache: Optional[bool]` - `cache_threshold: Optional[Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"]]` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `chunk_overlap: Optional[int]` - `chunk_size: Optional[int]` - `created_by: Optional[str]` - `custom_metadata: Optional[List[CustomMetadata]]` - `data_type: Literal["text", "number", "boolean", "datetime"]` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: str` - `embedding_model: Optional[Literal["@cf/qwen/qwen3-embedding-0.6b", "@cf/baai/bge-m3", "@cf/baai/bge-large-en-v1.5", 6 more]]` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/baai/bge-m3"` - `"@cf/baai/bge-large-en-v1.5"` - `"@cf/google/embeddinggemma-300m"` - `"google-ai-studio/gemini-embedding-001"` - `"google-ai-studio/gemini-embedding-2-preview"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable: Optional[bool]` - `engine_version: Optional[float]` - `fusion_method: Optional[Literal["max", "rrf"]]` - `"max"` - `"rrf"` - `hybrid_search_enabled: Optional[bool]` Deprecated — use index_method instead. - `index_method: Optional[IndexMethod]` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: bool` Enable keyword (BM25) storage backend. - `vector: bool` Enable vector (embedding) storage backend. - `indexing_options: Optional[IndexingOptions]` - `keyword_tokenizer: Optional[Literal["porter", "trigram"]]` Tokenizer used for keyword search indexing. porter provides word-level tokenization with Porter stemming (good for natural language queries). trigram enables character-level substring matching (good for partial matches, code, identifiers). Changing this triggers a full re-index. Defaults to porter. - `"porter"` - `"trigram"` - `last_activity: Optional[datetime]` - `max_num_results: Optional[int]` - `metadata: Optional[Metadata]` - `created_from_aisearch_wizard: Optional[bool]` - `search_for_agents: Optional[MetadataSearchForAgents]` - `hostname: str` - `zone_id: str` - `zone_name: str` - `worker_domain: Optional[str]` - `modified_by: Optional[str]` - `namespace: Optional[str]` - `paused: Optional[bool]` - `public_endpoint_id: Optional[str]` - `public_endpoint_params: Optional[PublicEndpointParams]` - `authorized_hosts: Optional[List[str]]` - `chat_completions_endpoint: Optional[PublicEndpointParamsChatCompletionsEndpoint]` - `disabled: Optional[bool]` Disable chat completions endpoint for this public endpoint - `enabled: Optional[bool]` - `mcp: Optional[PublicEndpointParamsMcp]` - `description: Optional[str]` - `disabled: Optional[bool]` Disable MCP endpoint for this public endpoint - `rate_limit: Optional[PublicEndpointParamsRateLimit]` - `period_ms: Optional[int]` - `requests: Optional[int]` - `technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `search_endpoint: Optional[PublicEndpointParamsSearchEndpoint]` - `disabled: Optional[bool]` Disable search endpoint for this public endpoint - `reranking: Optional[bool]` - `reranking_model: Optional[Literal["@cf/baai/bge-reranker-base", ""]]` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options: Optional[RetrievalOptions]` - `boost_by: Optional[List[RetrievalOptionsBoostBy]]` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: str` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support asc/desc directions; text/boolean fields support exists/not_exists. - `direction: Optional[Literal["asc", "desc", "exists", "not_exists"]]` Boost direction. 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime fields, 'exists' for text/boolean fields. - `"asc"` - `"desc"` - `"exists"` - `"not_exists"` - `keyword_match_mode: Optional[Literal["and", "or"]]` Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. Defaults to 'and'. - `"and"` - `"or"` - `rewrite_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `rewrite_query: Optional[bool]` - `score_threshold: Optional[float]` - `source: Optional[str]` - `source_params: Optional[SourceParams]` - `exclude_items: Optional[List[str]]` List of path patterns to exclude. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /admin/** matches /admin/users and /admin/settings/advanced) - `include_items: Optional[List[str]]` List of path patterns to include. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /blog/** matches /blog/post and /blog/2024/post) - `prefix: Optional[str]` - `r2_jurisdiction: Optional[str]` - `web_crawler: Optional[SourceParamsWebCrawler]` - `crawl_options: Optional[SourceParamsWebCrawlerCrawlOptions]` - `depth: Optional[float]` - `include_external_links: Optional[bool]` - `include_subdomains: Optional[bool]` - `max_age: Optional[float]` - `source: Optional[Literal["all", "sitemaps", "links"]]` - `"all"` - `"sitemaps"` - `"links"` - `parse_options: Optional[SourceParamsWebCrawlerParseOptions]` - `content_selector: Optional[List[SourceParamsWebCrawlerParseOptionsContentSelector]]` List of path-to-selector mappings for extracting specific content from crawled pages. Each entry pairs a URL glob pattern with a CSS selector. The first matching path wins. Only the matched HTML fragment is stored and indexed. - `path: str` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: str` CSS selector to extract content from pages matching the path pattern. Supports standard CSS selectors including class, ID, element, and attribute selectors. - `include_headers: Optional[Dict[str, str]]` - `include_images: Optional[bool]` - `specific_sitemaps: Optional[List[str]]` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering: Optional[bool]` - `parse_type: Optional[Literal["sitemap", "feed-rss", "crawl"]]` - `"sitemap"` - `"feed-rss"` - `"crawl"` - `store_options: Optional[SourceParamsWebCrawlerStoreOptions]` - `storage_id: str` - `r2_jurisdiction: Optional[str]` - `storage_type: Optional[Provider]` - `"r2"` - `status: Optional[str]` - `sync_interval: Optional[Literal[900, 1800, 3600, 5 more]]` Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). - `900` - `1800` - `3600` - `7200` - `14400` - `21600` - `43200` - `86400` - `token_id: Optional[str]` - `type: Optional[Literal["r2", "web-crawler"]]` - `"r2"` - `"web-crawler"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.aisearch.namespaces.instances.list( name="my-namespace", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", ) page = page.result[0] print(page.id) ``` #### Response ```json { "result": [ { "id": "my-ai-search", "created_at": "2019-12-27T18:11:19.117Z", "modified_at": "2019-12-27T18:11:19.117Z", "ai_gateway_id": "ai_gateway_id", "ai_search_model": "@cf/meta/llama-3.3-70b-instruct-fp8-fast", "cache": true, "cache_threshold": "super_strict_match", "chunk_overlap": 0, "chunk_size": 64, "created_by": "created_by", "custom_metadata": [ { "data_type": "text", "field_name": "x" } ], "embedding_model": "@cf/qwen/qwen3-embedding-0.6b", "enable": true, "engine_version": 0, "fusion_method": "max", "hybrid_search_enabled": true, "index_method": { "keyword": true, "vector": true }, "indexing_options": { "keyword_tokenizer": "porter" }, "last_activity": "2019-12-27T18:11:19.117Z", "max_num_results": 1, "metadata": { "created_from_aisearch_wizard": true, "search_for_agents": { "hostname": "hostname", "zone_id": "zone_id", "zone_name": "zone_name" }, "worker_domain": "worker_domain" }, "modified_by": "modified_by", "namespace": "namespace", "paused": true, "public_endpoint_id": "public_endpoint_id", "public_endpoint_params": { "authorized_hosts": [ "string" ], "chat_completions_endpoint": { "disabled": true }, "enabled": true, "mcp": { "description": "description", "disabled": true }, "rate_limit": { "period_ms": 60000, "requests": 1, "technique": "fixed" }, "search_endpoint": { "disabled": true } }, "reranking": true, "reranking_model": "@cf/baai/bge-reranker-base", "retrieval_options": { "boost_by": [ { "field": "timestamp", "direction": "desc" } ], "keyword_match_mode": "and" }, "rewrite_model": "@cf/meta/llama-3.3-70b-instruct-fp8-fast", "rewrite_query": true, "score_threshold": 0, "source": "source", "source_params": { "exclude_items": [ "/admin/**", "/private/**", "**\\temp\\**" ], "include_items": [ "/blog/**", "/docs/**/*.html", "**\\blog\\**.html" ], "prefix": "prefix", "r2_jurisdiction": "r2_jurisdiction", "web_crawler": { "crawl_options": { "depth": 1, "include_external_links": true, "include_subdomains": true, "max_age": 0, "source": "all" }, "parse_options": { "content_selector": [ { "path": "**/blog/**", "selector": "article .post-body" } ], "include_headers": { "foo": "string" }, "include_images": true, "specific_sitemaps": [ "https://example.com/sitemap.xml", "https://example.com/blog-sitemap.xml" ], "use_browser_rendering": true }, "parse_type": "sitemap", "store_options": { "storage_id": "storage_id", "r2_jurisdiction": "r2_jurisdiction", "storage_type": "r2" } } }, "status": "status", "sync_interval": 900, "token_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "type": "r2" } ], "success": true } ``` ## Create new instances. `aisearch.namespaces.instances.create(strname, InstanceCreateParams**kwargs) -> InstanceCreateResponse` **post** `/accounts/{account_id}/ai-search/namespaces/{name}/instances` Create a new instances. ### Parameters - `account_id: Optional[str]` - `name: str` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `ai_gateway_id: Optional[str]` - `aisearch_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `cache: Optional[bool]` - `cache_threshold: Optional[Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"]]` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `chunk: Optional[bool]` - `chunk_overlap: Optional[int]` - `chunk_size: Optional[int]` - `custom_metadata: Optional[Iterable[CustomMetadata]]` - `data_type: Literal["text", "number", "boolean", "datetime"]` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: str` - `embedding_model: Optional[Literal["@cf/qwen/qwen3-embedding-0.6b", "@cf/baai/bge-m3", "@cf/baai/bge-large-en-v1.5", 6 more]]` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/baai/bge-m3"` - `"@cf/baai/bge-large-en-v1.5"` - `"@cf/google/embeddinggemma-300m"` - `"google-ai-studio/gemini-embedding-001"` - `"google-ai-studio/gemini-embedding-2-preview"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `fusion_method: Optional[Literal["max", "rrf"]]` - `"max"` - `"rrf"` - `hybrid_search_enabled: Optional[bool]` Deprecated — use index_method instead. - `index_method: Optional[IndexMethod]` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: bool` Enable keyword (BM25) storage backend. - `vector: bool` Enable vector (embedding) storage backend. - `indexing_options: Optional[IndexingOptions]` - `keyword_tokenizer: Optional[Literal["porter", "trigram"]]` Tokenizer used for keyword search indexing. porter provides word-level tokenization with Porter stemming (good for natural language queries). trigram enables character-level substring matching (good for partial matches, code, identifiers). Changing this triggers a full re-index. Defaults to porter. - `"porter"` - `"trigram"` - `max_num_results: Optional[int]` - `metadata: Optional[Metadata]` - `created_from_aisearch_wizard: Optional[bool]` - `search_for_agents: Optional[MetadataSearchForAgents]` - `hostname: str` - `zone_id: str` - `zone_name: str` - `worker_domain: Optional[str]` - `public_endpoint_params: Optional[PublicEndpointParams]` - `authorized_hosts: Optional[Sequence[str]]` - `chat_completions_endpoint: Optional[PublicEndpointParamsChatCompletionsEndpoint]` - `disabled: Optional[bool]` Disable chat completions endpoint for this public endpoint - `enabled: Optional[bool]` - `mcp: Optional[PublicEndpointParamsMcp]` - `description: Optional[str]` - `disabled: Optional[bool]` Disable MCP endpoint for this public endpoint - `rate_limit: Optional[PublicEndpointParamsRateLimit]` - `period_ms: Optional[int]` - `requests: Optional[int]` - `technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `search_endpoint: Optional[PublicEndpointParamsSearchEndpoint]` - `disabled: Optional[bool]` Disable search endpoint for this public endpoint - `reranking: Optional[bool]` - `reranking_model: Optional[Literal["@cf/baai/bge-reranker-base", ""]]` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options: Optional[RetrievalOptions]` - `boost_by: Optional[Iterable[RetrievalOptionsBoostBy]]` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: str` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support asc/desc directions; text/boolean fields support exists/not_exists. - `direction: Optional[Literal["asc", "desc", "exists", "not_exists"]]` Boost direction. 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime fields, 'exists' for text/boolean fields. - `"asc"` - `"desc"` - `"exists"` - `"not_exists"` - `keyword_match_mode: Optional[Literal["and", "or"]]` Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. Defaults to 'and'. - `"and"` - `"or"` - `rewrite_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `rewrite_query: Optional[bool]` - `score_threshold: Optional[float]` - `source: Optional[str]` - `source_params: Optional[SourceParams]` - `exclude_items: Optional[Sequence[str]]` List of path patterns to exclude. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /admin/** matches /admin/users and /admin/settings/advanced) - `include_items: Optional[Sequence[str]]` List of path patterns to include. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /blog/** matches /blog/post and /blog/2024/post) - `prefix: Optional[str]` - `r2_jurisdiction: Optional[str]` - `web_crawler: Optional[SourceParamsWebCrawler]` - `crawl_options: Optional[SourceParamsWebCrawlerCrawlOptions]` - `depth: Optional[float]` - `include_external_links: Optional[bool]` - `include_subdomains: Optional[bool]` - `max_age: Optional[float]` - `source: Optional[Literal["all", "sitemaps", "links"]]` - `"all"` - `"sitemaps"` - `"links"` - `parse_options: Optional[SourceParamsWebCrawlerParseOptions]` - `content_selector: Optional[Iterable[SourceParamsWebCrawlerParseOptionsContentSelector]]` List of path-to-selector mappings for extracting specific content from crawled pages. Each entry pairs a URL glob pattern with a CSS selector. The first matching path wins. Only the matched HTML fragment is stored and indexed. - `path: str` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: str` CSS selector to extract content from pages matching the path pattern. Supports standard CSS selectors including class, ID, element, and attribute selectors. - `include_headers: Optional[Dict[str, str]]` - `include_images: Optional[bool]` - `specific_sitemaps: Optional[Sequence[str]]` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering: Optional[bool]` - `parse_type: Optional[Literal["sitemap", "feed-rss", "crawl"]]` - `"sitemap"` - `"feed-rss"` - `"crawl"` - `store_options: Optional[SourceParamsWebCrawlerStoreOptions]` - `storage_id: str` - `r2_jurisdiction: Optional[str]` - `storage_type: Optional[Provider]` - `"r2"` - `sync_interval: Optional[Literal[900, 1800, 3600, 5 more]]` Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). - `900` - `1800` - `3600` - `7200` - `14400` - `21600` - `43200` - `86400` - `token_id: Optional[str]` - `type: Optional[Literal["r2", "web-crawler"]]` - `"r2"` - `"web-crawler"` ### Returns - `class InstanceCreateResponse: …` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: datetime` - `modified_at: datetime` - `ai_gateway_id: Optional[str]` - `aisearch_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `cache: Optional[bool]` - `cache_threshold: Optional[Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"]]` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `chunk_overlap: Optional[int]` - `chunk_size: Optional[int]` - `created_by: Optional[str]` - `custom_metadata: Optional[List[CustomMetadata]]` - `data_type: Literal["text", "number", "boolean", "datetime"]` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: str` - `embedding_model: Optional[Literal["@cf/qwen/qwen3-embedding-0.6b", "@cf/baai/bge-m3", "@cf/baai/bge-large-en-v1.5", 6 more]]` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/baai/bge-m3"` - `"@cf/baai/bge-large-en-v1.5"` - `"@cf/google/embeddinggemma-300m"` - `"google-ai-studio/gemini-embedding-001"` - `"google-ai-studio/gemini-embedding-2-preview"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable: Optional[bool]` - `engine_version: Optional[float]` - `fusion_method: Optional[Literal["max", "rrf"]]` - `"max"` - `"rrf"` - `hybrid_search_enabled: Optional[bool]` Deprecated — use index_method instead. - `index_method: Optional[IndexMethod]` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: bool` Enable keyword (BM25) storage backend. - `vector: bool` Enable vector (embedding) storage backend. - `indexing_options: Optional[IndexingOptions]` - `keyword_tokenizer: Optional[Literal["porter", "trigram"]]` Tokenizer used for keyword search indexing. porter provides word-level tokenization with Porter stemming (good for natural language queries). trigram enables character-level substring matching (good for partial matches, code, identifiers). Changing this triggers a full re-index. Defaults to porter. - `"porter"` - `"trigram"` - `last_activity: Optional[datetime]` - `max_num_results: Optional[int]` - `metadata: Optional[Metadata]` - `created_from_aisearch_wizard: Optional[bool]` - `search_for_agents: Optional[MetadataSearchForAgents]` - `hostname: str` - `zone_id: str` - `zone_name: str` - `worker_domain: Optional[str]` - `modified_by: Optional[str]` - `namespace: Optional[str]` - `paused: Optional[bool]` - `public_endpoint_id: Optional[str]` - `public_endpoint_params: Optional[PublicEndpointParams]` - `authorized_hosts: Optional[List[str]]` - `chat_completions_endpoint: Optional[PublicEndpointParamsChatCompletionsEndpoint]` - `disabled: Optional[bool]` Disable chat completions endpoint for this public endpoint - `enabled: Optional[bool]` - `mcp: Optional[PublicEndpointParamsMcp]` - `description: Optional[str]` - `disabled: Optional[bool]` Disable MCP endpoint for this public endpoint - `rate_limit: Optional[PublicEndpointParamsRateLimit]` - `period_ms: Optional[int]` - `requests: Optional[int]` - `technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `search_endpoint: Optional[PublicEndpointParamsSearchEndpoint]` - `disabled: Optional[bool]` Disable search endpoint for this public endpoint - `reranking: Optional[bool]` - `reranking_model: Optional[Literal["@cf/baai/bge-reranker-base", ""]]` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options: Optional[RetrievalOptions]` - `boost_by: Optional[List[RetrievalOptionsBoostBy]]` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: str` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support asc/desc directions; text/boolean fields support exists/not_exists. - `direction: Optional[Literal["asc", "desc", "exists", "not_exists"]]` Boost direction. 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime fields, 'exists' for text/boolean fields. - `"asc"` - `"desc"` - `"exists"` - `"not_exists"` - `keyword_match_mode: Optional[Literal["and", "or"]]` Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. Defaults to 'and'. - `"and"` - `"or"` - `rewrite_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `rewrite_query: Optional[bool]` - `score_threshold: Optional[float]` - `source: Optional[str]` - `source_params: Optional[SourceParams]` - `exclude_items: Optional[List[str]]` List of path patterns to exclude. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /admin/** matches /admin/users and /admin/settings/advanced) - `include_items: Optional[List[str]]` List of path patterns to include. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /blog/** matches /blog/post and /blog/2024/post) - `prefix: Optional[str]` - `r2_jurisdiction: Optional[str]` - `web_crawler: Optional[SourceParamsWebCrawler]` - `crawl_options: Optional[SourceParamsWebCrawlerCrawlOptions]` - `depth: Optional[float]` - `include_external_links: Optional[bool]` - `include_subdomains: Optional[bool]` - `max_age: Optional[float]` - `source: Optional[Literal["all", "sitemaps", "links"]]` - `"all"` - `"sitemaps"` - `"links"` - `parse_options: Optional[SourceParamsWebCrawlerParseOptions]` - `content_selector: Optional[List[SourceParamsWebCrawlerParseOptionsContentSelector]]` List of path-to-selector mappings for extracting specific content from crawled pages. Each entry pairs a URL glob pattern with a CSS selector. The first matching path wins. Only the matched HTML fragment is stored and indexed. - `path: str` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: str` CSS selector to extract content from pages matching the path pattern. Supports standard CSS selectors including class, ID, element, and attribute selectors. - `include_headers: Optional[Dict[str, str]]` - `include_images: Optional[bool]` - `specific_sitemaps: Optional[List[str]]` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering: Optional[bool]` - `parse_type: Optional[Literal["sitemap", "feed-rss", "crawl"]]` - `"sitemap"` - `"feed-rss"` - `"crawl"` - `store_options: Optional[SourceParamsWebCrawlerStoreOptions]` - `storage_id: str` - `r2_jurisdiction: Optional[str]` - `storage_type: Optional[Provider]` - `"r2"` - `status: Optional[str]` - `sync_interval: Optional[Literal[900, 1800, 3600, 5 more]]` Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). - `900` - `1800` - `3600` - `7200` - `14400` - `21600` - `43200` - `86400` - `token_id: Optional[str]` - `type: Optional[Literal["r2", "web-crawler"]]` - `"r2"` - `"web-crawler"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) instance = client.aisearch.namespaces.instances.create( name="my-namespace", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", id="my-ai-search", ) print(instance.id) ``` #### Response ```json { "result": { "id": "my-ai-search", "created_at": "2019-12-27T18:11:19.117Z", "modified_at": "2019-12-27T18:11:19.117Z", "ai_gateway_id": "ai_gateway_id", "ai_search_model": "@cf/meta/llama-3.3-70b-instruct-fp8-fast", "cache": true, "cache_threshold": "super_strict_match", "chunk_overlap": 0, "chunk_size": 64, "created_by": "created_by", "custom_metadata": [ { "data_type": "text", "field_name": "x" } ], "embedding_model": "@cf/qwen/qwen3-embedding-0.6b", "enable": true, "engine_version": 0, "fusion_method": "max", "hybrid_search_enabled": true, "index_method": { "keyword": true, "vector": true }, "indexing_options": { "keyword_tokenizer": "porter" }, "last_activity": "2019-12-27T18:11:19.117Z", "max_num_results": 1, "metadata": { "created_from_aisearch_wizard": true, "search_for_agents": { "hostname": "hostname", "zone_id": "zone_id", "zone_name": "zone_name" }, "worker_domain": "worker_domain" }, "modified_by": "modified_by", "namespace": "namespace", "paused": true, "public_endpoint_id": "public_endpoint_id", "public_endpoint_params": { "authorized_hosts": [ "string" ], "chat_completions_endpoint": { "disabled": true }, "enabled": true, "mcp": { "description": "description", "disabled": true }, "rate_limit": { "period_ms": 60000, "requests": 1, "technique": "fixed" }, "search_endpoint": { "disabled": true } }, "reranking": true, "reranking_model": "@cf/baai/bge-reranker-base", "retrieval_options": { "boost_by": [ { "field": "timestamp", "direction": "desc" } ], "keyword_match_mode": "and" }, "rewrite_model": "@cf/meta/llama-3.3-70b-instruct-fp8-fast", "rewrite_query": true, "score_threshold": 0, "source": "source", "source_params": { "exclude_items": [ "/admin/**", "/private/**", "**\\temp\\**" ], "include_items": [ "/blog/**", "/docs/**/*.html", "**\\blog\\**.html" ], "prefix": "prefix", "r2_jurisdiction": "r2_jurisdiction", "web_crawler": { "crawl_options": { "depth": 1, "include_external_links": true, "include_subdomains": true, "max_age": 0, "source": "all" }, "parse_options": { "content_selector": [ { "path": "**/blog/**", "selector": "article .post-body" } ], "include_headers": { "foo": "string" }, "include_images": true, "specific_sitemaps": [ "https://example.com/sitemap.xml", "https://example.com/blog-sitemap.xml" ], "use_browser_rendering": true }, "parse_type": "sitemap", "store_options": { "storage_id": "storage_id", "r2_jurisdiction": "r2_jurisdiction", "storage_type": "r2" } } }, "status": "status", "sync_interval": 900, "token_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "type": "r2" }, "success": true } ``` ## Read instances. `aisearch.namespaces.instances.read(strid, InstanceReadParams**kwargs) -> InstanceReadResponse` **get** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}` Read instances. ### Parameters - `account_id: Optional[str]` - `name: str` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. ### Returns - `class InstanceReadResponse: …` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: datetime` - `modified_at: datetime` - `ai_gateway_id: Optional[str]` - `aisearch_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `cache: Optional[bool]` - `cache_threshold: Optional[Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"]]` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `chunk_overlap: Optional[int]` - `chunk_size: Optional[int]` - `created_by: Optional[str]` - `custom_metadata: Optional[List[CustomMetadata]]` - `data_type: Literal["text", "number", "boolean", "datetime"]` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: str` - `embedding_model: Optional[Literal["@cf/qwen/qwen3-embedding-0.6b", "@cf/baai/bge-m3", "@cf/baai/bge-large-en-v1.5", 6 more]]` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/baai/bge-m3"` - `"@cf/baai/bge-large-en-v1.5"` - `"@cf/google/embeddinggemma-300m"` - `"google-ai-studio/gemini-embedding-001"` - `"google-ai-studio/gemini-embedding-2-preview"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable: Optional[bool]` - `engine_version: Optional[float]` - `fusion_method: Optional[Literal["max", "rrf"]]` - `"max"` - `"rrf"` - `hybrid_search_enabled: Optional[bool]` Deprecated — use index_method instead. - `index_method: Optional[IndexMethod]` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: bool` Enable keyword (BM25) storage backend. - `vector: bool` Enable vector (embedding) storage backend. - `indexing_options: Optional[IndexingOptions]` - `keyword_tokenizer: Optional[Literal["porter", "trigram"]]` Tokenizer used for keyword search indexing. porter provides word-level tokenization with Porter stemming (good for natural language queries). trigram enables character-level substring matching (good for partial matches, code, identifiers). Changing this triggers a full re-index. Defaults to porter. - `"porter"` - `"trigram"` - `last_activity: Optional[datetime]` - `max_num_results: Optional[int]` - `metadata: Optional[Metadata]` - `created_from_aisearch_wizard: Optional[bool]` - `search_for_agents: Optional[MetadataSearchForAgents]` - `hostname: str` - `zone_id: str` - `zone_name: str` - `worker_domain: Optional[str]` - `modified_by: Optional[str]` - `namespace: Optional[str]` - `paused: Optional[bool]` - `public_endpoint_id: Optional[str]` - `public_endpoint_params: Optional[PublicEndpointParams]` - `authorized_hosts: Optional[List[str]]` - `chat_completions_endpoint: Optional[PublicEndpointParamsChatCompletionsEndpoint]` - `disabled: Optional[bool]` Disable chat completions endpoint for this public endpoint - `enabled: Optional[bool]` - `mcp: Optional[PublicEndpointParamsMcp]` - `description: Optional[str]` - `disabled: Optional[bool]` Disable MCP endpoint for this public endpoint - `rate_limit: Optional[PublicEndpointParamsRateLimit]` - `period_ms: Optional[int]` - `requests: Optional[int]` - `technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `search_endpoint: Optional[PublicEndpointParamsSearchEndpoint]` - `disabled: Optional[bool]` Disable search endpoint for this public endpoint - `reranking: Optional[bool]` - `reranking_model: Optional[Literal["@cf/baai/bge-reranker-base", ""]]` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options: Optional[RetrievalOptions]` - `boost_by: Optional[List[RetrievalOptionsBoostBy]]` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: str` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support asc/desc directions; text/boolean fields support exists/not_exists. - `direction: Optional[Literal["asc", "desc", "exists", "not_exists"]]` Boost direction. 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime fields, 'exists' for text/boolean fields. - `"asc"` - `"desc"` - `"exists"` - `"not_exists"` - `keyword_match_mode: Optional[Literal["and", "or"]]` Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. Defaults to 'and'. - `"and"` - `"or"` - `rewrite_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `rewrite_query: Optional[bool]` - `score_threshold: Optional[float]` - `source: Optional[str]` - `source_params: Optional[SourceParams]` - `exclude_items: Optional[List[str]]` List of path patterns to exclude. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /admin/** matches /admin/users and /admin/settings/advanced) - `include_items: Optional[List[str]]` List of path patterns to include. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /blog/** matches /blog/post and /blog/2024/post) - `prefix: Optional[str]` - `r2_jurisdiction: Optional[str]` - `web_crawler: Optional[SourceParamsWebCrawler]` - `crawl_options: Optional[SourceParamsWebCrawlerCrawlOptions]` - `depth: Optional[float]` - `include_external_links: Optional[bool]` - `include_subdomains: Optional[bool]` - `max_age: Optional[float]` - `source: Optional[Literal["all", "sitemaps", "links"]]` - `"all"` - `"sitemaps"` - `"links"` - `parse_options: Optional[SourceParamsWebCrawlerParseOptions]` - `content_selector: Optional[List[SourceParamsWebCrawlerParseOptionsContentSelector]]` List of path-to-selector mappings for extracting specific content from crawled pages. Each entry pairs a URL glob pattern with a CSS selector. The first matching path wins. Only the matched HTML fragment is stored and indexed. - `path: str` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: str` CSS selector to extract content from pages matching the path pattern. Supports standard CSS selectors including class, ID, element, and attribute selectors. - `include_headers: Optional[Dict[str, str]]` - `include_images: Optional[bool]` - `specific_sitemaps: Optional[List[str]]` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering: Optional[bool]` - `parse_type: Optional[Literal["sitemap", "feed-rss", "crawl"]]` - `"sitemap"` - `"feed-rss"` - `"crawl"` - `store_options: Optional[SourceParamsWebCrawlerStoreOptions]` - `storage_id: str` - `r2_jurisdiction: Optional[str]` - `storage_type: Optional[Provider]` - `"r2"` - `status: Optional[str]` - `sync_interval: Optional[Literal[900, 1800, 3600, 5 more]]` Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). - `900` - `1800` - `3600` - `7200` - `14400` - `21600` - `43200` - `86400` - `token_id: Optional[str]` - `type: Optional[Literal["r2", "web-crawler"]]` - `"r2"` - `"web-crawler"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.aisearch.namespaces.instances.read( id="my-ai-search", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", name="my-namespace", ) print(response.id) ``` #### Response ```json { "result": { "id": "my-ai-search", "created_at": "2019-12-27T18:11:19.117Z", "modified_at": "2019-12-27T18:11:19.117Z", "ai_gateway_id": "ai_gateway_id", "ai_search_model": "@cf/meta/llama-3.3-70b-instruct-fp8-fast", "cache": true, "cache_threshold": "super_strict_match", "chunk_overlap": 0, "chunk_size": 64, "created_by": "created_by", "custom_metadata": [ { "data_type": "text", "field_name": "x" } ], "embedding_model": "@cf/qwen/qwen3-embedding-0.6b", "enable": true, "engine_version": 0, "fusion_method": "max", "hybrid_search_enabled": true, "index_method": { "keyword": true, "vector": true }, "indexing_options": { "keyword_tokenizer": "porter" }, "last_activity": "2019-12-27T18:11:19.117Z", "max_num_results": 1, "metadata": { "created_from_aisearch_wizard": true, "search_for_agents": { "hostname": "hostname", "zone_id": "zone_id", "zone_name": "zone_name" }, "worker_domain": "worker_domain" }, "modified_by": "modified_by", "namespace": "namespace", "paused": true, "public_endpoint_id": "public_endpoint_id", "public_endpoint_params": { "authorized_hosts": [ "string" ], "chat_completions_endpoint": { "disabled": true }, "enabled": true, "mcp": { "description": "description", "disabled": true }, "rate_limit": { "period_ms": 60000, "requests": 1, "technique": "fixed" }, "search_endpoint": { "disabled": true } }, "reranking": true, "reranking_model": "@cf/baai/bge-reranker-base", "retrieval_options": { "boost_by": [ { "field": "timestamp", "direction": "desc" } ], "keyword_match_mode": "and" }, "rewrite_model": "@cf/meta/llama-3.3-70b-instruct-fp8-fast", "rewrite_query": true, "score_threshold": 0, "source": "source", "source_params": { "exclude_items": [ "/admin/**", "/private/**", "**\\temp\\**" ], "include_items": [ "/blog/**", "/docs/**/*.html", "**\\blog\\**.html" ], "prefix": "prefix", "r2_jurisdiction": "r2_jurisdiction", "web_crawler": { "crawl_options": { "depth": 1, "include_external_links": true, "include_subdomains": true, "max_age": 0, "source": "all" }, "parse_options": { "content_selector": [ { "path": "**/blog/**", "selector": "article .post-body" } ], "include_headers": { "foo": "string" }, "include_images": true, "specific_sitemaps": [ "https://example.com/sitemap.xml", "https://example.com/blog-sitemap.xml" ], "use_browser_rendering": true }, "parse_type": "sitemap", "store_options": { "storage_id": "storage_id", "r2_jurisdiction": "r2_jurisdiction", "storage_type": "r2" } } }, "status": "status", "sync_interval": 900, "token_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "type": "r2" }, "success": true } ``` ## Update instances. `aisearch.namespaces.instances.update(strid, InstanceUpdateParams**kwargs) -> InstanceUpdateResponse` **put** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}` Update instances. ### Parameters - `account_id: Optional[str]` - `name: str` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `ai_gateway_id: Optional[str]` - `aisearch_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `cache: Optional[bool]` - `cache_threshold: Optional[Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"]]` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `chunk: Optional[bool]` - `chunk_overlap: Optional[int]` - `chunk_size: Optional[int]` - `custom_metadata: Optional[Iterable[CustomMetadata]]` - `data_type: Literal["text", "number", "boolean", "datetime"]` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: str` - `embedding_model: Optional[Literal["@cf/qwen/qwen3-embedding-0.6b", "@cf/baai/bge-m3", "@cf/baai/bge-large-en-v1.5", 6 more]]` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/baai/bge-m3"` - `"@cf/baai/bge-large-en-v1.5"` - `"@cf/google/embeddinggemma-300m"` - `"google-ai-studio/gemini-embedding-001"` - `"google-ai-studio/gemini-embedding-2-preview"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `fusion_method: Optional[Literal["max", "rrf"]]` - `"max"` - `"rrf"` - `index_method: Optional[IndexMethod]` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: bool` Enable keyword (BM25) storage backend. - `vector: bool` Enable vector (embedding) storage backend. - `indexing_options: Optional[IndexingOptions]` - `keyword_tokenizer: Optional[Literal["porter", "trigram"]]` Tokenizer used for keyword search indexing. porter provides word-level tokenization with Porter stemming (good for natural language queries). trigram enables character-level substring matching (good for partial matches, code, identifiers). Changing this triggers a full re-index. Defaults to porter. - `"porter"` - `"trigram"` - `max_num_results: Optional[int]` - `metadata: Optional[Metadata]` - `created_from_aisearch_wizard: Optional[bool]` - `search_for_agents: Optional[MetadataSearchForAgents]` - `hostname: str` - `zone_id: str` - `zone_name: str` - `worker_domain: Optional[str]` - `paused: Optional[bool]` - `public_endpoint_params: Optional[PublicEndpointParams]` - `authorized_hosts: Optional[Sequence[str]]` - `chat_completions_endpoint: Optional[PublicEndpointParamsChatCompletionsEndpoint]` - `disabled: Optional[bool]` Disable chat completions endpoint for this public endpoint - `enabled: Optional[bool]` - `mcp: Optional[PublicEndpointParamsMcp]` - `description: Optional[str]` - `disabled: Optional[bool]` Disable MCP endpoint for this public endpoint - `rate_limit: Optional[PublicEndpointParamsRateLimit]` - `period_ms: Optional[int]` - `requests: Optional[int]` - `technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `search_endpoint: Optional[PublicEndpointParamsSearchEndpoint]` - `disabled: Optional[bool]` Disable search endpoint for this public endpoint - `reranking: Optional[bool]` - `reranking_model: Optional[Literal["@cf/baai/bge-reranker-base", ""]]` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options: Optional[RetrievalOptions]` - `boost_by: Optional[Iterable[RetrievalOptionsBoostBy]]` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: str` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support asc/desc directions; text/boolean fields support exists/not_exists. - `direction: Optional[Literal["asc", "desc", "exists", "not_exists"]]` Boost direction. 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime fields, 'exists' for text/boolean fields. - `"asc"` - `"desc"` - `"exists"` - `"not_exists"` - `keyword_match_mode: Optional[Literal["and", "or"]]` Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. Defaults to 'and'. - `"and"` - `"or"` - `rewrite_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `rewrite_query: Optional[bool]` - `score_threshold: Optional[float]` - `source_params: Optional[SourceParams]` - `exclude_items: Optional[Sequence[str]]` List of path patterns to exclude. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /admin/** matches /admin/users and /admin/settings/advanced) - `include_items: Optional[Sequence[str]]` List of path patterns to include. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /blog/** matches /blog/post and /blog/2024/post) - `prefix: Optional[str]` - `r2_jurisdiction: Optional[str]` - `web_crawler: Optional[SourceParamsWebCrawler]` - `crawl_options: Optional[SourceParamsWebCrawlerCrawlOptions]` - `depth: Optional[float]` - `include_external_links: Optional[bool]` - `include_subdomains: Optional[bool]` - `max_age: Optional[float]` - `source: Optional[Literal["all", "sitemaps", "links"]]` - `"all"` - `"sitemaps"` - `"links"` - `parse_options: Optional[SourceParamsWebCrawlerParseOptions]` - `content_selector: Optional[Iterable[SourceParamsWebCrawlerParseOptionsContentSelector]]` List of path-to-selector mappings for extracting specific content from crawled pages. Each entry pairs a URL glob pattern with a CSS selector. The first matching path wins. Only the matched HTML fragment is stored and indexed. - `path: str` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: str` CSS selector to extract content from pages matching the path pattern. Supports standard CSS selectors including class, ID, element, and attribute selectors. - `include_headers: Optional[Dict[str, str]]` - `include_images: Optional[bool]` - `specific_sitemaps: Optional[Sequence[str]]` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering: Optional[bool]` - `parse_type: Optional[Literal["sitemap", "feed-rss", "crawl"]]` - `"sitemap"` - `"feed-rss"` - `"crawl"` - `store_options: Optional[SourceParamsWebCrawlerStoreOptions]` - `storage_id: str` - `r2_jurisdiction: Optional[str]` - `storage_type: Optional[Provider]` - `"r2"` - `summarization: Optional[bool]` - `summarization_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `sync_interval: Optional[Literal[900, 1800, 3600, 5 more]]` Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). - `900` - `1800` - `3600` - `7200` - `14400` - `21600` - `43200` - `86400` - `system_prompt_aisearch: Optional[str]` - `system_prompt_index_summarization: Optional[str]` - `system_prompt_rewrite_query: Optional[str]` - `token_id: Optional[str]` ### Returns - `class InstanceUpdateResponse: …` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: datetime` - `modified_at: datetime` - `ai_gateway_id: Optional[str]` - `aisearch_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `cache: Optional[bool]` - `cache_threshold: Optional[Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"]]` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `chunk_overlap: Optional[int]` - `chunk_size: Optional[int]` - `created_by: Optional[str]` - `custom_metadata: Optional[List[CustomMetadata]]` - `data_type: Literal["text", "number", "boolean", "datetime"]` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: str` - `embedding_model: Optional[Literal["@cf/qwen/qwen3-embedding-0.6b", "@cf/baai/bge-m3", "@cf/baai/bge-large-en-v1.5", 6 more]]` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/baai/bge-m3"` - `"@cf/baai/bge-large-en-v1.5"` - `"@cf/google/embeddinggemma-300m"` - `"google-ai-studio/gemini-embedding-001"` - `"google-ai-studio/gemini-embedding-2-preview"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable: Optional[bool]` - `engine_version: Optional[float]` - `fusion_method: Optional[Literal["max", "rrf"]]` - `"max"` - `"rrf"` - `hybrid_search_enabled: Optional[bool]` Deprecated — use index_method instead. - `index_method: Optional[IndexMethod]` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: bool` Enable keyword (BM25) storage backend. - `vector: bool` Enable vector (embedding) storage backend. - `indexing_options: Optional[IndexingOptions]` - `keyword_tokenizer: Optional[Literal["porter", "trigram"]]` Tokenizer used for keyword search indexing. porter provides word-level tokenization with Porter stemming (good for natural language queries). trigram enables character-level substring matching (good for partial matches, code, identifiers). Changing this triggers a full re-index. Defaults to porter. - `"porter"` - `"trigram"` - `last_activity: Optional[datetime]` - `max_num_results: Optional[int]` - `metadata: Optional[Metadata]` - `created_from_aisearch_wizard: Optional[bool]` - `search_for_agents: Optional[MetadataSearchForAgents]` - `hostname: str` - `zone_id: str` - `zone_name: str` - `worker_domain: Optional[str]` - `modified_by: Optional[str]` - `namespace: Optional[str]` - `paused: Optional[bool]` - `public_endpoint_id: Optional[str]` - `public_endpoint_params: Optional[PublicEndpointParams]` - `authorized_hosts: Optional[List[str]]` - `chat_completions_endpoint: Optional[PublicEndpointParamsChatCompletionsEndpoint]` - `disabled: Optional[bool]` Disable chat completions endpoint for this public endpoint - `enabled: Optional[bool]` - `mcp: Optional[PublicEndpointParamsMcp]` - `description: Optional[str]` - `disabled: Optional[bool]` Disable MCP endpoint for this public endpoint - `rate_limit: Optional[PublicEndpointParamsRateLimit]` - `period_ms: Optional[int]` - `requests: Optional[int]` - `technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `search_endpoint: Optional[PublicEndpointParamsSearchEndpoint]` - `disabled: Optional[bool]` Disable search endpoint for this public endpoint - `reranking: Optional[bool]` - `reranking_model: Optional[Literal["@cf/baai/bge-reranker-base", ""]]` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options: Optional[RetrievalOptions]` - `boost_by: Optional[List[RetrievalOptionsBoostBy]]` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: str` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support asc/desc directions; text/boolean fields support exists/not_exists. - `direction: Optional[Literal["asc", "desc", "exists", "not_exists"]]` Boost direction. 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime fields, 'exists' for text/boolean fields. - `"asc"` - `"desc"` - `"exists"` - `"not_exists"` - `keyword_match_mode: Optional[Literal["and", "or"]]` Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. Defaults to 'and'. - `"and"` - `"or"` - `rewrite_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `rewrite_query: Optional[bool]` - `score_threshold: Optional[float]` - `source: Optional[str]` - `source_params: Optional[SourceParams]` - `exclude_items: Optional[List[str]]` List of path patterns to exclude. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /admin/** matches /admin/users and /admin/settings/advanced) - `include_items: Optional[List[str]]` List of path patterns to include. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /blog/** matches /blog/post and /blog/2024/post) - `prefix: Optional[str]` - `r2_jurisdiction: Optional[str]` - `web_crawler: Optional[SourceParamsWebCrawler]` - `crawl_options: Optional[SourceParamsWebCrawlerCrawlOptions]` - `depth: Optional[float]` - `include_external_links: Optional[bool]` - `include_subdomains: Optional[bool]` - `max_age: Optional[float]` - `source: Optional[Literal["all", "sitemaps", "links"]]` - `"all"` - `"sitemaps"` - `"links"` - `parse_options: Optional[SourceParamsWebCrawlerParseOptions]` - `content_selector: Optional[List[SourceParamsWebCrawlerParseOptionsContentSelector]]` List of path-to-selector mappings for extracting specific content from crawled pages. Each entry pairs a URL glob pattern with a CSS selector. The first matching path wins. Only the matched HTML fragment is stored and indexed. - `path: str` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: str` CSS selector to extract content from pages matching the path pattern. Supports standard CSS selectors including class, ID, element, and attribute selectors. - `include_headers: Optional[Dict[str, str]]` - `include_images: Optional[bool]` - `specific_sitemaps: Optional[List[str]]` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering: Optional[bool]` - `parse_type: Optional[Literal["sitemap", "feed-rss", "crawl"]]` - `"sitemap"` - `"feed-rss"` - `"crawl"` - `store_options: Optional[SourceParamsWebCrawlerStoreOptions]` - `storage_id: str` - `r2_jurisdiction: Optional[str]` - `storage_type: Optional[Provider]` - `"r2"` - `status: Optional[str]` - `sync_interval: Optional[Literal[900, 1800, 3600, 5 more]]` Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). - `900` - `1800` - `3600` - `7200` - `14400` - `21600` - `43200` - `86400` - `token_id: Optional[str]` - `type: Optional[Literal["r2", "web-crawler"]]` - `"r2"` - `"web-crawler"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) instance = client.aisearch.namespaces.instances.update( id="my-ai-search", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", name="my-namespace", ) print(instance.id) ``` #### Response ```json { "result": { "id": "my-ai-search", "created_at": "2019-12-27T18:11:19.117Z", "modified_at": "2019-12-27T18:11:19.117Z", "ai_gateway_id": "ai_gateway_id", "ai_search_model": "@cf/meta/llama-3.3-70b-instruct-fp8-fast", "cache": true, "cache_threshold": "super_strict_match", "chunk_overlap": 0, "chunk_size": 64, "created_by": "created_by", "custom_metadata": [ { "data_type": "text", "field_name": "x" } ], "embedding_model": "@cf/qwen/qwen3-embedding-0.6b", "enable": true, "engine_version": 0, "fusion_method": "max", "hybrid_search_enabled": true, "index_method": { "keyword": true, "vector": true }, "indexing_options": { "keyword_tokenizer": "porter" }, "last_activity": "2019-12-27T18:11:19.117Z", "max_num_results": 1, "metadata": { "created_from_aisearch_wizard": true, "search_for_agents": { "hostname": "hostname", "zone_id": "zone_id", "zone_name": "zone_name" }, "worker_domain": "worker_domain" }, "modified_by": "modified_by", "namespace": "namespace", "paused": true, "public_endpoint_id": "public_endpoint_id", "public_endpoint_params": { "authorized_hosts": [ "string" ], "chat_completions_endpoint": { "disabled": true }, "enabled": true, "mcp": { "description": "description", "disabled": true }, "rate_limit": { "period_ms": 60000, "requests": 1, "technique": "fixed" }, "search_endpoint": { "disabled": true } }, "reranking": true, "reranking_model": "@cf/baai/bge-reranker-base", "retrieval_options": { "boost_by": [ { "field": "timestamp", "direction": "desc" } ], "keyword_match_mode": "and" }, "rewrite_model": "@cf/meta/llama-3.3-70b-instruct-fp8-fast", "rewrite_query": true, "score_threshold": 0, "source": "source", "source_params": { "exclude_items": [ "/admin/**", "/private/**", "**\\temp\\**" ], "include_items": [ "/blog/**", "/docs/**/*.html", "**\\blog\\**.html" ], "prefix": "prefix", "r2_jurisdiction": "r2_jurisdiction", "web_crawler": { "crawl_options": { "depth": 1, "include_external_links": true, "include_subdomains": true, "max_age": 0, "source": "all" }, "parse_options": { "content_selector": [ { "path": "**/blog/**", "selector": "article .post-body" } ], "include_headers": { "foo": "string" }, "include_images": true, "specific_sitemaps": [ "https://example.com/sitemap.xml", "https://example.com/blog-sitemap.xml" ], "use_browser_rendering": true }, "parse_type": "sitemap", "store_options": { "storage_id": "storage_id", "r2_jurisdiction": "r2_jurisdiction", "storage_type": "r2" } } }, "status": "status", "sync_interval": 900, "token_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "type": "r2" }, "success": true } ``` ## Delete instances. `aisearch.namespaces.instances.delete(strid, InstanceDeleteParams**kwargs) -> InstanceDeleteResponse` **delete** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}` Delete instances. ### Parameters - `account_id: Optional[str]` - `name: str` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. ### Returns - `class InstanceDeleteResponse: …` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: datetime` - `modified_at: datetime` - `ai_gateway_id: Optional[str]` - `aisearch_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `cache: Optional[bool]` - `cache_threshold: Optional[Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"]]` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `chunk_overlap: Optional[int]` - `chunk_size: Optional[int]` - `created_by: Optional[str]` - `custom_metadata: Optional[List[CustomMetadata]]` - `data_type: Literal["text", "number", "boolean", "datetime"]` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: str` - `embedding_model: Optional[Literal["@cf/qwen/qwen3-embedding-0.6b", "@cf/baai/bge-m3", "@cf/baai/bge-large-en-v1.5", 6 more]]` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/baai/bge-m3"` - `"@cf/baai/bge-large-en-v1.5"` - `"@cf/google/embeddinggemma-300m"` - `"google-ai-studio/gemini-embedding-001"` - `"google-ai-studio/gemini-embedding-2-preview"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable: Optional[bool]` - `engine_version: Optional[float]` - `fusion_method: Optional[Literal["max", "rrf"]]` - `"max"` - `"rrf"` - `hybrid_search_enabled: Optional[bool]` Deprecated — use index_method instead. - `index_method: Optional[IndexMethod]` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: bool` Enable keyword (BM25) storage backend. - `vector: bool` Enable vector (embedding) storage backend. - `indexing_options: Optional[IndexingOptions]` - `keyword_tokenizer: Optional[Literal["porter", "trigram"]]` Tokenizer used for keyword search indexing. porter provides word-level tokenization with Porter stemming (good for natural language queries). trigram enables character-level substring matching (good for partial matches, code, identifiers). Changing this triggers a full re-index. Defaults to porter. - `"porter"` - `"trigram"` - `last_activity: Optional[datetime]` - `max_num_results: Optional[int]` - `metadata: Optional[Metadata]` - `created_from_aisearch_wizard: Optional[bool]` - `search_for_agents: Optional[MetadataSearchForAgents]` - `hostname: str` - `zone_id: str` - `zone_name: str` - `worker_domain: Optional[str]` - `modified_by: Optional[str]` - `namespace: Optional[str]` - `paused: Optional[bool]` - `public_endpoint_id: Optional[str]` - `public_endpoint_params: Optional[PublicEndpointParams]` - `authorized_hosts: Optional[List[str]]` - `chat_completions_endpoint: Optional[PublicEndpointParamsChatCompletionsEndpoint]` - `disabled: Optional[bool]` Disable chat completions endpoint for this public endpoint - `enabled: Optional[bool]` - `mcp: Optional[PublicEndpointParamsMcp]` - `description: Optional[str]` - `disabled: Optional[bool]` Disable MCP endpoint for this public endpoint - `rate_limit: Optional[PublicEndpointParamsRateLimit]` - `period_ms: Optional[int]` - `requests: Optional[int]` - `technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `search_endpoint: Optional[PublicEndpointParamsSearchEndpoint]` - `disabled: Optional[bool]` Disable search endpoint for this public endpoint - `reranking: Optional[bool]` - `reranking_model: Optional[Literal["@cf/baai/bge-reranker-base", ""]]` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options: Optional[RetrievalOptions]` - `boost_by: Optional[List[RetrievalOptionsBoostBy]]` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: str` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support asc/desc directions; text/boolean fields support exists/not_exists. - `direction: Optional[Literal["asc", "desc", "exists", "not_exists"]]` Boost direction. 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime fields, 'exists' for text/boolean fields. - `"asc"` - `"desc"` - `"exists"` - `"not_exists"` - `keyword_match_mode: Optional[Literal["and", "or"]]` Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. Defaults to 'and'. - `"and"` - `"or"` - `rewrite_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `rewrite_query: Optional[bool]` - `score_threshold: Optional[float]` - `source: Optional[str]` - `source_params: Optional[SourceParams]` - `exclude_items: Optional[List[str]]` List of path patterns to exclude. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /admin/** matches /admin/users and /admin/settings/advanced) - `include_items: Optional[List[str]]` List of path patterns to include. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /blog/** matches /blog/post and /blog/2024/post) - `prefix: Optional[str]` - `r2_jurisdiction: Optional[str]` - `web_crawler: Optional[SourceParamsWebCrawler]` - `crawl_options: Optional[SourceParamsWebCrawlerCrawlOptions]` - `depth: Optional[float]` - `include_external_links: Optional[bool]` - `include_subdomains: Optional[bool]` - `max_age: Optional[float]` - `source: Optional[Literal["all", "sitemaps", "links"]]` - `"all"` - `"sitemaps"` - `"links"` - `parse_options: Optional[SourceParamsWebCrawlerParseOptions]` - `content_selector: Optional[List[SourceParamsWebCrawlerParseOptionsContentSelector]]` List of path-to-selector mappings for extracting specific content from crawled pages. Each entry pairs a URL glob pattern with a CSS selector. The first matching path wins. Only the matched HTML fragment is stored and indexed. - `path: str` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: str` CSS selector to extract content from pages matching the path pattern. Supports standard CSS selectors including class, ID, element, and attribute selectors. - `include_headers: Optional[Dict[str, str]]` - `include_images: Optional[bool]` - `specific_sitemaps: Optional[List[str]]` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering: Optional[bool]` - `parse_type: Optional[Literal["sitemap", "feed-rss", "crawl"]]` - `"sitemap"` - `"feed-rss"` - `"crawl"` - `store_options: Optional[SourceParamsWebCrawlerStoreOptions]` - `storage_id: str` - `r2_jurisdiction: Optional[str]` - `storage_type: Optional[Provider]` - `"r2"` - `status: Optional[str]` - `sync_interval: Optional[Literal[900, 1800, 3600, 5 more]]` Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). - `900` - `1800` - `3600` - `7200` - `14400` - `21600` - `43200` - `86400` - `token_id: Optional[str]` - `type: Optional[Literal["r2", "web-crawler"]]` - `"r2"` - `"web-crawler"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) instance = client.aisearch.namespaces.instances.delete( id="my-ai-search", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", name="my-namespace", ) print(instance.id) ``` #### Response ```json { "result": { "id": "my-ai-search", "created_at": "2019-12-27T18:11:19.117Z", "modified_at": "2019-12-27T18:11:19.117Z", "ai_gateway_id": "ai_gateway_id", "ai_search_model": "@cf/meta/llama-3.3-70b-instruct-fp8-fast", "cache": true, "cache_threshold": "super_strict_match", "chunk_overlap": 0, "chunk_size": 64, "created_by": "created_by", "custom_metadata": [ { "data_type": "text", "field_name": "x" } ], "embedding_model": "@cf/qwen/qwen3-embedding-0.6b", "enable": true, "engine_version": 0, "fusion_method": "max", "hybrid_search_enabled": true, "index_method": { "keyword": true, "vector": true }, "indexing_options": { "keyword_tokenizer": "porter" }, "last_activity": "2019-12-27T18:11:19.117Z", "max_num_results": 1, "metadata": { "created_from_aisearch_wizard": true, "search_for_agents": { "hostname": "hostname", "zone_id": "zone_id", "zone_name": "zone_name" }, "worker_domain": "worker_domain" }, "modified_by": "modified_by", "namespace": "namespace", "paused": true, "public_endpoint_id": "public_endpoint_id", "public_endpoint_params": { "authorized_hosts": [ "string" ], "chat_completions_endpoint": { "disabled": true }, "enabled": true, "mcp": { "description": "description", "disabled": true }, "rate_limit": { "period_ms": 60000, "requests": 1, "technique": "fixed" }, "search_endpoint": { "disabled": true } }, "reranking": true, "reranking_model": "@cf/baai/bge-reranker-base", "retrieval_options": { "boost_by": [ { "field": "timestamp", "direction": "desc" } ], "keyword_match_mode": "and" }, "rewrite_model": "@cf/meta/llama-3.3-70b-instruct-fp8-fast", "rewrite_query": true, "score_threshold": 0, "source": "source", "source_params": { "exclude_items": [ "/admin/**", "/private/**", "**\\temp\\**" ], "include_items": [ "/blog/**", "/docs/**/*.html", "**\\blog\\**.html" ], "prefix": "prefix", "r2_jurisdiction": "r2_jurisdiction", "web_crawler": { "crawl_options": { "depth": 1, "include_external_links": true, "include_subdomains": true, "max_age": 0, "source": "all" }, "parse_options": { "content_selector": [ { "path": "**/blog/**", "selector": "article .post-body" } ], "include_headers": { "foo": "string" }, "include_images": true, "specific_sitemaps": [ "https://example.com/sitemap.xml", "https://example.com/blog-sitemap.xml" ], "use_browser_rendering": true }, "parse_type": "sitemap", "store_options": { "storage_id": "storage_id", "r2_jurisdiction": "r2_jurisdiction", "storage_type": "r2" } } }, "status": "status", "sync_interval": 900, "token_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "type": "r2" }, "success": true } ``` ## Stats `aisearch.namespaces.instances.stats(strid, InstanceStatsParams**kwargs) -> InstanceStatsResponse` **get** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/stats` Retrieves usage statistics for AI Search instances. ### Parameters - `account_id: Optional[str]` - `name: str` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. ### Returns - `class InstanceStatsResponse: …` - `completed: Optional[int]` - `engine: Optional[Engine]` Engine-specific metadata. Present only for managed (v3) instances. - `r2: Optional[EngineR2]` R2 bucket storage usage in bytes. - `metadata_size_bytes: int` - `object_count: int` - `payload_size_bytes: int` - `vectorize: Optional[EngineVectorize]` Vectorize index metadata (dimensions, vector count). - `dimensions: int` - `vectors_count: int` - `error: Optional[int]` - `file_embed_errors: Optional[Dict[str, object]]` - `index_source_errors: Optional[Dict[str, object]]` - `last_activity: Optional[datetime]` - `outdated: Optional[int]` - `queued: Optional[int]` - `running: Optional[int]` - `skipped: Optional[int]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.aisearch.namespaces.instances.stats( id="my-ai-search", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", name="my-namespace", ) print(response.completed) ``` #### Response ```json { "result": { "completed": 0, "engine": { "r2": { "metadataSizeBytes": 0, "objectCount": 0, "payloadSizeBytes": 0 }, "vectorize": { "dimensions": 0, "vectorsCount": 0 } }, "error": 0, "file_embed_errors": { "foo": "bar" }, "index_source_errors": { "foo": "bar" }, "last_activity": "2019-12-27T18:11:19.117Z", "outdated": 0, "queued": 0, "running": 0, "skipped": 0 }, "success": true } ``` ## Search `aisearch.namespaces.instances.search(strid, InstanceSearchParams**kwargs) -> InstanceSearchResponse` **post** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/search` Executes a semantic search query against an AI Search instance to find relevant indexed content. ### Parameters - `account_id: Optional[str]` - `name: str` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `aisearch_options: Optional[AISearchOptions]` - `cache: Optional[AISearchOptionsCache]` - `cache_threshold: Optional[Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"]]` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `enabled: Optional[bool]` - `query_rewrite: Optional[AISearchOptionsQueryRewrite]` - `enabled: Optional[bool]` - `model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `rewrite_prompt: Optional[str]` - `reranking: Optional[AISearchOptionsReranking]` - `enabled: Optional[bool]` - `match_threshold: Optional[float]` - `model: Optional[Literal["@cf/baai/bge-reranker-base", ""]]` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval: Optional[AISearchOptionsRetrieval]` - `boost_by: Optional[Iterable[AISearchOptionsRetrievalBoostBy]]` Metadata fields to boost search results by. Overrides the instance-level boost_by config. Direction defaults to 'asc' for numeric/datetime fields, 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: str` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support asc/desc directions; text/boolean fields support exists/not_exists. - `direction: Optional[Literal["asc", "desc", "exists", "not_exists"]]` Boost direction. 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime fields, 'exists' for text/boolean fields. - `"asc"` - `"desc"` - `"exists"` - `"not_exists"` - `context_expansion: Optional[int]` - `filters: Optional[Dict[str, object]]` - `fusion_method: Optional[Literal["max", "rrf"]]` - `"max"` - `"rrf"` - `keyword_match_mode: Optional[Literal["and", "or"]]` Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. Defaults to 'and'. - `"and"` - `"or"` - `match_threshold: Optional[float]` - `max_num_results: Optional[int]` - `retrieval_type: Optional[Literal["vector", "keyword", "hybrid"]]` - `"vector"` - `"keyword"` - `"hybrid"` - `return_on_failure: Optional[bool]` - `messages: Optional[Iterable[Message]]` - `content: Optional[str]` - `role: Literal["system", "developer", "user", 2 more]` - `"system"` - `"developer"` - `"user"` - `"assistant"` - `"tool"` - `query: Optional[str]` A simple text query string. Alternative to 'messages' — provide either this or 'messages', not both. ### Returns - `class InstanceSearchResponse: …` - `chunks: List[Chunk]` - `id: str` - `score: float` - `text: str` - `type: str` - `item: Optional[ChunkItem]` - `key: str` - `metadata: Optional[Dict[str, object]]` - `timestamp: Optional[float]` - `scoring_details: Optional[ChunkScoringDetails]` - `fusion_method: Optional[Literal["rrf", "max"]]` - `"rrf"` - `"max"` - `keyword_rank: Optional[float]` - `keyword_score: Optional[float]` - `reranking_score: Optional[float]` - `vector_rank: Optional[float]` - `vector_score: Optional[float]` - `search_query: str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.aisearch.namespaces.instances.search( id="my-ai-search", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", name="my-namespace", ) print(response.chunks) ``` #### Response ```json { "result": { "chunks": [ { "id": "id", "score": 0, "text": "text", "type": "type", "item": { "key": "key", "metadata": { "foo": "bar" }, "timestamp": 0 }, "scoring_details": { "fusion_method": "rrf", "keyword_rank": 0, "keyword_score": 0, "reranking_score": 0, "vector_rank": 0, "vector_score": 0 } } ], "search_query": "search_query" }, "success": true } ``` ## Chat Completions `aisearch.namespaces.instances.chat_completions(strid, InstanceChatCompletionsParams**kwargs) -> InstanceChatCompletionsResponse` **post** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/chat/completions` Performs a chat completion request against an AI Search instance, using indexed content as context for generating responses. ### Parameters - `account_id: Optional[str]` - `name: str` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `messages: Iterable[Message]` - `content: Optional[str]` - `role: Literal["system", "developer", "user", 2 more]` - `"system"` - `"developer"` - `"user"` - `"assistant"` - `"tool"` - `aisearch_options: Optional[AISearchOptions]` - `cache: Optional[AISearchOptionsCache]` - `cache_threshold: Optional[Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"]]` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `enabled: Optional[bool]` - `query_rewrite: Optional[AISearchOptionsQueryRewrite]` - `enabled: Optional[bool]` - `model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `rewrite_prompt: Optional[str]` - `reranking: Optional[AISearchOptionsReranking]` - `enabled: Optional[bool]` - `match_threshold: Optional[float]` - `model: Optional[Literal["@cf/baai/bge-reranker-base", ""]]` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval: Optional[AISearchOptionsRetrieval]` - `boost_by: Optional[Iterable[AISearchOptionsRetrievalBoostBy]]` Metadata fields to boost search results by. Overrides the instance-level boost_by config. Direction defaults to 'asc' for numeric/datetime fields, 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: str` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support asc/desc directions; text/boolean fields support exists/not_exists. - `direction: Optional[Literal["asc", "desc", "exists", "not_exists"]]` Boost direction. 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime fields, 'exists' for text/boolean fields. - `"asc"` - `"desc"` - `"exists"` - `"not_exists"` - `context_expansion: Optional[int]` - `filters: Optional[Dict[str, object]]` - `fusion_method: Optional[Literal["max", "rrf"]]` - `"max"` - `"rrf"` - `keyword_match_mode: Optional[Literal["and", "or"]]` Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. Defaults to 'and'. - `"and"` - `"or"` - `match_threshold: Optional[float]` - `max_num_results: Optional[int]` - `retrieval_type: Optional[Literal["vector", "keyword", "hybrid"]]` - `"vector"` - `"keyword"` - `"hybrid"` - `return_on_failure: Optional[bool]` - `model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `stream: Optional[bool]` ### Returns - `class InstanceChatCompletionsResponse: …` - `choices: List[Choice]` - `message: ChoiceMessage` - `content: Optional[str]` - `role: Literal["system", "developer", "user", 2 more]` - `"system"` - `"developer"` - `"user"` - `"assistant"` - `"tool"` - `index: Optional[int]` - `chunks: List[Chunk]` - `id: str` - `score: float` - `text: str` - `type: str` - `item: Optional[ChunkItem]` - `key: str` - `metadata: Optional[Dict[str, object]]` - `timestamp: Optional[float]` - `scoring_details: Optional[ChunkScoringDetails]` - `fusion_method: Optional[Literal["rrf", "max"]]` - `"rrf"` - `"max"` - `keyword_rank: Optional[float]` - `keyword_score: Optional[float]` - `reranking_score: Optional[float]` - `vector_rank: Optional[float]` - `vector_score: Optional[float]` - `id: Optional[str]` - `model: Optional[str]` - `object: Optional[str]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.aisearch.namespaces.instances.chat_completions( id="my-ai-search", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", name="my-namespace", messages=[{ "content": "content", "role": "system", }], ) print(response.id) ``` #### Response ```json { "choices": [ { "message": { "content": "content", "role": "system" }, "index": 0 } ], "chunks": [ { "id": "id", "score": 0, "text": "text", "type": "type", "item": { "key": "key", "metadata": { "foo": "bar" }, "timestamp": 0 }, "scoring_details": { "fusion_method": "rrf", "keyword_rank": 0, "keyword_score": 0, "reranking_score": 0, "vector_rank": 0, "vector_score": 0 } } ], "id": "id", "model": "model", "object": "object" } ``` ## Domain Types ### Instance List Response - `class InstanceListResponse: …` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: datetime` - `modified_at: datetime` - `ai_gateway_id: Optional[str]` - `aisearch_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `cache: Optional[bool]` - `cache_threshold: Optional[Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"]]` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `chunk_overlap: Optional[int]` - `chunk_size: Optional[int]` - `created_by: Optional[str]` - `custom_metadata: Optional[List[CustomMetadata]]` - `data_type: Literal["text", "number", "boolean", "datetime"]` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: str` - `embedding_model: Optional[Literal["@cf/qwen/qwen3-embedding-0.6b", "@cf/baai/bge-m3", "@cf/baai/bge-large-en-v1.5", 6 more]]` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/baai/bge-m3"` - `"@cf/baai/bge-large-en-v1.5"` - `"@cf/google/embeddinggemma-300m"` - `"google-ai-studio/gemini-embedding-001"` - `"google-ai-studio/gemini-embedding-2-preview"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable: Optional[bool]` - `engine_version: Optional[float]` - `fusion_method: Optional[Literal["max", "rrf"]]` - `"max"` - `"rrf"` - `hybrid_search_enabled: Optional[bool]` Deprecated — use index_method instead. - `index_method: Optional[IndexMethod]` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: bool` Enable keyword (BM25) storage backend. - `vector: bool` Enable vector (embedding) storage backend. - `indexing_options: Optional[IndexingOptions]` - `keyword_tokenizer: Optional[Literal["porter", "trigram"]]` Tokenizer used for keyword search indexing. porter provides word-level tokenization with Porter stemming (good for natural language queries). trigram enables character-level substring matching (good for partial matches, code, identifiers). Changing this triggers a full re-index. Defaults to porter. - `"porter"` - `"trigram"` - `last_activity: Optional[datetime]` - `max_num_results: Optional[int]` - `metadata: Optional[Metadata]` - `created_from_aisearch_wizard: Optional[bool]` - `search_for_agents: Optional[MetadataSearchForAgents]` - `hostname: str` - `zone_id: str` - `zone_name: str` - `worker_domain: Optional[str]` - `modified_by: Optional[str]` - `namespace: Optional[str]` - `paused: Optional[bool]` - `public_endpoint_id: Optional[str]` - `public_endpoint_params: Optional[PublicEndpointParams]` - `authorized_hosts: Optional[List[str]]` - `chat_completions_endpoint: Optional[PublicEndpointParamsChatCompletionsEndpoint]` - `disabled: Optional[bool]` Disable chat completions endpoint for this public endpoint - `enabled: Optional[bool]` - `mcp: Optional[PublicEndpointParamsMcp]` - `description: Optional[str]` - `disabled: Optional[bool]` Disable MCP endpoint for this public endpoint - `rate_limit: Optional[PublicEndpointParamsRateLimit]` - `period_ms: Optional[int]` - `requests: Optional[int]` - `technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `search_endpoint: Optional[PublicEndpointParamsSearchEndpoint]` - `disabled: Optional[bool]` Disable search endpoint for this public endpoint - `reranking: Optional[bool]` - `reranking_model: Optional[Literal["@cf/baai/bge-reranker-base", ""]]` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options: Optional[RetrievalOptions]` - `boost_by: Optional[List[RetrievalOptionsBoostBy]]` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: str` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support asc/desc directions; text/boolean fields support exists/not_exists. - `direction: Optional[Literal["asc", "desc", "exists", "not_exists"]]` Boost direction. 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime fields, 'exists' for text/boolean fields. - `"asc"` - `"desc"` - `"exists"` - `"not_exists"` - `keyword_match_mode: Optional[Literal["and", "or"]]` Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. Defaults to 'and'. - `"and"` - `"or"` - `rewrite_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `rewrite_query: Optional[bool]` - `score_threshold: Optional[float]` - `source: Optional[str]` - `source_params: Optional[SourceParams]` - `exclude_items: Optional[List[str]]` List of path patterns to exclude. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /admin/** matches /admin/users and /admin/settings/advanced) - `include_items: Optional[List[str]]` List of path patterns to include. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /blog/** matches /blog/post and /blog/2024/post) - `prefix: Optional[str]` - `r2_jurisdiction: Optional[str]` - `web_crawler: Optional[SourceParamsWebCrawler]` - `crawl_options: Optional[SourceParamsWebCrawlerCrawlOptions]` - `depth: Optional[float]` - `include_external_links: Optional[bool]` - `include_subdomains: Optional[bool]` - `max_age: Optional[float]` - `source: Optional[Literal["all", "sitemaps", "links"]]` - `"all"` - `"sitemaps"` - `"links"` - `parse_options: Optional[SourceParamsWebCrawlerParseOptions]` - `content_selector: Optional[List[SourceParamsWebCrawlerParseOptionsContentSelector]]` List of path-to-selector mappings for extracting specific content from crawled pages. Each entry pairs a URL glob pattern with a CSS selector. The first matching path wins. Only the matched HTML fragment is stored and indexed. - `path: str` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: str` CSS selector to extract content from pages matching the path pattern. Supports standard CSS selectors including class, ID, element, and attribute selectors. - `include_headers: Optional[Dict[str, str]]` - `include_images: Optional[bool]` - `specific_sitemaps: Optional[List[str]]` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering: Optional[bool]` - `parse_type: Optional[Literal["sitemap", "feed-rss", "crawl"]]` - `"sitemap"` - `"feed-rss"` - `"crawl"` - `store_options: Optional[SourceParamsWebCrawlerStoreOptions]` - `storage_id: str` - `r2_jurisdiction: Optional[str]` - `storage_type: Optional[Provider]` - `"r2"` - `status: Optional[str]` - `sync_interval: Optional[Literal[900, 1800, 3600, 5 more]]` Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). - `900` - `1800` - `3600` - `7200` - `14400` - `21600` - `43200` - `86400` - `token_id: Optional[str]` - `type: Optional[Literal["r2", "web-crawler"]]` - `"r2"` - `"web-crawler"` ### Instance Create Response - `class InstanceCreateResponse: …` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: datetime` - `modified_at: datetime` - `ai_gateway_id: Optional[str]` - `aisearch_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `cache: Optional[bool]` - `cache_threshold: Optional[Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"]]` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `chunk_overlap: Optional[int]` - `chunk_size: Optional[int]` - `created_by: Optional[str]` - `custom_metadata: Optional[List[CustomMetadata]]` - `data_type: Literal["text", "number", "boolean", "datetime"]` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: str` - `embedding_model: Optional[Literal["@cf/qwen/qwen3-embedding-0.6b", "@cf/baai/bge-m3", "@cf/baai/bge-large-en-v1.5", 6 more]]` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/baai/bge-m3"` - `"@cf/baai/bge-large-en-v1.5"` - `"@cf/google/embeddinggemma-300m"` - `"google-ai-studio/gemini-embedding-001"` - `"google-ai-studio/gemini-embedding-2-preview"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable: Optional[bool]` - `engine_version: Optional[float]` - `fusion_method: Optional[Literal["max", "rrf"]]` - `"max"` - `"rrf"` - `hybrid_search_enabled: Optional[bool]` Deprecated — use index_method instead. - `index_method: Optional[IndexMethod]` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: bool` Enable keyword (BM25) storage backend. - `vector: bool` Enable vector (embedding) storage backend. - `indexing_options: Optional[IndexingOptions]` - `keyword_tokenizer: Optional[Literal["porter", "trigram"]]` Tokenizer used for keyword search indexing. porter provides word-level tokenization with Porter stemming (good for natural language queries). trigram enables character-level substring matching (good for partial matches, code, identifiers). Changing this triggers a full re-index. Defaults to porter. - `"porter"` - `"trigram"` - `last_activity: Optional[datetime]` - `max_num_results: Optional[int]` - `metadata: Optional[Metadata]` - `created_from_aisearch_wizard: Optional[bool]` - `search_for_agents: Optional[MetadataSearchForAgents]` - `hostname: str` - `zone_id: str` - `zone_name: str` - `worker_domain: Optional[str]` - `modified_by: Optional[str]` - `namespace: Optional[str]` - `paused: Optional[bool]` - `public_endpoint_id: Optional[str]` - `public_endpoint_params: Optional[PublicEndpointParams]` - `authorized_hosts: Optional[List[str]]` - `chat_completions_endpoint: Optional[PublicEndpointParamsChatCompletionsEndpoint]` - `disabled: Optional[bool]` Disable chat completions endpoint for this public endpoint - `enabled: Optional[bool]` - `mcp: Optional[PublicEndpointParamsMcp]` - `description: Optional[str]` - `disabled: Optional[bool]` Disable MCP endpoint for this public endpoint - `rate_limit: Optional[PublicEndpointParamsRateLimit]` - `period_ms: Optional[int]` - `requests: Optional[int]` - `technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `search_endpoint: Optional[PublicEndpointParamsSearchEndpoint]` - `disabled: Optional[bool]` Disable search endpoint for this public endpoint - `reranking: Optional[bool]` - `reranking_model: Optional[Literal["@cf/baai/bge-reranker-base", ""]]` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options: Optional[RetrievalOptions]` - `boost_by: Optional[List[RetrievalOptionsBoostBy]]` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: str` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support asc/desc directions; text/boolean fields support exists/not_exists. - `direction: Optional[Literal["asc", "desc", "exists", "not_exists"]]` Boost direction. 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime fields, 'exists' for text/boolean fields. - `"asc"` - `"desc"` - `"exists"` - `"not_exists"` - `keyword_match_mode: Optional[Literal["and", "or"]]` Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. Defaults to 'and'. - `"and"` - `"or"` - `rewrite_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `rewrite_query: Optional[bool]` - `score_threshold: Optional[float]` - `source: Optional[str]` - `source_params: Optional[SourceParams]` - `exclude_items: Optional[List[str]]` List of path patterns to exclude. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /admin/** matches /admin/users and /admin/settings/advanced) - `include_items: Optional[List[str]]` List of path patterns to include. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /blog/** matches /blog/post and /blog/2024/post) - `prefix: Optional[str]` - `r2_jurisdiction: Optional[str]` - `web_crawler: Optional[SourceParamsWebCrawler]` - `crawl_options: Optional[SourceParamsWebCrawlerCrawlOptions]` - `depth: Optional[float]` - `include_external_links: Optional[bool]` - `include_subdomains: Optional[bool]` - `max_age: Optional[float]` - `source: Optional[Literal["all", "sitemaps", "links"]]` - `"all"` - `"sitemaps"` - `"links"` - `parse_options: Optional[SourceParamsWebCrawlerParseOptions]` - `content_selector: Optional[List[SourceParamsWebCrawlerParseOptionsContentSelector]]` List of path-to-selector mappings for extracting specific content from crawled pages. Each entry pairs a URL glob pattern with a CSS selector. The first matching path wins. Only the matched HTML fragment is stored and indexed. - `path: str` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: str` CSS selector to extract content from pages matching the path pattern. Supports standard CSS selectors including class, ID, element, and attribute selectors. - `include_headers: Optional[Dict[str, str]]` - `include_images: Optional[bool]` - `specific_sitemaps: Optional[List[str]]` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering: Optional[bool]` - `parse_type: Optional[Literal["sitemap", "feed-rss", "crawl"]]` - `"sitemap"` - `"feed-rss"` - `"crawl"` - `store_options: Optional[SourceParamsWebCrawlerStoreOptions]` - `storage_id: str` - `r2_jurisdiction: Optional[str]` - `storage_type: Optional[Provider]` - `"r2"` - `status: Optional[str]` - `sync_interval: Optional[Literal[900, 1800, 3600, 5 more]]` Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). - `900` - `1800` - `3600` - `7200` - `14400` - `21600` - `43200` - `86400` - `token_id: Optional[str]` - `type: Optional[Literal["r2", "web-crawler"]]` - `"r2"` - `"web-crawler"` ### Instance Read Response - `class InstanceReadResponse: …` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: datetime` - `modified_at: datetime` - `ai_gateway_id: Optional[str]` - `aisearch_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `cache: Optional[bool]` - `cache_threshold: Optional[Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"]]` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `chunk_overlap: Optional[int]` - `chunk_size: Optional[int]` - `created_by: Optional[str]` - `custom_metadata: Optional[List[CustomMetadata]]` - `data_type: Literal["text", "number", "boolean", "datetime"]` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: str` - `embedding_model: Optional[Literal["@cf/qwen/qwen3-embedding-0.6b", "@cf/baai/bge-m3", "@cf/baai/bge-large-en-v1.5", 6 more]]` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/baai/bge-m3"` - `"@cf/baai/bge-large-en-v1.5"` - `"@cf/google/embeddinggemma-300m"` - `"google-ai-studio/gemini-embedding-001"` - `"google-ai-studio/gemini-embedding-2-preview"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable: Optional[bool]` - `engine_version: Optional[float]` - `fusion_method: Optional[Literal["max", "rrf"]]` - `"max"` - `"rrf"` - `hybrid_search_enabled: Optional[bool]` Deprecated — use index_method instead. - `index_method: Optional[IndexMethod]` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: bool` Enable keyword (BM25) storage backend. - `vector: bool` Enable vector (embedding) storage backend. - `indexing_options: Optional[IndexingOptions]` - `keyword_tokenizer: Optional[Literal["porter", "trigram"]]` Tokenizer used for keyword search indexing. porter provides word-level tokenization with Porter stemming (good for natural language queries). trigram enables character-level substring matching (good for partial matches, code, identifiers). Changing this triggers a full re-index. Defaults to porter. - `"porter"` - `"trigram"` - `last_activity: Optional[datetime]` - `max_num_results: Optional[int]` - `metadata: Optional[Metadata]` - `created_from_aisearch_wizard: Optional[bool]` - `search_for_agents: Optional[MetadataSearchForAgents]` - `hostname: str` - `zone_id: str` - `zone_name: str` - `worker_domain: Optional[str]` - `modified_by: Optional[str]` - `namespace: Optional[str]` - `paused: Optional[bool]` - `public_endpoint_id: Optional[str]` - `public_endpoint_params: Optional[PublicEndpointParams]` - `authorized_hosts: Optional[List[str]]` - `chat_completions_endpoint: Optional[PublicEndpointParamsChatCompletionsEndpoint]` - `disabled: Optional[bool]` Disable chat completions endpoint for this public endpoint - `enabled: Optional[bool]` - `mcp: Optional[PublicEndpointParamsMcp]` - `description: Optional[str]` - `disabled: Optional[bool]` Disable MCP endpoint for this public endpoint - `rate_limit: Optional[PublicEndpointParamsRateLimit]` - `period_ms: Optional[int]` - `requests: Optional[int]` - `technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `search_endpoint: Optional[PublicEndpointParamsSearchEndpoint]` - `disabled: Optional[bool]` Disable search endpoint for this public endpoint - `reranking: Optional[bool]` - `reranking_model: Optional[Literal["@cf/baai/bge-reranker-base", ""]]` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options: Optional[RetrievalOptions]` - `boost_by: Optional[List[RetrievalOptionsBoostBy]]` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: str` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support asc/desc directions; text/boolean fields support exists/not_exists. - `direction: Optional[Literal["asc", "desc", "exists", "not_exists"]]` Boost direction. 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime fields, 'exists' for text/boolean fields. - `"asc"` - `"desc"` - `"exists"` - `"not_exists"` - `keyword_match_mode: Optional[Literal["and", "or"]]` Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. Defaults to 'and'. - `"and"` - `"or"` - `rewrite_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `rewrite_query: Optional[bool]` - `score_threshold: Optional[float]` - `source: Optional[str]` - `source_params: Optional[SourceParams]` - `exclude_items: Optional[List[str]]` List of path patterns to exclude. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /admin/** matches /admin/users and /admin/settings/advanced) - `include_items: Optional[List[str]]` List of path patterns to include. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /blog/** matches /blog/post and /blog/2024/post) - `prefix: Optional[str]` - `r2_jurisdiction: Optional[str]` - `web_crawler: Optional[SourceParamsWebCrawler]` - `crawl_options: Optional[SourceParamsWebCrawlerCrawlOptions]` - `depth: Optional[float]` - `include_external_links: Optional[bool]` - `include_subdomains: Optional[bool]` - `max_age: Optional[float]` - `source: Optional[Literal["all", "sitemaps", "links"]]` - `"all"` - `"sitemaps"` - `"links"` - `parse_options: Optional[SourceParamsWebCrawlerParseOptions]` - `content_selector: Optional[List[SourceParamsWebCrawlerParseOptionsContentSelector]]` List of path-to-selector mappings for extracting specific content from crawled pages. Each entry pairs a URL glob pattern with a CSS selector. The first matching path wins. Only the matched HTML fragment is stored and indexed. - `path: str` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: str` CSS selector to extract content from pages matching the path pattern. Supports standard CSS selectors including class, ID, element, and attribute selectors. - `include_headers: Optional[Dict[str, str]]` - `include_images: Optional[bool]` - `specific_sitemaps: Optional[List[str]]` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering: Optional[bool]` - `parse_type: Optional[Literal["sitemap", "feed-rss", "crawl"]]` - `"sitemap"` - `"feed-rss"` - `"crawl"` - `store_options: Optional[SourceParamsWebCrawlerStoreOptions]` - `storage_id: str` - `r2_jurisdiction: Optional[str]` - `storage_type: Optional[Provider]` - `"r2"` - `status: Optional[str]` - `sync_interval: Optional[Literal[900, 1800, 3600, 5 more]]` Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). - `900` - `1800` - `3600` - `7200` - `14400` - `21600` - `43200` - `86400` - `token_id: Optional[str]` - `type: Optional[Literal["r2", "web-crawler"]]` - `"r2"` - `"web-crawler"` ### Instance Update Response - `class InstanceUpdateResponse: …` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: datetime` - `modified_at: datetime` - `ai_gateway_id: Optional[str]` - `aisearch_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `cache: Optional[bool]` - `cache_threshold: Optional[Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"]]` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `chunk_overlap: Optional[int]` - `chunk_size: Optional[int]` - `created_by: Optional[str]` - `custom_metadata: Optional[List[CustomMetadata]]` - `data_type: Literal["text", "number", "boolean", "datetime"]` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: str` - `embedding_model: Optional[Literal["@cf/qwen/qwen3-embedding-0.6b", "@cf/baai/bge-m3", "@cf/baai/bge-large-en-v1.5", 6 more]]` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/baai/bge-m3"` - `"@cf/baai/bge-large-en-v1.5"` - `"@cf/google/embeddinggemma-300m"` - `"google-ai-studio/gemini-embedding-001"` - `"google-ai-studio/gemini-embedding-2-preview"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable: Optional[bool]` - `engine_version: Optional[float]` - `fusion_method: Optional[Literal["max", "rrf"]]` - `"max"` - `"rrf"` - `hybrid_search_enabled: Optional[bool]` Deprecated — use index_method instead. - `index_method: Optional[IndexMethod]` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: bool` Enable keyword (BM25) storage backend. - `vector: bool` Enable vector (embedding) storage backend. - `indexing_options: Optional[IndexingOptions]` - `keyword_tokenizer: Optional[Literal["porter", "trigram"]]` Tokenizer used for keyword search indexing. porter provides word-level tokenization with Porter stemming (good for natural language queries). trigram enables character-level substring matching (good for partial matches, code, identifiers). Changing this triggers a full re-index. Defaults to porter. - `"porter"` - `"trigram"` - `last_activity: Optional[datetime]` - `max_num_results: Optional[int]` - `metadata: Optional[Metadata]` - `created_from_aisearch_wizard: Optional[bool]` - `search_for_agents: Optional[MetadataSearchForAgents]` - `hostname: str` - `zone_id: str` - `zone_name: str` - `worker_domain: Optional[str]` - `modified_by: Optional[str]` - `namespace: Optional[str]` - `paused: Optional[bool]` - `public_endpoint_id: Optional[str]` - `public_endpoint_params: Optional[PublicEndpointParams]` - `authorized_hosts: Optional[List[str]]` - `chat_completions_endpoint: Optional[PublicEndpointParamsChatCompletionsEndpoint]` - `disabled: Optional[bool]` Disable chat completions endpoint for this public endpoint - `enabled: Optional[bool]` - `mcp: Optional[PublicEndpointParamsMcp]` - `description: Optional[str]` - `disabled: Optional[bool]` Disable MCP endpoint for this public endpoint - `rate_limit: Optional[PublicEndpointParamsRateLimit]` - `period_ms: Optional[int]` - `requests: Optional[int]` - `technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `search_endpoint: Optional[PublicEndpointParamsSearchEndpoint]` - `disabled: Optional[bool]` Disable search endpoint for this public endpoint - `reranking: Optional[bool]` - `reranking_model: Optional[Literal["@cf/baai/bge-reranker-base", ""]]` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options: Optional[RetrievalOptions]` - `boost_by: Optional[List[RetrievalOptionsBoostBy]]` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: str` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support asc/desc directions; text/boolean fields support exists/not_exists. - `direction: Optional[Literal["asc", "desc", "exists", "not_exists"]]` Boost direction. 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime fields, 'exists' for text/boolean fields. - `"asc"` - `"desc"` - `"exists"` - `"not_exists"` - `keyword_match_mode: Optional[Literal["and", "or"]]` Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. Defaults to 'and'. - `"and"` - `"or"` - `rewrite_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `rewrite_query: Optional[bool]` - `score_threshold: Optional[float]` - `source: Optional[str]` - `source_params: Optional[SourceParams]` - `exclude_items: Optional[List[str]]` List of path patterns to exclude. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /admin/** matches /admin/users and /admin/settings/advanced) - `include_items: Optional[List[str]]` List of path patterns to include. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /blog/** matches /blog/post and /blog/2024/post) - `prefix: Optional[str]` - `r2_jurisdiction: Optional[str]` - `web_crawler: Optional[SourceParamsWebCrawler]` - `crawl_options: Optional[SourceParamsWebCrawlerCrawlOptions]` - `depth: Optional[float]` - `include_external_links: Optional[bool]` - `include_subdomains: Optional[bool]` - `max_age: Optional[float]` - `source: Optional[Literal["all", "sitemaps", "links"]]` - `"all"` - `"sitemaps"` - `"links"` - `parse_options: Optional[SourceParamsWebCrawlerParseOptions]` - `content_selector: Optional[List[SourceParamsWebCrawlerParseOptionsContentSelector]]` List of path-to-selector mappings for extracting specific content from crawled pages. Each entry pairs a URL glob pattern with a CSS selector. The first matching path wins. Only the matched HTML fragment is stored and indexed. - `path: str` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: str` CSS selector to extract content from pages matching the path pattern. Supports standard CSS selectors including class, ID, element, and attribute selectors. - `include_headers: Optional[Dict[str, str]]` - `include_images: Optional[bool]` - `specific_sitemaps: Optional[List[str]]` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering: Optional[bool]` - `parse_type: Optional[Literal["sitemap", "feed-rss", "crawl"]]` - `"sitemap"` - `"feed-rss"` - `"crawl"` - `store_options: Optional[SourceParamsWebCrawlerStoreOptions]` - `storage_id: str` - `r2_jurisdiction: Optional[str]` - `storage_type: Optional[Provider]` - `"r2"` - `status: Optional[str]` - `sync_interval: Optional[Literal[900, 1800, 3600, 5 more]]` Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). - `900` - `1800` - `3600` - `7200` - `14400` - `21600` - `43200` - `86400` - `token_id: Optional[str]` - `type: Optional[Literal["r2", "web-crawler"]]` - `"r2"` - `"web-crawler"` ### Instance Delete Response - `class InstanceDeleteResponse: …` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: datetime` - `modified_at: datetime` - `ai_gateway_id: Optional[str]` - `aisearch_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `cache: Optional[bool]` - `cache_threshold: Optional[Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"]]` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `chunk_overlap: Optional[int]` - `chunk_size: Optional[int]` - `created_by: Optional[str]` - `custom_metadata: Optional[List[CustomMetadata]]` - `data_type: Literal["text", "number", "boolean", "datetime"]` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: str` - `embedding_model: Optional[Literal["@cf/qwen/qwen3-embedding-0.6b", "@cf/baai/bge-m3", "@cf/baai/bge-large-en-v1.5", 6 more]]` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/baai/bge-m3"` - `"@cf/baai/bge-large-en-v1.5"` - `"@cf/google/embeddinggemma-300m"` - `"google-ai-studio/gemini-embedding-001"` - `"google-ai-studio/gemini-embedding-2-preview"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable: Optional[bool]` - `engine_version: Optional[float]` - `fusion_method: Optional[Literal["max", "rrf"]]` - `"max"` - `"rrf"` - `hybrid_search_enabled: Optional[bool]` Deprecated — use index_method instead. - `index_method: Optional[IndexMethod]` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: bool` Enable keyword (BM25) storage backend. - `vector: bool` Enable vector (embedding) storage backend. - `indexing_options: Optional[IndexingOptions]` - `keyword_tokenizer: Optional[Literal["porter", "trigram"]]` Tokenizer used for keyword search indexing. porter provides word-level tokenization with Porter stemming (good for natural language queries). trigram enables character-level substring matching (good for partial matches, code, identifiers). Changing this triggers a full re-index. Defaults to porter. - `"porter"` - `"trigram"` - `last_activity: Optional[datetime]` - `max_num_results: Optional[int]` - `metadata: Optional[Metadata]` - `created_from_aisearch_wizard: Optional[bool]` - `search_for_agents: Optional[MetadataSearchForAgents]` - `hostname: str` - `zone_id: str` - `zone_name: str` - `worker_domain: Optional[str]` - `modified_by: Optional[str]` - `namespace: Optional[str]` - `paused: Optional[bool]` - `public_endpoint_id: Optional[str]` - `public_endpoint_params: Optional[PublicEndpointParams]` - `authorized_hosts: Optional[List[str]]` - `chat_completions_endpoint: Optional[PublicEndpointParamsChatCompletionsEndpoint]` - `disabled: Optional[bool]` Disable chat completions endpoint for this public endpoint - `enabled: Optional[bool]` - `mcp: Optional[PublicEndpointParamsMcp]` - `description: Optional[str]` - `disabled: Optional[bool]` Disable MCP endpoint for this public endpoint - `rate_limit: Optional[PublicEndpointParamsRateLimit]` - `period_ms: Optional[int]` - `requests: Optional[int]` - `technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `search_endpoint: Optional[PublicEndpointParamsSearchEndpoint]` - `disabled: Optional[bool]` Disable search endpoint for this public endpoint - `reranking: Optional[bool]` - `reranking_model: Optional[Literal["@cf/baai/bge-reranker-base", ""]]` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options: Optional[RetrievalOptions]` - `boost_by: Optional[List[RetrievalOptionsBoostBy]]` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: str` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support asc/desc directions; text/boolean fields support exists/not_exists. - `direction: Optional[Literal["asc", "desc", "exists", "not_exists"]]` Boost direction. 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime fields, 'exists' for text/boolean fields. - `"asc"` - `"desc"` - `"exists"` - `"not_exists"` - `keyword_match_mode: Optional[Literal["and", "or"]]` Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. Defaults to 'and'. - `"and"` - `"or"` - `rewrite_model: Optional[Literal["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/zai-org/glm-4.7-flash", "@cf/meta/llama-3.1-8b-instruct-fast", 27 more]]` - `"@cf/meta/llama-3.3-70b-instruct-fp8-fast"` - `"@cf/zai-org/glm-4.7-flash"` - `"@cf/meta/llama-3.1-8b-instruct-fast"` - `"@cf/meta/llama-3.1-8b-instruct-fp8"` - `"@cf/meta/llama-4-scout-17b-16e-instruct"` - `"@cf/qwen/qwen3-30b-a3b-fp8"` - `"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"` - `"@cf/moonshotai/kimi-k2-instruct"` - `"@cf/google/gemma-3-12b-it"` - `"@cf/google/gemma-4-26b-a4b-it"` - `"@cf/moonshotai/kimi-k2.5"` - `"anthropic/claude-3-7-sonnet"` - `"anthropic/claude-sonnet-4"` - `"anthropic/claude-opus-4"` - `"anthropic/claude-3-5-haiku"` - `"cerebras/qwen-3-235b-a22b-instruct"` - `"cerebras/qwen-3-235b-a22b-thinking"` - `"cerebras/llama-3.3-70b"` - `"cerebras/llama-4-maverick-17b-128e-instruct"` - `"cerebras/llama-4-scout-17b-16e-instruct"` - `"cerebras/gpt-oss-120b"` - `"google-ai-studio/gemini-2.5-flash"` - `"google-ai-studio/gemini-2.5-pro"` - `"grok/grok-4"` - `"groq/llama-3.3-70b-versatile"` - `"groq/llama-3.1-8b-instant"` - `"openai/gpt-5"` - `"openai/gpt-5-mini"` - `"openai/gpt-5-nano"` - `""` - `rewrite_query: Optional[bool]` - `score_threshold: Optional[float]` - `source: Optional[str]` - `source_params: Optional[SourceParams]` - `exclude_items: Optional[List[str]]` List of path patterns to exclude. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /admin/** matches /admin/users and /admin/settings/advanced) - `include_items: Optional[List[str]]` List of path patterns to include. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /blog/** matches /blog/post and /blog/2024/post) - `prefix: Optional[str]` - `r2_jurisdiction: Optional[str]` - `web_crawler: Optional[SourceParamsWebCrawler]` - `crawl_options: Optional[SourceParamsWebCrawlerCrawlOptions]` - `depth: Optional[float]` - `include_external_links: Optional[bool]` - `include_subdomains: Optional[bool]` - `max_age: Optional[float]` - `source: Optional[Literal["all", "sitemaps", "links"]]` - `"all"` - `"sitemaps"` - `"links"` - `parse_options: Optional[SourceParamsWebCrawlerParseOptions]` - `content_selector: Optional[List[SourceParamsWebCrawlerParseOptionsContentSelector]]` List of path-to-selector mappings for extracting specific content from crawled pages. Each entry pairs a URL glob pattern with a CSS selector. The first matching path wins. Only the matched HTML fragment is stored and indexed. - `path: str` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: str` CSS selector to extract content from pages matching the path pattern. Supports standard CSS selectors including class, ID, element, and attribute selectors. - `include_headers: Optional[Dict[str, str]]` - `include_images: Optional[bool]` - `specific_sitemaps: Optional[List[str]]` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering: Optional[bool]` - `parse_type: Optional[Literal["sitemap", "feed-rss", "crawl"]]` - `"sitemap"` - `"feed-rss"` - `"crawl"` - `store_options: Optional[SourceParamsWebCrawlerStoreOptions]` - `storage_id: str` - `r2_jurisdiction: Optional[str]` - `storage_type: Optional[Provider]` - `"r2"` - `status: Optional[str]` - `sync_interval: Optional[Literal[900, 1800, 3600, 5 more]]` Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). - `900` - `1800` - `3600` - `7200` - `14400` - `21600` - `43200` - `86400` - `token_id: Optional[str]` - `type: Optional[Literal["r2", "web-crawler"]]` - `"r2"` - `"web-crawler"` ### Instance Stats Response - `class InstanceStatsResponse: …` - `completed: Optional[int]` - `engine: Optional[Engine]` Engine-specific metadata. Present only for managed (v3) instances. - `r2: Optional[EngineR2]` R2 bucket storage usage in bytes. - `metadata_size_bytes: int` - `object_count: int` - `payload_size_bytes: int` - `vectorize: Optional[EngineVectorize]` Vectorize index metadata (dimensions, vector count). - `dimensions: int` - `vectors_count: int` - `error: Optional[int]` - `file_embed_errors: Optional[Dict[str, object]]` - `index_source_errors: Optional[Dict[str, object]]` - `last_activity: Optional[datetime]` - `outdated: Optional[int]` - `queued: Optional[int]` - `running: Optional[int]` - `skipped: Optional[int]` ### Instance Search Response - `class InstanceSearchResponse: …` - `chunks: List[Chunk]` - `id: str` - `score: float` - `text: str` - `type: str` - `item: Optional[ChunkItem]` - `key: str` - `metadata: Optional[Dict[str, object]]` - `timestamp: Optional[float]` - `scoring_details: Optional[ChunkScoringDetails]` - `fusion_method: Optional[Literal["rrf", "max"]]` - `"rrf"` - `"max"` - `keyword_rank: Optional[float]` - `keyword_score: Optional[float]` - `reranking_score: Optional[float]` - `vector_rank: Optional[float]` - `vector_score: Optional[float]` - `search_query: str` ### Instance Chat Completions Response - `class InstanceChatCompletionsResponse: …` - `choices: List[Choice]` - `message: ChoiceMessage` - `content: Optional[str]` - `role: Literal["system", "developer", "user", 2 more]` - `"system"` - `"developer"` - `"user"` - `"assistant"` - `"tool"` - `index: Optional[int]` - `chunks: List[Chunk]` - `id: str` - `score: float` - `text: str` - `type: str` - `item: Optional[ChunkItem]` - `key: str` - `metadata: Optional[Dict[str, object]]` - `timestamp: Optional[float]` - `scoring_details: Optional[ChunkScoringDetails]` - `fusion_method: Optional[Literal["rrf", "max"]]` - `"rrf"` - `"max"` - `keyword_rank: Optional[float]` - `keyword_score: Optional[float]` - `reranking_score: Optional[float]` - `vector_rank: Optional[float]` - `vector_score: Optional[float]` - `id: Optional[str]` - `model: Optional[str]` - `object: Optional[str]` # Jobs ## List Jobs `aisearch.namespaces.instances.jobs.list(strid, JobListParams**kwargs) -> SyncV4PagePaginationArray[JobListResponse]` **get** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/jobs` Lists indexing jobs for an AI Search instance. ### Parameters - `account_id: Optional[str]` - `name: str` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `page: Optional[int]` - `per_page: Optional[int]` ### Returns - `class JobListResponse: …` - `id: str` - `source: Literal["user", "schedule"]` - `"user"` - `"schedule"` - `description: Optional[str]` - `end_reason: Optional[str]` - `ended_at: Optional[str]` - `last_seen_at: Optional[str]` - `started_at: Optional[str]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.aisearch.namespaces.instances.jobs.list( id="my-ai-search", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", name="my-namespace", ) page = page.result[0] print(page.id) ``` #### Response ```json { "result": [ { "id": "id", "source": "user", "description": "description", "end_reason": "end_reason", "ended_at": "ended_at", "last_seen_at": "last_seen_at", "started_at": "started_at" } ], "result_info": { "count": 0, "page": 0, "per_page": 0, "total_count": 0 }, "success": true } ``` ## Create new job `aisearch.namespaces.instances.jobs.create(strid, JobCreateParams**kwargs) -> JobCreateResponse` **post** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/jobs` Creates a new indexing job for an AI Search instance. ### Parameters - `account_id: Optional[str]` - `name: str` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `description: Optional[str]` ### Returns - `class JobCreateResponse: …` - `id: str` - `source: Literal["user", "schedule"]` - `"user"` - `"schedule"` - `description: Optional[str]` - `end_reason: Optional[str]` - `ended_at: Optional[str]` - `last_seen_at: Optional[str]` - `started_at: Optional[str]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) job = client.aisearch.namespaces.instances.jobs.create( id="my-ai-search", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", name="my-namespace", ) print(job.id) ``` #### Response ```json { "result": { "id": "id", "source": "user", "description": "description", "end_reason": "end_reason", "ended_at": "ended_at", "last_seen_at": "last_seen_at", "started_at": "started_at" }, "success": true } ``` ## Get a Job Details `aisearch.namespaces.instances.jobs.get(strjob_id, JobGetParams**kwargs) -> JobGetResponse` **get** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/jobs/{job_id}` Retrieves details for a specific AI Search indexing job. ### Parameters - `account_id: Optional[str]` - `name: str` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `job_id: str` ### Returns - `class JobGetResponse: …` - `id: str` - `source: Literal["user", "schedule"]` - `"user"` - `"schedule"` - `description: Optional[str]` - `end_reason: Optional[str]` - `ended_at: Optional[str]` - `last_seen_at: Optional[str]` - `started_at: Optional[str]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) job = client.aisearch.namespaces.instances.jobs.get( job_id="job_id", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", name="my-namespace", id="my-ai-search", ) print(job.id) ``` #### Response ```json { "result": { "id": "id", "source": "user", "description": "description", "end_reason": "end_reason", "ended_at": "ended_at", "last_seen_at": "last_seen_at", "started_at": "started_at" }, "success": true } ``` ## Change Job Status `aisearch.namespaces.instances.jobs.update(strjob_id, JobUpdateParams**kwargs) -> JobUpdateResponse` **patch** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/jobs/{job_id}` Updates the status of an AI Search indexing job. ### Parameters - `account_id: Optional[str]` - `name: str` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `job_id: str` - `action: Literal["cancel"]` - `"cancel"` ### Returns - `class JobUpdateResponse: …` - `id: str` - `source: Literal["user", "schedule"]` - `"user"` - `"schedule"` - `description: Optional[str]` - `end_reason: Optional[str]` - `ended_at: Optional[str]` - `last_seen_at: Optional[str]` - `started_at: Optional[str]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) job = client.aisearch.namespaces.instances.jobs.update( job_id="job_id", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", name="my-namespace", id="my-ai-search", action="cancel", ) print(job.id) ``` #### Response ```json { "result": { "id": "id", "source": "user", "description": "description", "end_reason": "end_reason", "ended_at": "ended_at", "last_seen_at": "last_seen_at", "started_at": "started_at" }, "success": true } ``` ## List Job Logs `aisearch.namespaces.instances.jobs.logs(strjob_id, JobLogsParams**kwargs) -> JobLogsResponse` **get** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/jobs/{job_id}/logs` Lists log entries for an AI Search indexing job. ### Parameters - `account_id: Optional[str]` - `name: str` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `job_id: str` - `page: Optional[int]` - `per_page: Optional[int]` ### Returns - `List[JobLogsResponseItem]` - `id: int` - `created_at: float` - `message: str` - `message_type: int` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.aisearch.namespaces.instances.jobs.logs( job_id="job_id", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", name="my-namespace", id="my-ai-search", ) print(response) ``` #### Response ```json { "result": [ { "id": 0, "created_at": 0, "message": "message", "message_type": 0 } ], "result_info": { "count": 0, "page": 0, "per_page": 0, "total_count": 0 }, "success": true } ``` ## Domain Types ### Job List Response - `class JobListResponse: …` - `id: str` - `source: Literal["user", "schedule"]` - `"user"` - `"schedule"` - `description: Optional[str]` - `end_reason: Optional[str]` - `ended_at: Optional[str]` - `last_seen_at: Optional[str]` - `started_at: Optional[str]` ### Job Create Response - `class JobCreateResponse: …` - `id: str` - `source: Literal["user", "schedule"]` - `"user"` - `"schedule"` - `description: Optional[str]` - `end_reason: Optional[str]` - `ended_at: Optional[str]` - `last_seen_at: Optional[str]` - `started_at: Optional[str]` ### Job Get Response - `class JobGetResponse: …` - `id: str` - `source: Literal["user", "schedule"]` - `"user"` - `"schedule"` - `description: Optional[str]` - `end_reason: Optional[str]` - `ended_at: Optional[str]` - `last_seen_at: Optional[str]` - `started_at: Optional[str]` ### Job Update Response - `class JobUpdateResponse: …` - `id: str` - `source: Literal["user", "schedule"]` - `"user"` - `"schedule"` - `description: Optional[str]` - `end_reason: Optional[str]` - `ended_at: Optional[str]` - `last_seen_at: Optional[str]` - `started_at: Optional[str]` ### Job Logs Response - `List[JobLogsResponseItem]` - `id: int` - `created_at: float` - `message: str` - `message_type: int` # Items ## Items List. `aisearch.namespaces.instances.items.list(strid, ItemListParams**kwargs) -> SyncV4PagePaginationArray[ItemListResponse]` **get** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items` Lists indexed items in an AI Search instance. ### Parameters - `account_id: Optional[str]` - `name: str` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `item_id: Optional[str]` Filter items by their unique ID. Returns at most one item. - `metadata_filter: Optional[str]` JSON-encoded metadata filter using Vectorize filter syntax. Examples: {"folder":"reports/"}, {"timestamp":{"$gte":1700000000000}}, {"folder":{"$in":["docs/","reports/"]}} - `page: Optional[int]` - `per_page: Optional[int]` - `search: Optional[str]` - `sort_by: Optional[Literal["status", "modified_at"]]` Sort order for items. "status" (default) sorts by status priority then last_seen_at. "modified_at" sorts by file modification time (most recent first), falling back to created_at. - `"status"` - `"modified_at"` - `source: Optional[str]` Filter items by source_id. Use "builtin" for uploaded files, or a source identifier like "web-crawler:https://example.com". - `status: Optional[Literal["queued", "running", "completed", 3 more]]` - `"queued"` - `"running"` - `"completed"` - `"error"` - `"skipped"` - `"outdated"` ### Returns - `class ItemListResponse: …` - `id: str` - `checksum: str` - `chunks_count: Optional[int]` - `created_at: datetime` - `file_size: Optional[float]` - `key: str` - `last_seen_at: datetime` - `namespace: str` - `next_action: Optional[Literal["INDEX", "DELETE"]]` - `"INDEX"` - `"DELETE"` - `source_id: Optional[str]` Identifies which data source this item belongs to. "builtin" for uploaded files, "{type}:{source}" for external sources, null for legacy items. - `status: Literal["queued", "running", "completed", 3 more]` - `"queued"` - `"running"` - `"completed"` - `"error"` - `"skipped"` - `"outdated"` - `error: Optional[str]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.aisearch.namespaces.instances.items.list( id="my-ai-search", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", name="my-namespace", ) page = page.result[0] print(page.id) ``` #### Response ```json { "result": [ { "id": "id", "checksum": "checksum", "chunks_count": 0, "created_at": "2019-12-27T18:11:19.117Z", "file_size": 0, "key": "key", "last_seen_at": "2019-12-27T18:11:19.117Z", "namespace": "namespace", "next_action": "INDEX", "source_id": "source_id", "status": "queued", "error": "error" } ], "result_info": { "count": 0, "page": 0, "total_count": 0, "per_page": 5 }, "success": true } ``` ## Upload Item. `aisearch.namespaces.instances.items.upload(strid, ItemUploadParams**kwargs) -> ItemUploadResponse` **post** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items` Uploads a file to a managed AI Search instance via multipart/form-data (max 4MB). ### Parameters - `account_id: Optional[str]` - `name: str` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `file: File` - `file: FileTypes` The file to upload (max 4MB). Filename must not exceed 128 characters. - `metadata: Optional[str]` JSON string of custom metadata key-value pairs. - `wait_for_completion: Optional[bool]` Wait for indexing to complete before responding. Defaults to false. ### Returns - `class ItemUploadResponse: …` - `id: str` - `checksum: str` - `chunks_count: Optional[int]` - `created_at: datetime` - `file_size: Optional[float]` - `key: str` - `last_seen_at: datetime` - `namespace: str` - `next_action: Optional[Literal["INDEX", "DELETE"]]` - `"INDEX"` - `"DELETE"` - `source_id: Optional[str]` Identifies which data source this item belongs to. "builtin" for uploaded files, "{type}:{source}" for external sources, null for legacy items. - `status: Literal["queued", "running", "completed", 3 more]` - `"queued"` - `"running"` - `"completed"` - `"error"` - `"skipped"` - `"outdated"` - `error: Optional[str]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.aisearch.namespaces.instances.items.upload( id="my-ai-search", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", name="my-namespace", file={ "file": b"Example data" }, ) print(response.id) ``` #### Response ```json { "result": { "id": "id", "checksum": "checksum", "chunks_count": 0, "created_at": "2019-12-27T18:11:19.117Z", "file_size": 0, "key": "key", "last_seen_at": "2019-12-27T18:11:19.117Z", "namespace": "namespace", "next_action": "INDEX", "source_id": "source_id", "status": "queued", "error": "error" }, "success": true } ``` ## Create or Update Item. `aisearch.namespaces.instances.items.create_or_update(strid, ItemCreateOrUpdateParams**kwargs) -> ItemCreateOrUpdateResponse` **put** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items` Creates or updates an indexed item in an AI Search instance. ### Parameters - `account_id: Optional[str]` - `name: str` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `key: str` Item key / filename. Must not exceed 128 characters. - `next_action: Literal["INDEX"]` - `"INDEX"` ### Returns - `class ItemCreateOrUpdateResponse: …` - `id: str` - `checksum: str` - `chunks_count: Optional[int]` - `created_at: datetime` - `file_size: Optional[float]` - `key: str` - `last_seen_at: datetime` - `namespace: str` - `next_action: Optional[Literal["INDEX", "DELETE"]]` - `"INDEX"` - `"DELETE"` - `source_id: Optional[str]` Identifies which data source this item belongs to. "builtin" for uploaded files, "{type}:{source}" for external sources, null for legacy items. - `status: Literal["queued", "running", "completed", 3 more]` - `"queued"` - `"running"` - `"completed"` - `"error"` - `"skipped"` - `"outdated"` - `error: Optional[str]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.aisearch.namespaces.instances.items.create_or_update( id="my-ai-search", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", name="my-namespace", key="key", next_action="INDEX", ) print(response.id) ``` #### Response ```json { "result": { "id": "id", "checksum": "checksum", "chunks_count": 0, "created_at": "2019-12-27T18:11:19.117Z", "file_size": 0, "key": "key", "last_seen_at": "2019-12-27T18:11:19.117Z", "namespace": "namespace", "next_action": "INDEX", "source_id": "source_id", "status": "queued", "error": "error" }, "success": true } ``` ## Get Item. `aisearch.namespaces.instances.items.get(stritem_id, ItemGetParams**kwargs) -> ItemGetResponse` **get** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items/{item_id}` Retrieves a specific indexed item from an AI Search instance. ### Parameters - `account_id: Optional[str]` - `name: str` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `item_id: str` ### Returns - `class ItemGetResponse: …` - `id: str` - `checksum: str` - `chunks_count: Optional[int]` - `created_at: datetime` - `file_size: Optional[float]` - `key: str` - `last_seen_at: datetime` - `namespace: str` - `next_action: Optional[Literal["INDEX", "DELETE"]]` - `"INDEX"` - `"DELETE"` - `source_id: Optional[str]` Identifies which data source this item belongs to. "builtin" for uploaded files, "{type}:{source}" for external sources, null for legacy items. - `status: Literal["queued", "running", "completed", 3 more]` - `"queued"` - `"running"` - `"completed"` - `"error"` - `"skipped"` - `"outdated"` - `error: Optional[str]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) item = client.aisearch.namespaces.instances.items.get( item_id="item_id", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", name="my-namespace", id="my-ai-search", ) print(item.id) ``` #### Response ```json { "result": { "id": "id", "checksum": "checksum", "chunks_count": 0, "created_at": "2019-12-27T18:11:19.117Z", "file_size": 0, "key": "key", "last_seen_at": "2019-12-27T18:11:19.117Z", "namespace": "namespace", "next_action": "INDEX", "source_id": "source_id", "status": "queued", "error": "error" }, "success": true } ``` ## Sync Item. `aisearch.namespaces.instances.items.sync(stritem_id, ItemSyncParams**kwargs) -> ItemSyncResponse` **patch** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items/{item_id}` Syncs an item to an AI Search instance index. ### Parameters - `account_id: Optional[str]` - `name: str` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `item_id: str` - `next_action: Literal["INDEX"]` - `"INDEX"` ### Returns - `class ItemSyncResponse: …` - `id: str` - `checksum: str` - `chunks_count: Optional[int]` - `created_at: datetime` - `file_size: Optional[float]` - `key: str` - `last_seen_at: datetime` - `namespace: str` - `next_action: Optional[Literal["INDEX", "DELETE"]]` - `"INDEX"` - `"DELETE"` - `source_id: Optional[str]` Identifies which data source this item belongs to. "builtin" for uploaded files, "{type}:{source}" for external sources, null for legacy items. - `status: Literal["queued", "running", "completed", 3 more]` - `"queued"` - `"running"` - `"completed"` - `"error"` - `"skipped"` - `"outdated"` - `error: Optional[str]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.aisearch.namespaces.instances.items.sync( item_id="item_id", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", name="my-namespace", id="my-ai-search", next_action="INDEX", ) print(response.id) ``` #### Response ```json { "result": { "id": "id", "checksum": "checksum", "chunks_count": 0, "created_at": "2019-12-27T18:11:19.117Z", "file_size": 0, "key": "key", "last_seen_at": "2019-12-27T18:11:19.117Z", "namespace": "namespace", "next_action": "INDEX", "source_id": "source_id", "status": "queued", "error": "error" }, "success": true } ``` ## Delete Item. `aisearch.namespaces.instances.items.delete(stritem_id, ItemDeleteParams**kwargs) -> ItemDeleteResponse` **delete** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items/{item_id}` Deletes a file from a managed AI Search instance and triggers a reindex. ### Parameters - `account_id: Optional[str]` - `name: str` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `item_id: str` ### Returns - `class ItemDeleteResponse: …` - `key: str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) item = client.aisearch.namespaces.instances.items.delete( item_id="item_id", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", name="my-namespace", id="my-ai-search", ) print(item.key) ``` #### Response ```json { "result": { "key": "key" }, "success": true } ``` ## Download Item Content. `aisearch.namespaces.instances.items.download(stritem_id, ItemDownloadParams**kwargs) -> BinaryResponseContent` **get** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items/{item_id}/download` Downloads the raw file content for a specific item from the managed AI Search instance storage. ### Parameters - `account_id: Optional[str]` - `name: str` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `item_id: str` ### Returns - `BinaryResponseContent` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.aisearch.namespaces.instances.items.download( item_id="item_id", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", name="my-namespace", id="my-ai-search", ) print(response) content = response.read() print(content) ``` ## Item Logs. `aisearch.namespaces.instances.items.logs(stritem_id, ItemLogsParams**kwargs) -> ItemLogsResponse` **get** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items/{item_id}/logs` Lists processing logs for a specific item in an AI Search instance. ### Parameters - `account_id: Optional[str]` - `name: str` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `item_id: str` - `cursor: Optional[str]` - `limit: Optional[int]` ### Returns - `List[ItemLogsResponseItem]` - `action: str` - `chunk_count: Optional[int]` - `error_type: Optional[str]` - `file_key: str` - `message: Optional[str]` - `processing_time_ms: Optional[int]` - `timestamp: datetime` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.aisearch.namespaces.instances.items.logs( item_id="item_id", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", name="my-namespace", id="my-ai-search", ) print(response) ``` #### Response ```json { "result": [ { "action": "action", "chunkCount": 0, "errorType": "errorType", "fileKey": "fileKey", "message": "message", "processingTimeMs": 0, "timestamp": "2019-12-27T18:11:19.117Z" } ], "result_info": { "count": 0, "cursor": "cursor", "per_page": 0, "truncated": true }, "success": true } ``` ## List Item Chunks. `aisearch.namespaces.instances.items.chunks(stritem_id, ItemChunksParams**kwargs) -> ItemChunksResponse` **get** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items/{item_id}/chunks` Lists chunks for a specific item in an AI Search instance, including their text content. ### Parameters - `account_id: Optional[str]` - `name: str` - `id: str` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `item_id: str` - `limit: Optional[int]` - `offset: Optional[int]` ### Returns - `List[ItemChunksResponseItem]` - `id: str` - `item: ItemChunksResponseItemItem` - `key: str` - `metadata: Optional[Dict[str, object]]` - `timestamp: Optional[float]` - `text: str` - `end_byte: Optional[float]` - `start_byte: Optional[float]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.aisearch.namespaces.instances.items.chunks( item_id="item_id", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", name="my-namespace", id="my-ai-search", ) print(response) ``` #### Response ```json { "result": [ { "id": "id", "item": { "key": "key", "metadata": { "foo": "bar" }, "timestamp": 0 }, "text": "text", "end_byte": 0, "start_byte": 0 } ], "result_info": { "count": 0, "limit": 0, "offset": 0, "total": 0 }, "success": true } ``` ## Domain Types ### Item List Response - `class ItemListResponse: …` - `id: str` - `checksum: str` - `chunks_count: Optional[int]` - `created_at: datetime` - `file_size: Optional[float]` - `key: str` - `last_seen_at: datetime` - `namespace: str` - `next_action: Optional[Literal["INDEX", "DELETE"]]` - `"INDEX"` - `"DELETE"` - `source_id: Optional[str]` Identifies which data source this item belongs to. "builtin" for uploaded files, "{type}:{source}" for external sources, null for legacy items. - `status: Literal["queued", "running", "completed", 3 more]` - `"queued"` - `"running"` - `"completed"` - `"error"` - `"skipped"` - `"outdated"` - `error: Optional[str]` ### Item Upload Response - `class ItemUploadResponse: …` - `id: str` - `checksum: str` - `chunks_count: Optional[int]` - `created_at: datetime` - `file_size: Optional[float]` - `key: str` - `last_seen_at: datetime` - `namespace: str` - `next_action: Optional[Literal["INDEX", "DELETE"]]` - `"INDEX"` - `"DELETE"` - `source_id: Optional[str]` Identifies which data source this item belongs to. "builtin" for uploaded files, "{type}:{source}" for external sources, null for legacy items. - `status: Literal["queued", "running", "completed", 3 more]` - `"queued"` - `"running"` - `"completed"` - `"error"` - `"skipped"` - `"outdated"` - `error: Optional[str]` ### Item Create Or Update Response - `class ItemCreateOrUpdateResponse: …` - `id: str` - `checksum: str` - `chunks_count: Optional[int]` - `created_at: datetime` - `file_size: Optional[float]` - `key: str` - `last_seen_at: datetime` - `namespace: str` - `next_action: Optional[Literal["INDEX", "DELETE"]]` - `"INDEX"` - `"DELETE"` - `source_id: Optional[str]` Identifies which data source this item belongs to. "builtin" for uploaded files, "{type}:{source}" for external sources, null for legacy items. - `status: Literal["queued", "running", "completed", 3 more]` - `"queued"` - `"running"` - `"completed"` - `"error"` - `"skipped"` - `"outdated"` - `error: Optional[str]` ### Item Get Response - `class ItemGetResponse: …` - `id: str` - `checksum: str` - `chunks_count: Optional[int]` - `created_at: datetime` - `file_size: Optional[float]` - `key: str` - `last_seen_at: datetime` - `namespace: str` - `next_action: Optional[Literal["INDEX", "DELETE"]]` - `"INDEX"` - `"DELETE"` - `source_id: Optional[str]` Identifies which data source this item belongs to. "builtin" for uploaded files, "{type}:{source}" for external sources, null for legacy items. - `status: Literal["queued", "running", "completed", 3 more]` - `"queued"` - `"running"` - `"completed"` - `"error"` - `"skipped"` - `"outdated"` - `error: Optional[str]` ### Item Sync Response - `class ItemSyncResponse: …` - `id: str` - `checksum: str` - `chunks_count: Optional[int]` - `created_at: datetime` - `file_size: Optional[float]` - `key: str` - `last_seen_at: datetime` - `namespace: str` - `next_action: Optional[Literal["INDEX", "DELETE"]]` - `"INDEX"` - `"DELETE"` - `source_id: Optional[str]` Identifies which data source this item belongs to. "builtin" for uploaded files, "{type}:{source}" for external sources, null for legacy items. - `status: Literal["queued", "running", "completed", 3 more]` - `"queued"` - `"running"` - `"completed"` - `"error"` - `"skipped"` - `"outdated"` - `error: Optional[str]` ### Item Delete Response - `class ItemDeleteResponse: …` - `key: str` ### Item Logs Response - `List[ItemLogsResponseItem]` - `action: str` - `chunk_count: Optional[int]` - `error_type: Optional[str]` - `file_key: str` - `message: Optional[str]` - `processing_time_ms: Optional[int]` - `timestamp: datetime` ### Item Chunks Response - `List[ItemChunksResponseItem]` - `id: str` - `item: ItemChunksResponseItemItem` - `key: str` - `metadata: Optional[Dict[str, object]]` - `timestamp: Optional[float]` - `text: str` - `end_byte: Optional[float]` - `start_byte: Optional[float]`