# AI Search # Namespaces ## List namespaces `client.aiSearch.namespaces.list(NamespaceListParamsparams, RequestOptionsoptions?): V4PagePaginationArray` **get** `/accounts/{account_id}/ai-search/namespaces` List namespaces in the account, including their descriptions and creation times. ### Parameters - `params: NamespaceListParams` - `account_id: string` Path param - `page?: number` Query param: Page number (1-indexed). - `per_page?: number` Query param: Number of results per page. - `search?: string` Query param: Filter namespaces whose name or description contains this string (case-insensitive). ### Returns - `NamespaceListResponse` - `created_at: string` - `name: string` - `description?: string | null` Optional description for the namespace. Max 256 characters. - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams | null` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `instances_allowed?: Array` Instance IDs exposed through the namespace public endpoint. Empty means nothing is searchable. Every ID must be an existing instance in this namespace, and the list cannot exceed the account's multi-instance search limit. - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const namespaceListResponse of client.aiSearch.namespaces.list({ account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', })) { console.log(namespaceListResponse.public_endpoint_id); } ``` #### Response ```json { "result": [ { "created_at": "2019-12-27T18:11:19.117Z", "name": "production", "description": "Production environment", "public_endpoint_id": "public_endpoint_id", "public_endpoint_params": { "authorized_hosts": [ "string" ], "chat_completions_endpoint": { "disabled": true }, "custom_domains": [ "search.example.com" ], "default_domain_enabled": true, "enabled": true, "instances_allowed": [ "docs", "blog" ], "mcp": { "description": "description", "disabled": true }, "rate_limit": { "period_ms": 60000, "requests": 1, "technique": "fixed" }, "search_endpoint": { "disabled": true } } } ], "result_info": { "count": 0, "page": 0, "per_page": 0, "total_count": 0 }, "success": true } ``` ## Create a namespace `client.aiSearch.namespaces.create(NamespaceCreateParamsparams, RequestOptionsoptions?): NamespaceCreateResponse` **post** `/accounts/{account_id}/ai-search/namespaces` Create a namespace for organizing AI Search instances. ### Parameters - `params: NamespaceCreateParams` - `account_id: string` Path param - `name: string` Body param - `description?: string | null` Body param: Optional description for the namespace. Max 256 characters. - `public_endpoint_params?: PublicEndpointParams` Body param - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `instances_allowed?: Array` Instance IDs exposed through the namespace public endpoint. Empty means nothing is searchable. Every ID must be an existing instance in this namespace, and the list cannot exceed the account's multi-instance search limit. - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint ### Returns - `NamespaceCreateResponse` - `created_at: string` - `name: string` - `description?: string | null` Optional description for the namespace. Max 256 characters. - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams | null` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `instances_allowed?: Array` Instance IDs exposed through the namespace public endpoint. Empty means nothing is searchable. Every ID must be an existing instance in this namespace, and the list cannot exceed the account's multi-instance search limit. - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const namespace = await client.aiSearch.namespaces.create({ account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', name: 'name', }); console.log(namespace.public_endpoint_id); ``` #### Response ```json { "result": { "created_at": "2019-12-27T18:11:19.117Z", "name": "production", "description": "Production environment", "public_endpoint_id": "public_endpoint_id", "public_endpoint_params": { "authorized_hosts": [ "string" ], "chat_completions_endpoint": { "disabled": true }, "custom_domains": [ "search.example.com" ], "default_domain_enabled": true, "enabled": true, "instances_allowed": [ "docs", "blog" ], "mcp": { "description": "description", "disabled": true }, "rate_limit": { "period_ms": 60000, "requests": 1, "technique": "fixed" }, "search_endpoint": { "disabled": true } } }, "success": true } ``` ## Get a namespace `client.aiSearch.namespaces.read(stringname, NamespaceReadParamsparams, RequestOptionsoptions?): NamespaceReadResponse` **get** `/accounts/{account_id}/ai-search/namespaces/{name}` Retrieve a namespace and its description. ### Parameters - `name: string` - `params: NamespaceReadParams` - `account_id: string` ### Returns - `NamespaceReadResponse` - `created_at: string` - `name: string` - `description?: string | null` Optional description for the namespace. Max 256 characters. - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams | null` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `instances_allowed?: Array` Instance IDs exposed through the namespace public endpoint. Empty means nothing is searchable. Every ID must be an existing instance in this namespace, and the list cannot exceed the account's multi-instance search limit. - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiSearch.namespaces.read('production', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', }); console.log(response.public_endpoint_id); ``` #### Response ```json { "result": { "created_at": "2019-12-27T18:11:19.117Z", "name": "production", "description": "Production environment", "public_endpoint_id": "public_endpoint_id", "public_endpoint_params": { "authorized_hosts": [ "string" ], "chat_completions_endpoint": { "disabled": true }, "custom_domains": [ "search.example.com" ], "default_domain_enabled": true, "enabled": true, "instances_allowed": [ "docs", "blog" ], "mcp": { "description": "description", "disabled": true }, "rate_limit": { "period_ms": 60000, "requests": 1, "technique": "fixed" }, "search_endpoint": { "disabled": true } } }, "success": true } ``` ## Update a namespace `client.aiSearch.namespaces.update(stringname, NamespaceUpdateParamsparams, RequestOptionsoptions?): NamespaceUpdateResponse` **put** `/accounts/{account_id}/ai-search/namespaces/{name}` Update the description and/or the public endpoint configuration of an existing namespace. The default namespace's description cannot be modified, but its public endpoint can. ### Parameters - `name: string` - `params: NamespaceUpdateParams` - `account_id: string` Path param - `description?: string | null` Body param: Optional description for the namespace. Max 256 characters. - `public_endpoint_params?: PublicEndpointParams | null` Body param - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `instances_allowed?: Array` Instance IDs exposed through the namespace public endpoint. Empty means nothing is searchable. Every ID must be an existing instance in this namespace, and the list cannot exceed the account's multi-instance search limit. - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint ### Returns - `NamespaceUpdateResponse` - `created_at: string` - `name: string` - `description?: string | null` Optional description for the namespace. Max 256 characters. - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams | null` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `instances_allowed?: Array` Instance IDs exposed through the namespace public endpoint. Empty means nothing is searchable. Every ID must be an existing instance in this namespace, and the list cannot exceed the account's multi-instance search limit. - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const namespace = await client.aiSearch.namespaces.update('production', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', }); console.log(namespace.public_endpoint_id); ``` #### Response ```json { "result": { "created_at": "2019-12-27T18:11:19.117Z", "name": "production", "description": "Production environment", "public_endpoint_id": "public_endpoint_id", "public_endpoint_params": { "authorized_hosts": [ "string" ], "chat_completions_endpoint": { "disabled": true }, "custom_domains": [ "search.example.com" ], "default_domain_enabled": true, "enabled": true, "instances_allowed": [ "docs", "blog" ], "mcp": { "description": "description", "disabled": true }, "rate_limit": { "period_ms": 60000, "requests": 1, "technique": "fixed" }, "search_endpoint": { "disabled": true } } }, "success": true } ``` ## Delete a namespace `client.aiSearch.namespaces.delete(stringname, NamespaceDeleteParamsparams, RequestOptionsoptions?): NamespaceDeleteResponse` **delete** `/accounts/{account_id}/ai-search/namespaces/{name}` Permanently delete a namespace. The namespace must be empty (no instances), and the default namespace cannot be deleted. ### Parameters - `name: string` - `params: NamespaceDeleteParams` - `account_id: string` ### Returns - `NamespaceDeleteResponse = unknown` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const namespace = await client.aiSearch.namespaces.delete('production', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', }); console.log(namespace); ``` #### Response ```json { "result": {}, "success": true } ``` ## Multi-Instance Search `client.aiSearch.namespaces.search(stringname, NamespaceSearchParamsparams, RequestOptionsoptions?): NamespaceSearchResponse` **post** `/accounts/{account_id}/ai-search/namespaces/{name}/search` Performs a semantic search query against multiple AI Search instances in parallel, merging the retrieved results into a single ranked response. ### Parameters - `name: string` - `params: NamespaceSearchParams` - `account_id: string` Path param - `ai_search_options: AISearchOptions` Body param - `instance_ids: Array` - `cache?: Cache` - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `enabled?: boolean` - `query_rewrite?: QueryRewrite` - `enabled?: boolean` - `model?: "@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?: string` - `reranking?: Reranking` - `enabled?: boolean` - `match_threshold?: number` - `model?: "@cf/baai/bge-reranker-base" | ""` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval?: Retrieval` - `boost_by?: Array` 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: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: number` - `filters?: Record` - `fusion_method?: "max" | "rrf"` - `"max"` - `"rrf"` - `keyword_match_mode?: "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. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'. - `"and"` - `"or"` - `match_threshold?: number` - `max_num_results?: number` - `retrieval_type?: "vector" | "keyword" | "hybrid"` - `"vector"` - `"keyword"` - `"hybrid"` - `return_on_failure?: boolean` - `messages?: Array` Body param: OpenAI-compatible message array. For multimodal queries, set the last user message's `content` to an array of typed parts: `[{type:'text', text:'…'}, {type:'image_url', image_url:{url:'…'}}]`. Image inputs require the RAG's embedding_model to declare 'image' in supported_modalities. - `content: string | Array | null` - `string` - `Array` - `UnionMember0` - `text: string` - `type: "text"` - `"text"` - `UnionMember1` - `image_url: ImageURL` - `url: string` - `type: "image_url"` - `"image_url"` - `UnionMember2` - `file: File` - `filename: string` - `file_data?: string` - `file_id?: string` - `type: "file"` - `"file"` - `role: "system" | "developer" | "user" | 2 more` - `"system"` - `"developer"` - `"user"` - `"assistant"` - `"tool"` - `query?: string` Body param: A simple text query string. Alternative to 'messages' — provide either this or 'messages', not both. ### Returns - `NamespaceSearchResponse` - `chunks: Array` - `id: string` - `instance_id: string` - `score: number` - `text: string` - `type: string` - `item?: Item` - `key: string` - `metadata?: Record` - `timestamp?: number` - `scoring_details?: ScoringDetails` - `fusion_method?: "rrf" | "max"` - `"rrf"` - `"max"` - `keyword_rank?: number` - `keyword_score?: number` - `reranking_score?: number` - `vector_rank?: number` - `vector_score?: number` - `query_kind: "text" | "image" | "multimodal"` - `"text"` - `"image"` - `"multimodal"` - `errors?: Array` - `instance_id: string` - `message: string` - `search_query?: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiSearch.namespaces.search('my-namespace', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', ai_search_options: { instance_ids: ['my-ai-search'] }, }); console.log(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 } } ], "query_kind": "text", "errors": [ { "instance_id": "instance_id", "message": "message" } ], "search_query": "search_query" }, "success": true } ``` ## Multi-Instance Chat Completions `client.aiSearch.namespaces.chatCompletions(stringname, NamespaceChatCompletionsParamsparams, RequestOptionsoptions?): 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 - `name: string` - `params: NamespaceChatCompletionsParams` - `account_id: string` Path param - `ai_search_options: AISearchOptions` Body param - `instance_ids: Array` - `cache?: Cache` - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `enabled?: boolean` - `query_rewrite?: QueryRewrite` - `enabled?: boolean` - `model?: "@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?: string` - `reranking?: Reranking` - `enabled?: boolean` - `match_threshold?: number` - `model?: "@cf/baai/bge-reranker-base" | ""` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval?: Retrieval` - `boost_by?: Array` 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: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: number` - `filters?: Record` - `fusion_method?: "max" | "rrf"` - `"max"` - `"rrf"` - `keyword_match_mode?: "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. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'. - `"and"` - `"or"` - `match_threshold?: number` - `max_num_results?: number` - `retrieval_type?: "vector" | "keyword" | "hybrid"` - `"vector"` - `"keyword"` - `"hybrid"` - `return_on_failure?: boolean` - `messages: Array` Body param - `content: string | Array | null` - `string` - `Array` - `UnionMember0` - `text: string` - `type: "text"` - `"text"` - `UnionMember1` - `image_url: ImageURL` - `url: string` - `type: "image_url"` - `"image_url"` - `UnionMember2` - `file: File` - `filename: string` - `file_data?: string` - `file_id?: string` - `type: "file"` - `"file"` - `role: "system" | "developer" | "user" | 2 more` - `"system"` - `"developer"` - `"user"` - `"assistant"` - `"tool"` - `model?: "@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` Body param - `"@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?: boolean` Body param ### Returns - `NamespaceChatCompletionsResponse` - `choices: Array` - `message: Message` - `content: string | Array | null` - `string` - `Array` - `UnionMember0` - `text: string` - `type: "text"` - `"text"` - `UnionMember1` - `image_url: ImageURL` - `url: string` - `type: "image_url"` - `"image_url"` - `UnionMember2` - `file: File` - `filename: string` - `file_data?: string` - `file_id?: string` - `type: "file"` - `"file"` - `role: "system" | "developer" | "user" | 2 more` - `"system"` - `"developer"` - `"user"` - `"assistant"` - `"tool"` - `index?: number` - `chunks: Array` - `id: string` - `instance_id: string` - `score: number` - `text: string` - `type: string` - `item?: Item` - `key: string` - `metadata?: Record` - `timestamp?: number` - `scoring_details?: ScoringDetails` - `fusion_method?: "rrf" | "max"` - `"rrf"` - `"max"` - `keyword_rank?: number` - `keyword_score?: number` - `reranking_score?: number` - `vector_rank?: number` - `vector_score?: number` - `id?: string` - `errors?: Array` - `instance_id: string` - `message: string` - `model?: string` - `object?: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiSearch.namespaces.chatCompletions('my-namespace', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', ai_search_options: { instance_ids: ['my-ai-search'] }, messages: [{ content: 'string', role: 'system' }], }); console.log(response.id); ``` #### Response ```json { "choices": [ { "message": { "content": "string", "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 - `NamespaceListResponse` - `created_at: string` - `name: string` - `description?: string | null` Optional description for the namespace. Max 256 characters. - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams | null` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `instances_allowed?: Array` Instance IDs exposed through the namespace public endpoint. Empty means nothing is searchable. Every ID must be an existing instance in this namespace, and the list cannot exceed the account's multi-instance search limit. - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint ### Namespace Create Response - `NamespaceCreateResponse` - `created_at: string` - `name: string` - `description?: string | null` Optional description for the namespace. Max 256 characters. - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams | null` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `instances_allowed?: Array` Instance IDs exposed through the namespace public endpoint. Empty means nothing is searchable. Every ID must be an existing instance in this namespace, and the list cannot exceed the account's multi-instance search limit. - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint ### Namespace Read Response - `NamespaceReadResponse` - `created_at: string` - `name: string` - `description?: string | null` Optional description for the namespace. Max 256 characters. - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams | null` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `instances_allowed?: Array` Instance IDs exposed through the namespace public endpoint. Empty means nothing is searchable. Every ID must be an existing instance in this namespace, and the list cannot exceed the account's multi-instance search limit. - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint ### Namespace Update Response - `NamespaceUpdateResponse` - `created_at: string` - `name: string` - `description?: string | null` Optional description for the namespace. Max 256 characters. - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams | null` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `instances_allowed?: Array` Instance IDs exposed through the namespace public endpoint. Empty means nothing is searchable. Every ID must be an existing instance in this namespace, and the list cannot exceed the account's multi-instance search limit. - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint ### Namespace Delete Response - `NamespaceDeleteResponse = unknown` ### Namespace Search Response - `NamespaceSearchResponse` - `chunks: Array` - `id: string` - `instance_id: string` - `score: number` - `text: string` - `type: string` - `item?: Item` - `key: string` - `metadata?: Record` - `timestamp?: number` - `scoring_details?: ScoringDetails` - `fusion_method?: "rrf" | "max"` - `"rrf"` - `"max"` - `keyword_rank?: number` - `keyword_score?: number` - `reranking_score?: number` - `vector_rank?: number` - `vector_score?: number` - `query_kind: "text" | "image" | "multimodal"` - `"text"` - `"image"` - `"multimodal"` - `errors?: Array` - `instance_id: string` - `message: string` - `search_query?: string` ### Namespace Chat Completions Response - `NamespaceChatCompletionsResponse` - `choices: Array` - `message: Message` - `content: string | Array | null` - `string` - `Array` - `UnionMember0` - `text: string` - `type: "text"` - `"text"` - `UnionMember1` - `image_url: ImageURL` - `url: string` - `type: "image_url"` - `"image_url"` - `UnionMember2` - `file: File` - `filename: string` - `file_data?: string` - `file_id?: string` - `type: "file"` - `"file"` - `role: "system" | "developer" | "user" | 2 more` - `"system"` - `"developer"` - `"user"` - `"assistant"` - `"tool"` - `index?: number` - `chunks: Array` - `id: string` - `instance_id: string` - `score: number` - `text: string` - `type: string` - `item?: Item` - `key: string` - `metadata?: Record` - `timestamp?: number` - `scoring_details?: ScoringDetails` - `fusion_method?: "rrf" | "max"` - `"rrf"` - `"max"` - `keyword_rank?: number` - `keyword_score?: number` - `reranking_score?: number` - `vector_rank?: number` - `vector_score?: number` - `id?: string` - `errors?: Array` - `instance_id: string` - `message: string` - `model?: string` - `object?: string` # Instances ## List AI Search instances. `client.aiSearch.namespaces.instances.list(stringname, InstanceListParamsparams, RequestOptionsoptions?): V4PagePaginationArray` **get** `/accounts/{account_id}/ai-search/namespaces/{name}/instances` List all AI Search instances in the account. ### Parameters - `name: string` - `params: InstanceListParams` - `account_id: string` Path param - `namespace?: string` Query param: Filter by namespace. - `order_by?: "created_at"` Query param: Field to order results by. - `"created_at"` - `order_by_direction?: "asc" | "desc"` Query param: Order direction. - `"asc"` - `"desc"` - `page?: number` Query param: Page number (1-indexed). - `per_page?: number` Query param: Number of results per page. - `search?: string` Query param: Filter instances whose id contains this string (case-insensitive). ### Returns - `InstanceListResponse` - `id: string` - `ai_gateway_id: string | null` - `ai_search_model: string | null` - `cache: boolean` - `cache_threshold: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes" | null` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl: 600 | 1800 | 3600 | 7 more` - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk: boolean` - `chunk_overlap: number | null` - `chunk_size: number | null` - `created_at: string` - `created_by: string | null` - `custom_metadata: Array | null` - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model: string | null` - `enable: boolean` - `engine_version: number` - `fusion_method: "max" | "rrf"` - `"max"` - `"rrf"` - `hybrid_search_enabled: boolean` - `index_method: IndexMethod` - `keyword: boolean` - `vector: boolean` - `indexing_options: IndexingOptions | null` - `keyword_tokenizer?: "porter" | "trigram"` - `"porter"` - `"trigram"` - `last_activity: string | null` - `max_num_results: number | null` - `metadata: Metadata | null` - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `modified_at: string` - `modified_by: string | null` - `namespace: string` - `paused: boolean` - `public_endpoint_id: string | null` - `public_endpoint_params: PublicEndpointParams | null` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` - `custom_domains?: Array | null` - `default_domain_enabled?: boolean` - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` - `reranking: boolean` - `reranking_model: string | null` - `retrieval_options: RetrievalOptions | null` - `boost_by?: Array` - `field: string` - `dataType?: "number" | "datetime" | "text" | "boolean"` - `"number"` - `"datetime"` - `"text"` - `"boolean"` - `direction?: "asc" | "desc" | "exists" | "not_exists"` - `"asc"` - `"desc"` - `"exists"` - `"not_exists"` - `keyword_match_mode?: "and" | "or"` - `"and"` - `"or"` - `rewrite_model: string | null` - `rewrite_query: boolean` - `score_threshold: number | null` - `source: string | null` - `source_params: SourceParams | null` - `exclude_items?: Array` - `include_items?: Array` - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` - `depth?: number` - `include_external_links?: boolean` - `include_subdomains?: boolean` - `limit?: number` Maximum number of pages to crawl. New values are capped at 100000; instances configured before that cap may report a higher stored value, which the crawler clamps at run time. - `max_age?: number` - `source?: "all" | "sitemaps" | "links"` - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` - `path: string` - `selector: string` - `include_headers?: Record` - `include_images?: boolean` - `specific_sitemaps?: Array` - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` - `"sitemap"` - `"discover"` - `status: string` - `summarization: boolean` - `summarization_model: string | null` - `sync_interval: 900 | 1800 | 3600 | 5 more` - `900` - `1800` - `3600` - `7200` - `14400` - `21600` - `43200` - `86400` - `system_prompt_ai_search: string | null` - `system_prompt_index_summarization: string | null` - `system_prompt_rewrite_query: string | null` - `token_id: string | null` - `type: "r2" | "web-crawler" | null` - `"r2"` - `"web-crawler"` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const instanceListResponse of client.aiSearch.namespaces.instances.list('my-namespace', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', })) { console.log(instanceListResponse.id); } ``` #### Response ```json { "result": [ { "id": "id", "ai_gateway_id": "ai_gateway_id", "ai_search_model": "ai_search_model", "cache": true, "cache_threshold": "super_strict_match", "cache_ttl": 600, "chunk": true, "chunk_overlap": 0, "chunk_size": 0, "created_at": "2019-12-27T18:11:19.117Z", "created_by": "created_by", "custom_metadata": [ { "data_type": "text", "field_name": "field_name" } ], "embedding_model": "embedding_model", "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": 0, "metadata": { "created_from_aisearch_wizard": true, "worker_domain": "worker_domain" }, "modified_at": "2019-12-27T18:11:19.117Z", "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 }, "custom_domains": [ "x" ], "default_domain_enabled": 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": "reranking_model", "retrieval_options": { "boost_by": [ { "field": "x", "dataType": "number", "direction": "asc" } ], "keyword_match_mode": "and" }, "rewrite_model": "rewrite_model", "rewrite_query": true, "score_threshold": 0, "source": "source", "source_params": { "exclude_items": [ "string" ], "include_items": [ "string" ], "prefix": "prefix", "r2_jurisdiction": "r2_jurisdiction", "web_crawler": { "discover_options": { "depth": 1, "include_external_links": true, "include_subdomains": true, "limit": 1, "max_age": 0, "source": "all" }, "parse_options": { "content_selector": [ { "path": "x", "selector": "x" } ], "include_headers": { "foo": "string" }, "include_images": true, "specific_sitemaps": [ "https://example.com" ], "use_browser_rendering": true }, "parse_type": "sitemap" } }, "status": "status", "summarization": true, "summarization_model": "summarization_model", "sync_interval": 900, "system_prompt_ai_search": "system_prompt_ai_search", "system_prompt_index_summarization": "system_prompt_index_summarization", "system_prompt_rewrite_query": "system_prompt_rewrite_query", "token_id": "token_id", "type": "r2" } ], "result_info": { "count": 0, "page": 0, "per_page": 0, "total_count": 0 }, "success": true } ``` ## Create an AI Search instance. `client.aiSearch.namespaces.instances.create(stringname, InstanceCreateParamsparams, RequestOptionsoptions?): InstanceCreateResponse` **post** `/accounts/{account_id}/ai-search/namespaces/{name}/instances` Create a new AI Search instance with the given configuration. ### Parameters - `name: string` - `params: InstanceCreateParams` - `account_id: string` Path param - `id: string` Body param: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `ai_gateway_id?: string | null` Body param - `ai_search_model?: "@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 | null` Body param - `"@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?: boolean` Body param - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` Body param - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl?: 600 | 1800 | 3600 | 7 more` Body param: Cache entry TTL in seconds. Allowed values: 600 (10min), 1800 (30min), 3600 (1h), 7200 (2h), 21600 (6h), 43200 (12h), 86400 (24h), 172800 (48h), 259200 (72h), 518400 (6d). - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk?: boolean` Body param - `chunk_overlap?: number` Body param - `chunk_size?: number` Body param - `custom_metadata?: Array` Body param - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model?: "@cf/qwen/qwen3-embedding-0.6b" | "@cf/qwen/qwen3-vl-embedding-2b" | "@cf/baai/bge-m3" | 8 more | null` Body param - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/qwen/qwen3-vl-embedding-2b"` - `"@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"` - `"google-ai-studio/gemini-embedding-2"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `fusion_method?: "max" | "rrf"` Body param - `"max"` - `"rrf"` - `hybrid_search_enabled?: boolean` Body param: Deprecated — use index_method instead. - `index_method?: IndexMethod` Body param: Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: boolean` Enable keyword (BM25) storage backend. - `vector: boolean` Enable vector (embedding) storage backend. - `indexing_options?: IndexingOptions | null` Body param - `keyword_tokenizer?: "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?: number` Body param - `metadata?: Metadata` Body param - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `public_endpoint_params?: PublicEndpointParams` Body param - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint - `reranking?: boolean` Body param - `reranking_model?: "@cf/baai/bge-reranker-base" | "" | null` Body param - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options?: RetrievalOptions | null` Body param - `boost_by?: Array` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric/datetime fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: "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. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'. - `"and"` - `"or"` - `rewrite_model?: "@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 | null` Body param - `"@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?: boolean` Body param - `score_threshold?: number` Body param - `source?: string | null` Body param - `source_params?: SourceParams | null` Body param - `exclude_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `include_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` Options for parse_type 'discover', where Browser Run discovers URLs by link following and sitemaps. Ignored for 'sitemap'. - `depth?: number` Maximum link-follow depth from the seed URL. - `include_external_links?: boolean` Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own. - `include_subdomains?: boolean` Follow links to subdomains of the source host. - `limit?: number` Maximum number of pages to crawl (1-100000). - `max_age?: number` Maximum content age in seconds to accept (0–604800). - `source?: "all" | "sitemaps" | "links"` Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both. - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` 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. Omit the field to disable content selection — empty arrays are rejected. - `path: string` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: string` CSS selector to extract content from pages matching the path pattern. Must not contain disallowed characters (;, `, $, {, }, ). Must target a single element; if multiple elements match, the selector is ignored and the full page is used. - `include_headers?: Record` Up to 5 custom HTTP headers sent with each crawl request. Names must be RFC-7230 token characters (no spaces, colons, or control characters); values must be HTAB + printable ASCII (no CR/LF). - `include_images?: boolean` - `specific_sitemaps?: Array` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account. - `"sitemap"` - `"discover"` - `sync_interval?: 900 | 1800 | 3600 | 5 more` Body param: 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?: string` Body param - `type?: "r2" | "web-crawler" | null` Body param - `"r2"` - `"web-crawler"` ### Returns - `InstanceCreateResponse` - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: string` - `modified_at: string` - `ai_gateway_id?: string | null` - `ai_search_model?: "@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 | null` - `"@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?: boolean` - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl?: 600 | 1800 | 3600 | 7 more` Cache entry TTL in seconds. Allowed values: 600 (10min), 1800 (30min), 3600 (1h), 7200 (2h), 21600 (6h), 43200 (12h), 86400 (24h), 172800 (48h), 259200 (72h), 518400 (6d). - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk_overlap?: number` - `chunk_size?: number` - `created_by?: string | null` - `custom_metadata?: Array` - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model?: "@cf/qwen/qwen3-embedding-0.6b" | "@cf/qwen/qwen3-vl-embedding-2b" | "@cf/baai/bge-m3" | 8 more | null` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/qwen/qwen3-vl-embedding-2b"` - `"@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"` - `"google-ai-studio/gemini-embedding-2"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable?: boolean` - `engine_version?: number` - `fusion_method?: "max" | "rrf"` - `"max"` - `"rrf"` - `hybrid_search_enabled?: boolean` Deprecated — use index_method instead. - `index_method?: IndexMethod` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: boolean` Enable keyword (BM25) storage backend. - `vector: boolean` Enable vector (embedding) storage backend. - `indexing_options?: IndexingOptions | null` - `keyword_tokenizer?: "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?: string | null` - `max_num_results?: number` - `metadata?: Metadata` - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `modified_by?: string | null` - `namespace?: string | null` - `paused?: boolean` - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint - `reranking?: boolean` - `reranking_model?: "@cf/baai/bge-reranker-base" | "" | null` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options?: RetrievalOptions | null` - `boost_by?: Array` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric/datetime fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: "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. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'. - `"and"` - `"or"` - `rewrite_model?: "@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 | null` - `"@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?: boolean` - `score_threshold?: number` - `source?: string | null` - `source_params?: SourceParams | null` - `exclude_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `include_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` Options for parse_type 'discover', where Browser Run discovers URLs by link following and sitemaps. Ignored for 'sitemap'. - `depth?: number` Maximum link-follow depth from the seed URL. - `include_external_links?: boolean` Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own. - `include_subdomains?: boolean` Follow links to subdomains of the source host. - `limit?: number` Maximum number of pages to crawl (1-100000). - `max_age?: number` Maximum content age in seconds to accept (0–604800). - `source?: "all" | "sitemaps" | "links"` Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both. - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` 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. Omit the field to disable content selection — empty arrays are rejected. - `path: string` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: string` CSS selector to extract content from pages matching the path pattern. Must not contain disallowed characters (;, `, $, {, }, ). Must target a single element; if multiple elements match, the selector is ignored and the full page is used. - `include_headers?: Record` Up to 5 custom HTTP headers sent with each crawl request. Names must be RFC-7230 token characters (no spaces, colons, or control characters); values must be HTAB + printable ASCII (no CR/LF). - `include_images?: boolean` - `specific_sitemaps?: Array` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account. - `"sitemap"` - `"discover"` - `status?: string` - `sync_interval?: 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?: string` - `type?: "r2" | "web-crawler" | null` - `"r2"` - `"web-crawler"` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const instance = await client.aiSearch.namespaces.instances.create('my-namespace', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', id: 'my-ai-search', }); console.log(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", "cache_ttl": 600, "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, "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 }, "custom_domains": [ "search.example.com" ], "default_domain_enabled": 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": { "discover_options": { "depth": 5, "include_external_links": false, "include_subdomains": false, "limit": 10000, "max_age": 86400, "source": "all" }, "parse_options": { "content_selector": [ { "path": "**/blog/**", "selector": "article div.post-body" }, { "path": "**/docs/**", "selector": "main" } ], "include_headers": { "cache-control": "no-cache, no-store" }, "include_images": true, "specific_sitemaps": [ "https://example.com/sitemap.xml", "https://example.com/blog-sitemap.xml" ], "use_browser_rendering": true }, "parse_type": "sitemap" } }, "status": "status", "sync_interval": 900, "token_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "type": "r2" }, "success": true } ``` ## Get an AI Search instance. `client.aiSearch.namespaces.instances.read(stringid, InstanceReadParamsparams, RequestOptionsoptions?): InstanceReadResponse` **get** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}` Retrieve the configuration and status of an AI Search instance. ### Parameters - `id: string` - `params: InstanceReadParams` - `account_id: string` - `name: string` Namespace name ### Returns - `InstanceReadResponse` - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: string` - `modified_at: string` - `ai_gateway_id?: string | null` - `ai_search_model?: "@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 | null` - `"@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?: boolean` - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl?: 600 | 1800 | 3600 | 7 more` Cache entry TTL in seconds. Allowed values: 600 (10min), 1800 (30min), 3600 (1h), 7200 (2h), 21600 (6h), 43200 (12h), 86400 (24h), 172800 (48h), 259200 (72h), 518400 (6d). - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk_overlap?: number` - `chunk_size?: number` - `created_by?: string | null` - `custom_metadata?: Array` - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model?: "@cf/qwen/qwen3-embedding-0.6b" | "@cf/qwen/qwen3-vl-embedding-2b" | "@cf/baai/bge-m3" | 8 more | null` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/qwen/qwen3-vl-embedding-2b"` - `"@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"` - `"google-ai-studio/gemini-embedding-2"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable?: boolean` - `engine_version?: number` - `fusion_method?: "max" | "rrf"` - `"max"` - `"rrf"` - `hybrid_search_enabled?: boolean` Deprecated — use index_method instead. - `index_method?: IndexMethod` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: boolean` Enable keyword (BM25) storage backend. - `vector: boolean` Enable vector (embedding) storage backend. - `indexing_options?: IndexingOptions | null` - `keyword_tokenizer?: "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?: string | null` - `max_num_results?: number` - `metadata?: Metadata` - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `modified_by?: string | null` - `namespace?: string | null` - `paused?: boolean` - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint - `reranking?: boolean` - `reranking_model?: "@cf/baai/bge-reranker-base" | "" | null` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options?: RetrievalOptions | null` - `boost_by?: Array` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric/datetime fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: "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. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'. - `"and"` - `"or"` - `rewrite_model?: "@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 | null` - `"@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?: boolean` - `score_threshold?: number` - `source?: string | null` - `source_params?: SourceParams | null` - `exclude_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `include_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` Options for parse_type 'discover', where Browser Run discovers URLs by link following and sitemaps. Ignored for 'sitemap'. - `depth?: number` Maximum link-follow depth from the seed URL. - `include_external_links?: boolean` Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own. - `include_subdomains?: boolean` Follow links to subdomains of the source host. - `limit?: number` Maximum number of pages to crawl (1-100000). - `max_age?: number` Maximum content age in seconds to accept (0–604800). - `source?: "all" | "sitemaps" | "links"` Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both. - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` 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. Omit the field to disable content selection — empty arrays are rejected. - `path: string` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: string` CSS selector to extract content from pages matching the path pattern. Must not contain disallowed characters (;, `, $, {, }, ). Must target a single element; if multiple elements match, the selector is ignored and the full page is used. - `include_headers?: Record` Up to 5 custom HTTP headers sent with each crawl request. Names must be RFC-7230 token characters (no spaces, colons, or control characters); values must be HTAB + printable ASCII (no CR/LF). - `include_images?: boolean` - `specific_sitemaps?: Array` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account. - `"sitemap"` - `"discover"` - `status?: string` - `sync_interval?: 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?: string` - `type?: "r2" | "web-crawler" | null` - `"r2"` - `"web-crawler"` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiSearch.namespaces.instances.read('my-ai-search', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', name: 'my-namespace', }); console.log(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", "cache_ttl": 600, "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, "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 }, "custom_domains": [ "search.example.com" ], "default_domain_enabled": 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": { "discover_options": { "depth": 5, "include_external_links": false, "include_subdomains": false, "limit": 10000, "max_age": 86400, "source": "all" }, "parse_options": { "content_selector": [ { "path": "**/blog/**", "selector": "article div.post-body" }, { "path": "**/docs/**", "selector": "main" } ], "include_headers": { "cache-control": "no-cache, no-store" }, "include_images": true, "specific_sitemaps": [ "https://example.com/sitemap.xml", "https://example.com/blog-sitemap.xml" ], "use_browser_rendering": true }, "parse_type": "sitemap" } }, "status": "status", "sync_interval": 900, "token_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "type": "r2" }, "success": true } ``` ## Update an AI Search instance. `client.aiSearch.namespaces.instances.update(stringid, InstanceUpdateParamsparams, RequestOptionsoptions?): InstanceUpdateResponse` **put** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}` Update the configuration of an AI Search instance. ### Parameters - `id: string` - `params: InstanceUpdateParams` - `account_id: string` Path param - `name: string` Path param: Namespace name - `ai_gateway_id?: string | null` Body param - `ai_search_model?: "@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 | null` Body param - `"@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?: boolean` Body param - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` Body param - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl?: 600 | 1800 | 3600 | 7 more` Body param: Cache entry TTL in seconds. Allowed values: 600 (10min), 1800 (30min), 3600 (1h), 7200 (2h), 21600 (6h), 43200 (12h), 86400 (24h), 172800 (48h), 259200 (72h), 518400 (6d). - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk?: boolean` Body param - `chunk_overlap?: number` Body param - `chunk_size?: number` Body param - `custom_metadata?: Array` Body param - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model?: "@cf/qwen/qwen3-embedding-0.6b" | "@cf/qwen/qwen3-vl-embedding-2b" | "@cf/baai/bge-m3" | 8 more | null` Body param - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/qwen/qwen3-vl-embedding-2b"` - `"@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"` - `"google-ai-studio/gemini-embedding-2"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `fusion_method?: "max" | "rrf"` Body param - `"max"` - `"rrf"` - `index_method?: IndexMethod` Body param: Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: boolean` Enable keyword (BM25) storage backend. - `vector: boolean` Enable vector (embedding) storage backend. - `indexing_options?: IndexingOptions | null` Body param - `keyword_tokenizer?: "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?: number` Body param - `metadata?: Metadata` Body param - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `paused?: boolean` Body param - `public_endpoint_params?: PublicEndpointParams` Body param - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint - `reranking?: boolean` Body param - `reranking_model?: "@cf/baai/bge-reranker-base" | "" | null` Body param - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options?: RetrievalOptions | null` Body param - `boost_by?: Array` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric/datetime fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: "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. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'. - `"and"` - `"or"` - `rewrite_model?: "@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 | null` Body param - `"@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?: boolean` Body param - `score_threshold?: number` Body param - `source?: string | null` Body param - `source_params?: SourceParams | null` Body param - `exclude_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `include_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` Options for parse_type 'discover', where Browser Run discovers URLs by link following and sitemaps. Ignored for 'sitemap'. - `depth?: number` Maximum link-follow depth from the seed URL. - `include_external_links?: boolean` Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own. - `include_subdomains?: boolean` Follow links to subdomains of the source host. - `limit?: number` Maximum number of pages to crawl (1-100000). - `max_age?: number` Maximum content age in seconds to accept (0–604800). - `source?: "all" | "sitemaps" | "links"` Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both. - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` 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. Omit the field to disable content selection — empty arrays are rejected. - `path: string` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: string` CSS selector to extract content from pages matching the path pattern. Must not contain disallowed characters (;, `, $, {, }, ). Must target a single element; if multiple elements match, the selector is ignored and the full page is used. - `include_headers?: Record` Up to 5 custom HTTP headers sent with each crawl request. Names must be RFC-7230 token characters (no spaces, colons, or control characters); values must be HTAB + printable ASCII (no CR/LF). - `include_images?: boolean` - `specific_sitemaps?: Array` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account. - `"sitemap"` - `"discover"` - `summarization?: boolean` Body param - `summarization_model?: "@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 | null` Body param - `"@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?: 900 | 1800 | 3600 | 5 more` Body param: 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_ai_search?: string | null` Body param - `system_prompt_index_summarization?: string | null` Body param - `system_prompt_rewrite_query?: string | null` Body param - `token_id?: string` Body param ### Returns - `InstanceUpdateResponse` - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: string` - `modified_at: string` - `ai_gateway_id?: string | null` - `ai_search_model?: "@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 | null` - `"@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?: boolean` - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl?: 600 | 1800 | 3600 | 7 more` Cache entry TTL in seconds. Allowed values: 600 (10min), 1800 (30min), 3600 (1h), 7200 (2h), 21600 (6h), 43200 (12h), 86400 (24h), 172800 (48h), 259200 (72h), 518400 (6d). - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk_overlap?: number` - `chunk_size?: number` - `created_by?: string | null` - `custom_metadata?: Array` - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model?: "@cf/qwen/qwen3-embedding-0.6b" | "@cf/qwen/qwen3-vl-embedding-2b" | "@cf/baai/bge-m3" | 8 more | null` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/qwen/qwen3-vl-embedding-2b"` - `"@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"` - `"google-ai-studio/gemini-embedding-2"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable?: boolean` - `engine_version?: number` - `fusion_method?: "max" | "rrf"` - `"max"` - `"rrf"` - `hybrid_search_enabled?: boolean` Deprecated — use index_method instead. - `index_method?: IndexMethod` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: boolean` Enable keyword (BM25) storage backend. - `vector: boolean` Enable vector (embedding) storage backend. - `indexing_options?: IndexingOptions | null` - `keyword_tokenizer?: "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?: string | null` - `max_num_results?: number` - `metadata?: Metadata` - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `modified_by?: string | null` - `namespace?: string | null` - `paused?: boolean` - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint - `reranking?: boolean` - `reranking_model?: "@cf/baai/bge-reranker-base" | "" | null` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options?: RetrievalOptions | null` - `boost_by?: Array` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric/datetime fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: "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. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'. - `"and"` - `"or"` - `rewrite_model?: "@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 | null` - `"@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?: boolean` - `score_threshold?: number` - `source?: string | null` - `source_params?: SourceParams | null` - `exclude_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `include_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` Options for parse_type 'discover', where Browser Run discovers URLs by link following and sitemaps. Ignored for 'sitemap'. - `depth?: number` Maximum link-follow depth from the seed URL. - `include_external_links?: boolean` Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own. - `include_subdomains?: boolean` Follow links to subdomains of the source host. - `limit?: number` Maximum number of pages to crawl (1-100000). - `max_age?: number` Maximum content age in seconds to accept (0–604800). - `source?: "all" | "sitemaps" | "links"` Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both. - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` 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. Omit the field to disable content selection — empty arrays are rejected. - `path: string` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: string` CSS selector to extract content from pages matching the path pattern. Must not contain disallowed characters (;, `, $, {, }, ). Must target a single element; if multiple elements match, the selector is ignored and the full page is used. - `include_headers?: Record` Up to 5 custom HTTP headers sent with each crawl request. Names must be RFC-7230 token characters (no spaces, colons, or control characters); values must be HTAB + printable ASCII (no CR/LF). - `include_images?: boolean` - `specific_sitemaps?: Array` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account. - `"sitemap"` - `"discover"` - `status?: string` - `sync_interval?: 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?: string` - `type?: "r2" | "web-crawler" | null` - `"r2"` - `"web-crawler"` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const instance = await client.aiSearch.namespaces.instances.update('my-ai-search', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', name: 'my-namespace', }); console.log(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", "cache_ttl": 600, "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, "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 }, "custom_domains": [ "search.example.com" ], "default_domain_enabled": 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": { "discover_options": { "depth": 5, "include_external_links": false, "include_subdomains": false, "limit": 10000, "max_age": 86400, "source": "all" }, "parse_options": { "content_selector": [ { "path": "**/blog/**", "selector": "article div.post-body" }, { "path": "**/docs/**", "selector": "main" } ], "include_headers": { "cache-control": "no-cache, no-store" }, "include_images": true, "specific_sitemaps": [ "https://example.com/sitemap.xml", "https://example.com/blog-sitemap.xml" ], "use_browser_rendering": true }, "parse_type": "sitemap" } }, "status": "status", "sync_interval": 900, "token_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "type": "r2" }, "success": true } ``` ## Delete an AI Search instance. `client.aiSearch.namespaces.instances.delete(stringid, InstanceDeleteParamsparams, RequestOptionsoptions?): InstanceDeleteResponse` **delete** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}` Permanently delete an AI Search instance and all its indexed data. ### Parameters - `id: string` - `params: InstanceDeleteParams` - `account_id: string` - `name: string` Namespace name ### Returns - `InstanceDeleteResponse` - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: string` - `modified_at: string` - `ai_gateway_id?: string | null` - `ai_search_model?: "@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 | null` - `"@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?: boolean` - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl?: 600 | 1800 | 3600 | 7 more` Cache entry TTL in seconds. Allowed values: 600 (10min), 1800 (30min), 3600 (1h), 7200 (2h), 21600 (6h), 43200 (12h), 86400 (24h), 172800 (48h), 259200 (72h), 518400 (6d). - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk_overlap?: number` - `chunk_size?: number` - `created_by?: string | null` - `custom_metadata?: Array` - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model?: "@cf/qwen/qwen3-embedding-0.6b" | "@cf/qwen/qwen3-vl-embedding-2b" | "@cf/baai/bge-m3" | 8 more | null` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/qwen/qwen3-vl-embedding-2b"` - `"@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"` - `"google-ai-studio/gemini-embedding-2"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable?: boolean` - `engine_version?: number` - `fusion_method?: "max" | "rrf"` - `"max"` - `"rrf"` - `hybrid_search_enabled?: boolean` Deprecated — use index_method instead. - `index_method?: IndexMethod` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: boolean` Enable keyword (BM25) storage backend. - `vector: boolean` Enable vector (embedding) storage backend. - `indexing_options?: IndexingOptions | null` - `keyword_tokenizer?: "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?: string | null` - `max_num_results?: number` - `metadata?: Metadata` - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `modified_by?: string | null` - `namespace?: string | null` - `paused?: boolean` - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint - `reranking?: boolean` - `reranking_model?: "@cf/baai/bge-reranker-base" | "" | null` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options?: RetrievalOptions | null` - `boost_by?: Array` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric/datetime fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: "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. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'. - `"and"` - `"or"` - `rewrite_model?: "@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 | null` - `"@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?: boolean` - `score_threshold?: number` - `source?: string | null` - `source_params?: SourceParams | null` - `exclude_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `include_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` Options for parse_type 'discover', where Browser Run discovers URLs by link following and sitemaps. Ignored for 'sitemap'. - `depth?: number` Maximum link-follow depth from the seed URL. - `include_external_links?: boolean` Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own. - `include_subdomains?: boolean` Follow links to subdomains of the source host. - `limit?: number` Maximum number of pages to crawl (1-100000). - `max_age?: number` Maximum content age in seconds to accept (0–604800). - `source?: "all" | "sitemaps" | "links"` Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both. - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` 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. Omit the field to disable content selection — empty arrays are rejected. - `path: string` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: string` CSS selector to extract content from pages matching the path pattern. Must not contain disallowed characters (;, `, $, {, }, ). Must target a single element; if multiple elements match, the selector is ignored and the full page is used. - `include_headers?: Record` Up to 5 custom HTTP headers sent with each crawl request. Names must be RFC-7230 token characters (no spaces, colons, or control characters); values must be HTAB + printable ASCII (no CR/LF). - `include_images?: boolean` - `specific_sitemaps?: Array` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account. - `"sitemap"` - `"discover"` - `status?: string` - `sync_interval?: 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?: string` - `type?: "r2" | "web-crawler" | null` - `"r2"` - `"web-crawler"` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const instance = await client.aiSearch.namespaces.instances.delete('my-ai-search', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', name: 'my-namespace', }); console.log(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", "cache_ttl": 600, "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, "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 }, "custom_domains": [ "search.example.com" ], "default_domain_enabled": 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": { "discover_options": { "depth": 5, "include_external_links": false, "include_subdomains": false, "limit": 10000, "max_age": 86400, "source": "all" }, "parse_options": { "content_selector": [ { "path": "**/blog/**", "selector": "article div.post-body" }, { "path": "**/docs/**", "selector": "main" } ], "include_headers": { "cache-control": "no-cache, no-store" }, "include_images": true, "specific_sitemaps": [ "https://example.com/sitemap.xml", "https://example.com/blog-sitemap.xml" ], "use_browser_rendering": true }, "parse_type": "sitemap" } }, "status": "status", "sync_interval": 900, "token_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "type": "r2" }, "success": true } ``` ## Get instance statistics. `client.aiSearch.namespaces.instances.stats(stringid, InstanceStatsParamsparams, RequestOptionsoptions?): InstanceStatsResponse` **get** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/stats` Retrieve usage and indexing statistics for an AI Search instance. ### Parameters - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `params: InstanceStatsParams` - `account_id: string` - `name: string` Namespace name ### Returns - `InstanceStatsResponse` - `completed?: number` - `degraded?: boolean` True when status counts are unavailable (e.g. legacy stats query exceeded D1 statement-size limit). Counts are omitted in this case. - `engine?: Engine` Engine-specific metadata. Present only for managed (v3) instances. - `r2?: R2` R2 bucket storage usage in bytes. - `metadataSizeBytes: number` - `objectCount: number` - `payloadSizeBytes: number` - `vectorize?: Vectorize` Vectorize index metadata (dimensions, vector count). - `dimensions: number` - `vectorsCount: number` - `error?: number` - `file_embed_errors?: Record` - `index_source_errors?: Record` - `last_activity?: string` - `outdated?: number` - `queued?: number` - `running?: number` - `skipped?: number` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiSearch.namespaces.instances.stats('my-ai-search', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', name: 'my-namespace', }); console.log(response.completed); ``` #### Response ```json { "result": { "completed": 0, "degraded": true, "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 `client.aiSearch.namespaces.instances.search(stringid, InstanceSearchParamsparams, RequestOptionsoptions?): 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 - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `params: InstanceSearchParams` - `account_id: string` Path param - `name: string` Path param: Namespace name - `ai_search_options?: AISearchOptions` Body param - `cache?: Cache` - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `enabled?: boolean` - `query_rewrite?: QueryRewrite` - `enabled?: boolean` - `model?: "@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?: string` - `reranking?: Reranking` - `enabled?: boolean` - `match_threshold?: number` - `model?: "@cf/baai/bge-reranker-base" | ""` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval?: Retrieval` - `boost_by?: Array` 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: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: number` - `filters?: Record` - `fusion_method?: "max" | "rrf"` - `"max"` - `"rrf"` - `keyword_match_mode?: "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. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'. - `"and"` - `"or"` - `match_threshold?: number` - `max_num_results?: number` - `retrieval_type?: "vector" | "keyword" | "hybrid"` - `"vector"` - `"keyword"` - `"hybrid"` - `return_on_failure?: boolean` - `messages?: Array` Body param: OpenAI-compatible message array. For multimodal queries, set the last user message's `content` to an array of typed parts: `[{type:'text', text:'…'}, {type:'image_url', image_url:{url:'…'}}]`. Image inputs require the RAG's embedding_model to declare 'image' in supported_modalities. - `content: string | Array | null` - `string` - `Array` - `UnionMember0` - `text: string` - `type: "text"` - `"text"` - `UnionMember1` - `image_url: ImageURL` - `url: string` - `type: "image_url"` - `"image_url"` - `UnionMember2` - `file: File` - `filename: string` - `file_data?: string` - `file_id?: string` - `type: "file"` - `"file"` - `role: "system" | "developer" | "user" | 2 more` - `"system"` - `"developer"` - `"user"` - `"assistant"` - `"tool"` - `query?: string` Body param: A simple text query string. Alternative to 'messages' — provide either this or 'messages', not both. ### Returns - `InstanceSearchResponse` - `chunks: Array` - `id: string` - `score: number` - `text: string` - `type: string` - `item?: Item` - `key: string` - `metadata?: Record` - `timestamp?: number` - `scoring_details?: ScoringDetails` - `fusion_method?: "rrf" | "max"` - `"rrf"` - `"max"` - `keyword_rank?: number` - `keyword_score?: number` - `reranking_score?: number` - `vector_rank?: number` - `vector_score?: number` - `query_kind: "text" | "image" | "multimodal"` - `"text"` - `"image"` - `"multimodal"` - `search_query?: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiSearch.namespaces.instances.search('my-ai-search', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', name: 'my-namespace', }); console.log(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 } } ], "query_kind": "text", "search_query": "search_query" }, "success": true } ``` ## Chat Completions `client.aiSearch.namespaces.instances.chatCompletions(stringid, InstanceChatCompletionsParamsparams, RequestOptionsoptions?): 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 - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `params: InstanceChatCompletionsParams` - `account_id: string` Path param - `name: string` Path param: Namespace name - `messages: Array` Body param - `content: string | Array | null` - `string` - `Array` - `UnionMember0` - `text: string` - `type: "text"` - `"text"` - `UnionMember1` - `image_url: ImageURL` - `url: string` - `type: "image_url"` - `"image_url"` - `UnionMember2` - `file: File` - `filename: string` - `file_data?: string` - `file_id?: string` - `type: "file"` - `"file"` - `role: "system" | "developer" | "user" | 2 more` - `"system"` - `"developer"` - `"user"` - `"assistant"` - `"tool"` - `ai_search_options?: AISearchOptions` Body param - `cache?: Cache` - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `enabled?: boolean` - `query_rewrite?: QueryRewrite` - `enabled?: boolean` - `model?: "@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?: string` - `reranking?: Reranking` - `enabled?: boolean` - `match_threshold?: number` - `model?: "@cf/baai/bge-reranker-base" | ""` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval?: Retrieval` - `boost_by?: Array` 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: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: number` - `filters?: Record` - `fusion_method?: "max" | "rrf"` - `"max"` - `"rrf"` - `keyword_match_mode?: "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. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'. - `"and"` - `"or"` - `match_threshold?: number` - `max_num_results?: number` - `retrieval_type?: "vector" | "keyword" | "hybrid"` - `"vector"` - `"keyword"` - `"hybrid"` - `return_on_failure?: boolean` - `model?: "@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` Body param - `"@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?: boolean` Body param ### Returns - `InstanceChatCompletionsResponse` - `choices: Array` - `message: Message` - `content: string | Array | null` - `string` - `Array` - `UnionMember0` - `text: string` - `type: "text"` - `"text"` - `UnionMember1` - `image_url: ImageURL` - `url: string` - `type: "image_url"` - `"image_url"` - `UnionMember2` - `file: File` - `filename: string` - `file_data?: string` - `file_id?: string` - `type: "file"` - `"file"` - `role: "system" | "developer" | "user" | 2 more` - `"system"` - `"developer"` - `"user"` - `"assistant"` - `"tool"` - `index?: number` - `chunks: Array` - `id: string` - `score: number` - `text: string` - `type: string` - `item?: Item` - `key: string` - `metadata?: Record` - `timestamp?: number` - `scoring_details?: ScoringDetails` - `fusion_method?: "rrf" | "max"` - `"rrf"` - `"max"` - `keyword_rank?: number` - `keyword_score?: number` - `reranking_score?: number` - `vector_rank?: number` - `vector_score?: number` - `id?: string` - `model?: string` - `object?: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiSearch.namespaces.instances.chatCompletions('my-ai-search', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', name: 'my-namespace', messages: [{ content: 'string', role: 'system' }], }); console.log(response.id); ``` #### Response ```json { "choices": [ { "message": { "content": "string", "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 - `InstanceListResponse` - `id: string` - `ai_gateway_id: string | null` - `ai_search_model: string | null` - `cache: boolean` - `cache_threshold: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes" | null` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl: 600 | 1800 | 3600 | 7 more` - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk: boolean` - `chunk_overlap: number | null` - `chunk_size: number | null` - `created_at: string` - `created_by: string | null` - `custom_metadata: Array | null` - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model: string | null` - `enable: boolean` - `engine_version: number` - `fusion_method: "max" | "rrf"` - `"max"` - `"rrf"` - `hybrid_search_enabled: boolean` - `index_method: IndexMethod` - `keyword: boolean` - `vector: boolean` - `indexing_options: IndexingOptions | null` - `keyword_tokenizer?: "porter" | "trigram"` - `"porter"` - `"trigram"` - `last_activity: string | null` - `max_num_results: number | null` - `metadata: Metadata | null` - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `modified_at: string` - `modified_by: string | null` - `namespace: string` - `paused: boolean` - `public_endpoint_id: string | null` - `public_endpoint_params: PublicEndpointParams | null` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` - `custom_domains?: Array | null` - `default_domain_enabled?: boolean` - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` - `reranking: boolean` - `reranking_model: string | null` - `retrieval_options: RetrievalOptions | null` - `boost_by?: Array` - `field: string` - `dataType?: "number" | "datetime" | "text" | "boolean"` - `"number"` - `"datetime"` - `"text"` - `"boolean"` - `direction?: "asc" | "desc" | "exists" | "not_exists"` - `"asc"` - `"desc"` - `"exists"` - `"not_exists"` - `keyword_match_mode?: "and" | "or"` - `"and"` - `"or"` - `rewrite_model: string | null` - `rewrite_query: boolean` - `score_threshold: number | null` - `source: string | null` - `source_params: SourceParams | null` - `exclude_items?: Array` - `include_items?: Array` - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` - `depth?: number` - `include_external_links?: boolean` - `include_subdomains?: boolean` - `limit?: number` Maximum number of pages to crawl. New values are capped at 100000; instances configured before that cap may report a higher stored value, which the crawler clamps at run time. - `max_age?: number` - `source?: "all" | "sitemaps" | "links"` - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` - `path: string` - `selector: string` - `include_headers?: Record` - `include_images?: boolean` - `specific_sitemaps?: Array` - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` - `"sitemap"` - `"discover"` - `status: string` - `summarization: boolean` - `summarization_model: string | null` - `sync_interval: 900 | 1800 | 3600 | 5 more` - `900` - `1800` - `3600` - `7200` - `14400` - `21600` - `43200` - `86400` - `system_prompt_ai_search: string | null` - `system_prompt_index_summarization: string | null` - `system_prompt_rewrite_query: string | null` - `token_id: string | null` - `type: "r2" | "web-crawler" | null` - `"r2"` - `"web-crawler"` ### Instance Create Response - `InstanceCreateResponse` - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: string` - `modified_at: string` - `ai_gateway_id?: string | null` - `ai_search_model?: "@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 | null` - `"@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?: boolean` - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl?: 600 | 1800 | 3600 | 7 more` Cache entry TTL in seconds. Allowed values: 600 (10min), 1800 (30min), 3600 (1h), 7200 (2h), 21600 (6h), 43200 (12h), 86400 (24h), 172800 (48h), 259200 (72h), 518400 (6d). - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk_overlap?: number` - `chunk_size?: number` - `created_by?: string | null` - `custom_metadata?: Array` - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model?: "@cf/qwen/qwen3-embedding-0.6b" | "@cf/qwen/qwen3-vl-embedding-2b" | "@cf/baai/bge-m3" | 8 more | null` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/qwen/qwen3-vl-embedding-2b"` - `"@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"` - `"google-ai-studio/gemini-embedding-2"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable?: boolean` - `engine_version?: number` - `fusion_method?: "max" | "rrf"` - `"max"` - `"rrf"` - `hybrid_search_enabled?: boolean` Deprecated — use index_method instead. - `index_method?: IndexMethod` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: boolean` Enable keyword (BM25) storage backend. - `vector: boolean` Enable vector (embedding) storage backend. - `indexing_options?: IndexingOptions | null` - `keyword_tokenizer?: "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?: string | null` - `max_num_results?: number` - `metadata?: Metadata` - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `modified_by?: string | null` - `namespace?: string | null` - `paused?: boolean` - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint - `reranking?: boolean` - `reranking_model?: "@cf/baai/bge-reranker-base" | "" | null` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options?: RetrievalOptions | null` - `boost_by?: Array` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric/datetime fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: "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. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'. - `"and"` - `"or"` - `rewrite_model?: "@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 | null` - `"@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?: boolean` - `score_threshold?: number` - `source?: string | null` - `source_params?: SourceParams | null` - `exclude_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `include_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` Options for parse_type 'discover', where Browser Run discovers URLs by link following and sitemaps. Ignored for 'sitemap'. - `depth?: number` Maximum link-follow depth from the seed URL. - `include_external_links?: boolean` Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own. - `include_subdomains?: boolean` Follow links to subdomains of the source host. - `limit?: number` Maximum number of pages to crawl (1-100000). - `max_age?: number` Maximum content age in seconds to accept (0–604800). - `source?: "all" | "sitemaps" | "links"` Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both. - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` 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. Omit the field to disable content selection — empty arrays are rejected. - `path: string` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: string` CSS selector to extract content from pages matching the path pattern. Must not contain disallowed characters (;, `, $, {, }, ). Must target a single element; if multiple elements match, the selector is ignored and the full page is used. - `include_headers?: Record` Up to 5 custom HTTP headers sent with each crawl request. Names must be RFC-7230 token characters (no spaces, colons, or control characters); values must be HTAB + printable ASCII (no CR/LF). - `include_images?: boolean` - `specific_sitemaps?: Array` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account. - `"sitemap"` - `"discover"` - `status?: string` - `sync_interval?: 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?: string` - `type?: "r2" | "web-crawler" | null` - `"r2"` - `"web-crawler"` ### Instance Read Response - `InstanceReadResponse` - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: string` - `modified_at: string` - `ai_gateway_id?: string | null` - `ai_search_model?: "@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 | null` - `"@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?: boolean` - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl?: 600 | 1800 | 3600 | 7 more` Cache entry TTL in seconds. Allowed values: 600 (10min), 1800 (30min), 3600 (1h), 7200 (2h), 21600 (6h), 43200 (12h), 86400 (24h), 172800 (48h), 259200 (72h), 518400 (6d). - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk_overlap?: number` - `chunk_size?: number` - `created_by?: string | null` - `custom_metadata?: Array` - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model?: "@cf/qwen/qwen3-embedding-0.6b" | "@cf/qwen/qwen3-vl-embedding-2b" | "@cf/baai/bge-m3" | 8 more | null` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/qwen/qwen3-vl-embedding-2b"` - `"@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"` - `"google-ai-studio/gemini-embedding-2"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable?: boolean` - `engine_version?: number` - `fusion_method?: "max" | "rrf"` - `"max"` - `"rrf"` - `hybrid_search_enabled?: boolean` Deprecated — use index_method instead. - `index_method?: IndexMethod` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: boolean` Enable keyword (BM25) storage backend. - `vector: boolean` Enable vector (embedding) storage backend. - `indexing_options?: IndexingOptions | null` - `keyword_tokenizer?: "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?: string | null` - `max_num_results?: number` - `metadata?: Metadata` - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `modified_by?: string | null` - `namespace?: string | null` - `paused?: boolean` - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint - `reranking?: boolean` - `reranking_model?: "@cf/baai/bge-reranker-base" | "" | null` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options?: RetrievalOptions | null` - `boost_by?: Array` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric/datetime fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: "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. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'. - `"and"` - `"or"` - `rewrite_model?: "@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 | null` - `"@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?: boolean` - `score_threshold?: number` - `source?: string | null` - `source_params?: SourceParams | null` - `exclude_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `include_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` Options for parse_type 'discover', where Browser Run discovers URLs by link following and sitemaps. Ignored for 'sitemap'. - `depth?: number` Maximum link-follow depth from the seed URL. - `include_external_links?: boolean` Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own. - `include_subdomains?: boolean` Follow links to subdomains of the source host. - `limit?: number` Maximum number of pages to crawl (1-100000). - `max_age?: number` Maximum content age in seconds to accept (0–604800). - `source?: "all" | "sitemaps" | "links"` Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both. - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` 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. Omit the field to disable content selection — empty arrays are rejected. - `path: string` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: string` CSS selector to extract content from pages matching the path pattern. Must not contain disallowed characters (;, `, $, {, }, ). Must target a single element; if multiple elements match, the selector is ignored and the full page is used. - `include_headers?: Record` Up to 5 custom HTTP headers sent with each crawl request. Names must be RFC-7230 token characters (no spaces, colons, or control characters); values must be HTAB + printable ASCII (no CR/LF). - `include_images?: boolean` - `specific_sitemaps?: Array` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account. - `"sitemap"` - `"discover"` - `status?: string` - `sync_interval?: 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?: string` - `type?: "r2" | "web-crawler" | null` - `"r2"` - `"web-crawler"` ### Instance Update Response - `InstanceUpdateResponse` - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: string` - `modified_at: string` - `ai_gateway_id?: string | null` - `ai_search_model?: "@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 | null` - `"@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?: boolean` - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl?: 600 | 1800 | 3600 | 7 more` Cache entry TTL in seconds. Allowed values: 600 (10min), 1800 (30min), 3600 (1h), 7200 (2h), 21600 (6h), 43200 (12h), 86400 (24h), 172800 (48h), 259200 (72h), 518400 (6d). - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk_overlap?: number` - `chunk_size?: number` - `created_by?: string | null` - `custom_metadata?: Array` - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model?: "@cf/qwen/qwen3-embedding-0.6b" | "@cf/qwen/qwen3-vl-embedding-2b" | "@cf/baai/bge-m3" | 8 more | null` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/qwen/qwen3-vl-embedding-2b"` - `"@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"` - `"google-ai-studio/gemini-embedding-2"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable?: boolean` - `engine_version?: number` - `fusion_method?: "max" | "rrf"` - `"max"` - `"rrf"` - `hybrid_search_enabled?: boolean` Deprecated — use index_method instead. - `index_method?: IndexMethod` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: boolean` Enable keyword (BM25) storage backend. - `vector: boolean` Enable vector (embedding) storage backend. - `indexing_options?: IndexingOptions | null` - `keyword_tokenizer?: "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?: string | null` - `max_num_results?: number` - `metadata?: Metadata` - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `modified_by?: string | null` - `namespace?: string | null` - `paused?: boolean` - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint - `reranking?: boolean` - `reranking_model?: "@cf/baai/bge-reranker-base" | "" | null` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options?: RetrievalOptions | null` - `boost_by?: Array` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric/datetime fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: "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. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'. - `"and"` - `"or"` - `rewrite_model?: "@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 | null` - `"@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?: boolean` - `score_threshold?: number` - `source?: string | null` - `source_params?: SourceParams | null` - `exclude_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `include_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` Options for parse_type 'discover', where Browser Run discovers URLs by link following and sitemaps. Ignored for 'sitemap'. - `depth?: number` Maximum link-follow depth from the seed URL. - `include_external_links?: boolean` Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own. - `include_subdomains?: boolean` Follow links to subdomains of the source host. - `limit?: number` Maximum number of pages to crawl (1-100000). - `max_age?: number` Maximum content age in seconds to accept (0–604800). - `source?: "all" | "sitemaps" | "links"` Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both. - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` 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. Omit the field to disable content selection — empty arrays are rejected. - `path: string` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: string` CSS selector to extract content from pages matching the path pattern. Must not contain disallowed characters (;, `, $, {, }, ). Must target a single element; if multiple elements match, the selector is ignored and the full page is used. - `include_headers?: Record` Up to 5 custom HTTP headers sent with each crawl request. Names must be RFC-7230 token characters (no spaces, colons, or control characters); values must be HTAB + printable ASCII (no CR/LF). - `include_images?: boolean` - `specific_sitemaps?: Array` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account. - `"sitemap"` - `"discover"` - `status?: string` - `sync_interval?: 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?: string` - `type?: "r2" | "web-crawler" | null` - `"r2"` - `"web-crawler"` ### Instance Delete Response - `InstanceDeleteResponse` - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: string` - `modified_at: string` - `ai_gateway_id?: string | null` - `ai_search_model?: "@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 | null` - `"@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?: boolean` - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl?: 600 | 1800 | 3600 | 7 more` Cache entry TTL in seconds. Allowed values: 600 (10min), 1800 (30min), 3600 (1h), 7200 (2h), 21600 (6h), 43200 (12h), 86400 (24h), 172800 (48h), 259200 (72h), 518400 (6d). - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk_overlap?: number` - `chunk_size?: number` - `created_by?: string | null` - `custom_metadata?: Array` - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model?: "@cf/qwen/qwen3-embedding-0.6b" | "@cf/qwen/qwen3-vl-embedding-2b" | "@cf/baai/bge-m3" | 8 more | null` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/qwen/qwen3-vl-embedding-2b"` - `"@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"` - `"google-ai-studio/gemini-embedding-2"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable?: boolean` - `engine_version?: number` - `fusion_method?: "max" | "rrf"` - `"max"` - `"rrf"` - `hybrid_search_enabled?: boolean` Deprecated — use index_method instead. - `index_method?: IndexMethod` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: boolean` Enable keyword (BM25) storage backend. - `vector: boolean` Enable vector (embedding) storage backend. - `indexing_options?: IndexingOptions | null` - `keyword_tokenizer?: "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?: string | null` - `max_num_results?: number` - `metadata?: Metadata` - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `modified_by?: string | null` - `namespace?: string | null` - `paused?: boolean` - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint - `reranking?: boolean` - `reranking_model?: "@cf/baai/bge-reranker-base" | "" | null` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options?: RetrievalOptions | null` - `boost_by?: Array` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric/datetime fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: "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. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'. - `"and"` - `"or"` - `rewrite_model?: "@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 | null` - `"@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?: boolean` - `score_threshold?: number` - `source?: string | null` - `source_params?: SourceParams | null` - `exclude_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `include_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` Options for parse_type 'discover', where Browser Run discovers URLs by link following and sitemaps. Ignored for 'sitemap'. - `depth?: number` Maximum link-follow depth from the seed URL. - `include_external_links?: boolean` Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own. - `include_subdomains?: boolean` Follow links to subdomains of the source host. - `limit?: number` Maximum number of pages to crawl (1-100000). - `max_age?: number` Maximum content age in seconds to accept (0–604800). - `source?: "all" | "sitemaps" | "links"` Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both. - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` 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. Omit the field to disable content selection — empty arrays are rejected. - `path: string` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: string` CSS selector to extract content from pages matching the path pattern. Must not contain disallowed characters (;, `, $, {, }, ). Must target a single element; if multiple elements match, the selector is ignored and the full page is used. - `include_headers?: Record` Up to 5 custom HTTP headers sent with each crawl request. Names must be RFC-7230 token characters (no spaces, colons, or control characters); values must be HTAB + printable ASCII (no CR/LF). - `include_images?: boolean` - `specific_sitemaps?: Array` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account. - `"sitemap"` - `"discover"` - `status?: string` - `sync_interval?: 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?: string` - `type?: "r2" | "web-crawler" | null` - `"r2"` - `"web-crawler"` ### Instance Stats Response - `InstanceStatsResponse` - `completed?: number` - `degraded?: boolean` True when status counts are unavailable (e.g. legacy stats query exceeded D1 statement-size limit). Counts are omitted in this case. - `engine?: Engine` Engine-specific metadata. Present only for managed (v3) instances. - `r2?: R2` R2 bucket storage usage in bytes. - `metadataSizeBytes: number` - `objectCount: number` - `payloadSizeBytes: number` - `vectorize?: Vectorize` Vectorize index metadata (dimensions, vector count). - `dimensions: number` - `vectorsCount: number` - `error?: number` - `file_embed_errors?: Record` - `index_source_errors?: Record` - `last_activity?: string` - `outdated?: number` - `queued?: number` - `running?: number` - `skipped?: number` ### Instance Search Response - `InstanceSearchResponse` - `chunks: Array` - `id: string` - `score: number` - `text: string` - `type: string` - `item?: Item` - `key: string` - `metadata?: Record` - `timestamp?: number` - `scoring_details?: ScoringDetails` - `fusion_method?: "rrf" | "max"` - `"rrf"` - `"max"` - `keyword_rank?: number` - `keyword_score?: number` - `reranking_score?: number` - `vector_rank?: number` - `vector_score?: number` - `query_kind: "text" | "image" | "multimodal"` - `"text"` - `"image"` - `"multimodal"` - `search_query?: string` ### Instance Chat Completions Response - `InstanceChatCompletionsResponse` - `choices: Array` - `message: Message` - `content: string | Array | null` - `string` - `Array` - `UnionMember0` - `text: string` - `type: "text"` - `"text"` - `UnionMember1` - `image_url: ImageURL` - `url: string` - `type: "image_url"` - `"image_url"` - `UnionMember2` - `file: File` - `filename: string` - `file_data?: string` - `file_id?: string` - `type: "file"` - `"file"` - `role: "system" | "developer" | "user" | 2 more` - `"system"` - `"developer"` - `"user"` - `"assistant"` - `"tool"` - `index?: number` - `chunks: Array` - `id: string` - `score: number` - `text: string` - `type: string` - `item?: Item` - `key: string` - `metadata?: Record` - `timestamp?: number` - `scoring_details?: ScoringDetails` - `fusion_method?: "rrf" | "max"` - `"rrf"` - `"max"` - `keyword_rank?: number` - `keyword_score?: number` - `reranking_score?: number` - `vector_rank?: number` - `vector_score?: number` - `id?: string` - `model?: string` - `object?: string` # Jobs ## List Jobs `client.aiSearch.namespaces.instances.jobs.list(stringid, JobListParamsparams, RequestOptionsoptions?): V4PagePaginationArray` **get** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/jobs` Lists indexing jobs for an AI Search instance. ### Parameters - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `params: JobListParams` - `account_id: string` Path param - `name: string` Path param: Namespace name - `page?: number` Query param - `per_page?: number` Query param ### Returns - `JobListResponse` - `id: string` - `source: "user" | "schedule"` - `"user"` - `"schedule"` - `description?: string` - `end_reason?: string` - `ended_at?: string` - `last_seen_at?: string` - `started_at?: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const jobListResponse of client.aiSearch.namespaces.instances.jobs.list('my-ai-search', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', name: 'my-namespace', })) { console.log(jobListResponse.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 `client.aiSearch.namespaces.instances.jobs.create(stringid, JobCreateParamsparams, RequestOptionsoptions?): JobCreateResponse` **post** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/jobs` Creates a new indexing job for an AI Search instance. ### Parameters - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `params: JobCreateParams` - `account_id: string` Path param - `name: string` Path param: Namespace name - `description?: string` Body param ### Returns - `JobCreateResponse` - `id: string` - `source: "user" | "schedule"` - `"user"` - `"schedule"` - `description?: string` - `end_reason?: string` - `ended_at?: string` - `last_seen_at?: string` - `started_at?: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const job = await client.aiSearch.namespaces.instances.jobs.create('my-ai-search', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', name: 'my-namespace', }); console.log(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 `client.aiSearch.namespaces.instances.jobs.get(stringjobID, JobGetParamsparams, RequestOptionsoptions?): JobGetResponse` **get** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/jobs/{job_id}` Retrieves details for a specific AI Search indexing job. ### Parameters - `jobID: string` - `params: JobGetParams` - `account_id: string` - `name: string` Namespace name - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. ### Returns - `JobGetResponse` - `id: string` - `source: "user" | "schedule"` - `"user"` - `"schedule"` - `description?: string` - `end_reason?: string` - `ended_at?: string` - `last_seen_at?: string` - `started_at?: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const job = await client.aiSearch.namespaces.instances.jobs.get('job_id', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', name: 'my-namespace', id: 'my-ai-search', }); console.log(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 } ``` ## Cancel an indexing job. `client.aiSearch.namespaces.instances.jobs.update(stringjobID, JobUpdateParamsparams, RequestOptionsoptions?): JobUpdateResponse` **patch** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/jobs/{job_id}` Cancel an in-progress indexing job for an AI Search instance. ### Parameters - `jobID: string` - `params: JobUpdateParams` - `account_id: string` Path param - `name: string` Path param: Namespace name - `id: string` Path param: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `action: "cancel"` Body param - `"cancel"` ### Returns - `JobUpdateResponse` - `id: string` - `source: "user" | "schedule"` - `"user"` - `"schedule"` - `description?: string` - `end_reason?: string` - `ended_at?: string` - `last_seen_at?: string` - `started_at?: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const job = await client.aiSearch.namespaces.instances.jobs.update('job_id', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', name: 'my-namespace', id: 'my-ai-search', action: 'cancel', }); console.log(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 `client.aiSearch.namespaces.instances.jobs.logs(stringjobID, JobLogsParamsparams, RequestOptionsoptions?): 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 - `jobID: string` - `params: JobLogsParams` - `account_id: string` Path param - `name: string` Path param: Namespace name - `id: string` Path param: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `page?: number` Query param - `per_page?: number` Query param ### Returns - `JobLogsResponse = Array` - `id: number` - `created_at: number` - `message: string` - `message_type: number` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiSearch.namespaces.instances.jobs.logs('job_id', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', name: 'my-namespace', id: 'my-ai-search', }); console.log(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 - `JobListResponse` - `id: string` - `source: "user" | "schedule"` - `"user"` - `"schedule"` - `description?: string` - `end_reason?: string` - `ended_at?: string` - `last_seen_at?: string` - `started_at?: string` ### Job Create Response - `JobCreateResponse` - `id: string` - `source: "user" | "schedule"` - `"user"` - `"schedule"` - `description?: string` - `end_reason?: string` - `ended_at?: string` - `last_seen_at?: string` - `started_at?: string` ### Job Get Response - `JobGetResponse` - `id: string` - `source: "user" | "schedule"` - `"user"` - `"schedule"` - `description?: string` - `end_reason?: string` - `ended_at?: string` - `last_seen_at?: string` - `started_at?: string` ### Job Update Response - `JobUpdateResponse` - `id: string` - `source: "user" | "schedule"` - `"user"` - `"schedule"` - `description?: string` - `end_reason?: string` - `ended_at?: string` - `last_seen_at?: string` - `started_at?: string` ### Job Logs Response - `JobLogsResponse = Array` - `id: number` - `created_at: number` - `message: string` - `message_type: number` # Items ## Items List. `client.aiSearch.namespaces.instances.items.list(stringid, ItemListParamsparams, RequestOptionsoptions?): V4PagePaginationArray` **get** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items` Lists indexed items in an AI Search instance. ### Parameters - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `params: ItemListParams` - `account_id: string` Path param - `name: string` Path param: Namespace name - `item_id?: string` Query param: Filter items by their unique ID. Returns at most one item. - `key?: string` Query param: Filter items by their exact key (object key / filename). Keys are unique per source, so combine with `source` to disambiguate across data sources. - `metadata_filter?: string` Query param: JSON-encoded metadata filter using Vectorize filter syntax. Examples: {"folder":"reports/"}, {"timestamp":{"$gte":1700000000000}}, {"folder":{"$in":["docs/","reports/"]}} - `page?: number` Query param - `per_page?: number` Query param - `search?: string` Query param - `sort_by?: "status" | "modified_at"` Query param: 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?: string` Query param: Filter items by source_id. Use "builtin" for uploaded files, or a source identifier like "web-crawler:https://example.com". - `status?: "queued" | "running" | "completed" | 3 more` Query param - `"queued"` - `"running"` - `"completed"` - `"error"` - `"skipped"` - `"outdated"` ### Returns - `ItemListResponse` - `id: string` - `checksum: string` - `chunks_count: number | null` - `created_at: string` - `file_size: number | null` - `key: string` - `last_seen_at: string` - `metadata: Record | null` Built-in, configured filterable, and retained source metadata for the item. - `string` - `number` - `boolean` - `namespace: string` - `next_action: "INDEX" | "DELETE" | null` - `"INDEX"` - `"DELETE"` - `source_id: string | null` Identifies which data source this item belongs to. "builtin" for uploaded files, "{type}:{source}" for external sources, null for legacy items. - `status: "queued" | "running" | "completed" | 3 more` - `"queued"` - `"running"` - `"completed"` - `"error"` - `"skipped"` - `"outdated"` - `error?: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const itemListResponse of client.aiSearch.namespaces.instances.items.list( 'my-ai-search', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', name: 'my-namespace' }, )) { console.log(itemListResponse.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", "metadata": { "foo": "string" }, "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. `client.aiSearch.namespaces.instances.items.upload(stringid, ItemUploadParamsparams, RequestOptionsoptions?): 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. ### Parameters - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `params: ItemUploadParams` - `account_id: string` Path param - `name: string` Path param: Namespace name - `file: File` Body param - `file: Uploadable` The file to upload. Filename must not exceed 128 characters. - `metadata?: string` JSON string of custom metadata key-value pairs. - `wait_for_completion?: boolean` Wait for indexing to fully complete before responding. On RAGs with vector indexing enabled, this additionally waits for Vectorize ingestion confirmation (up to 40s) so the returned item reflects a queryable state. On timeout the item is returned in `running` state and the background alarm continues polling. Defaults to false. ### Returns - `ItemUploadResponse` - `id: string` - `checksum: string` - `chunks_count: number | null` - `created_at: string` - `file_size: number | null` - `key: string` - `last_seen_at: string` - `metadata: Record | null` Built-in, configured filterable, and retained source metadata for the item. - `string` - `number` - `boolean` - `namespace: string` - `next_action: "INDEX" | "DELETE" | null` - `"INDEX"` - `"DELETE"` - `source_id: string | null` Identifies which data source this item belongs to. "builtin" for uploaded files, "{type}:{source}" for external sources, null for legacy items. - `status: "queued" | "running" | "completed" | 3 more` - `"queued"` - `"running"` - `"completed"` - `"error"` - `"skipped"` - `"outdated"` - `error?: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiSearch.namespaces.instances.items.upload('my-ai-search', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', name: 'my-namespace', file: { file: fs.createReadStream('path/to/file') }, }); console.log(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", "metadata": { "foo": "string" }, "namespace": "namespace", "next_action": "INDEX", "source_id": "source_id", "status": "queued", "error": "error" }, "success": true } ``` ## Create or Update Item. `client.aiSearch.namespaces.instances.items.createOrUpdate(stringid, ItemCreateOrUpdateParamsparams, RequestOptionsoptions?): ItemCreateOrUpdateResponse` **put** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items` Creates or updates an indexed item in an AI Search instance. ### Parameters - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `params: ItemCreateOrUpdateParams` - `account_id: string` Path param - `name: string` Path param: Namespace name - `key: string` Body param: Item key / filename. Must not exceed 128 characters. - `next_action: "INDEX"` Body param - `"INDEX"` - `wait_for_completion?: boolean` Body param: Wait for indexing to fully complete before responding. On RAGs with vector indexing enabled, this additionally waits for Vectorize ingestion confirmation (up to 40s) so the returned item reflects a queryable state. On timeout the item is returned in `running` state and the background alarm continues polling. Defaults to false. ### Returns - `ItemCreateOrUpdateResponse` - `id: string` - `checksum: string` - `chunks_count: number | null` - `created_at: string` - `file_size: number | null` - `key: string` - `last_seen_at: string` - `metadata: Record | null` Built-in, configured filterable, and retained source metadata for the item. - `string` - `number` - `boolean` - `namespace: string` - `next_action: "INDEX" | "DELETE" | null` - `"INDEX"` - `"DELETE"` - `source_id: string | null` Identifies which data source this item belongs to. "builtin" for uploaded files, "{type}:{source}" for external sources, null for legacy items. - `status: "queued" | "running" | "completed" | 3 more` - `"queued"` - `"running"` - `"completed"` - `"error"` - `"skipped"` - `"outdated"` - `error?: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiSearch.namespaces.instances.items.createOrUpdate('my-ai-search', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', name: 'my-namespace', key: 'key', next_action: 'INDEX', }); console.log(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", "metadata": { "foo": "string" }, "namespace": "namespace", "next_action": "INDEX", "source_id": "source_id", "status": "queued", "error": "error" }, "success": true } ``` ## Get Item. `client.aiSearch.namespaces.instances.items.get(stringitemID, ItemGetParamsparams, RequestOptionsoptions?): 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 - `itemID: string` - `params: ItemGetParams` - `account_id: string` - `name: string` Namespace name - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. ### Returns - `ItemGetResponse` - `id: string` - `checksum: string` - `chunks_count: number | null` - `created_at: string` - `file_size: number | null` - `key: string` - `last_seen_at: string` - `metadata: Record | null` Built-in, configured filterable, and retained source metadata for the item. - `string` - `number` - `boolean` - `namespace: string` - `next_action: "INDEX" | "DELETE" | null` - `"INDEX"` - `"DELETE"` - `source_id: string | null` Identifies which data source this item belongs to. "builtin" for uploaded files, "{type}:{source}" for external sources, null for legacy items. - `status: "queued" | "running" | "completed" | 3 more` - `"queued"` - `"running"` - `"completed"` - `"error"` - `"skipped"` - `"outdated"` - `error?: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const item = await client.aiSearch.namespaces.instances.items.get('item_id', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', name: 'my-namespace', id: 'my-ai-search', }); console.log(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", "metadata": { "foo": "string" }, "namespace": "namespace", "next_action": "INDEX", "source_id": "source_id", "status": "queued", "error": "error" }, "success": true } ``` ## Sync Item. `client.aiSearch.namespaces.instances.items.sync(stringitemID, ItemSyncParamsparams, RequestOptionsoptions?): ItemSyncResponse` **patch** `/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items/{item_id}` Syncs an item to an AI Search instance index. ### Parameters - `itemID: string` - `params: ItemSyncParams` - `account_id: string` Path param - `name: string` Path param: Namespace name - `id: string` Path param: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `next_action: "INDEX"` Body param - `"INDEX"` - `wait_for_completion?: boolean` Body param: Wait for indexing to fully complete before responding. On RAGs with vector indexing enabled, this additionally waits for Vectorize ingestion confirmation (up to 40s) so the returned item reflects a queryable state. On timeout the item is returned in `running` state and the background alarm continues polling. Defaults to false. ### Returns - `ItemSyncResponse` - `id: string` - `checksum: string` - `chunks_count: number | null` - `created_at: string` - `file_size: number | null` - `key: string` - `last_seen_at: string` - `metadata: Record | null` Built-in, configured filterable, and retained source metadata for the item. - `string` - `number` - `boolean` - `namespace: string` - `next_action: "INDEX" | "DELETE" | null` - `"INDEX"` - `"DELETE"` - `source_id: string | null` Identifies which data source this item belongs to. "builtin" for uploaded files, "{type}:{source}" for external sources, null for legacy items. - `status: "queued" | "running" | "completed" | 3 more` - `"queued"` - `"running"` - `"completed"` - `"error"` - `"skipped"` - `"outdated"` - `error?: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiSearch.namespaces.instances.items.sync('item_id', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', name: 'my-namespace', id: 'my-ai-search', next_action: 'INDEX', }); console.log(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", "metadata": { "foo": "string" }, "namespace": "namespace", "next_action": "INDEX", "source_id": "source_id", "status": "queued", "error": "error" }, "success": true } ``` ## Delete Item. `client.aiSearch.namespaces.instances.items.delete(stringitemID, ItemDeleteParamsparams, RequestOptionsoptions?): 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 - `itemID: string` - `params: ItemDeleteParams` - `account_id: string` - `name: string` Namespace name - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. ### Returns - `ItemDeleteResponse` - `key: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const item = await client.aiSearch.namespaces.instances.items.delete('item_id', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', name: 'my-namespace', id: 'my-ai-search', }); console.log(item.key); ``` #### Response ```json { "result": { "key": "key" }, "success": true } ``` ## Download Item Content. `client.aiSearch.namespaces.instances.items.download(stringitemID, ItemDownloadParamsparams, RequestOptionsoptions?): Response` **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 - `itemID: string` - `params: ItemDownloadParams` - `account_id: string` - `name: string` Namespace name - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. ### Returns - `unnamed_schema_13 = Response` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiSearch.namespaces.instances.items.download('item_id', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', name: 'my-namespace', id: 'my-ai-search', }); console.log(response); const content = await response.blob(); console.log(content); ``` ## Item Logs. `client.aiSearch.namespaces.instances.items.logs(stringitemID, ItemLogsParamsparams, RequestOptionsoptions?): 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 - `itemID: string` - `params: ItemLogsParams` - `account_id: string` Path param - `name: string` Path param: Namespace name - `id: string` Path param: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `cursor?: string` Query param - `limit?: number` Query param ### Returns - `ItemLogsResponse = Array` - `action: string` - `chunkCount: number | null` - `errorType: string | null` - `fileKey: string` - `message: string | null` - `processingTimeMs: number | null` - `timestamp: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiSearch.namespaces.instances.items.logs('item_id', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', name: 'my-namespace', id: 'my-ai-search', }); console.log(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. `client.aiSearch.namespaces.instances.items.chunks(stringitemID, ItemChunksParamsparams, RequestOptionsoptions?): 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 - `itemID: string` - `params: ItemChunksParams` - `account_id: string` Path param - `name: string` Path param: Namespace name - `id: string` Path param: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `limit?: number` Query param - `offset?: number` Query param ### Returns - `ItemChunksResponse = Array` - `id: string` - `item: Item` - `key: string` - `metadata?: Record` - `timestamp?: number` - `text: string` - `end_byte?: number` - `start_byte?: number` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiSearch.namespaces.instances.items.chunks('item_id', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', name: 'my-namespace', id: 'my-ai-search', }); console.log(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 - `ItemListResponse` - `id: string` - `checksum: string` - `chunks_count: number | null` - `created_at: string` - `file_size: number | null` - `key: string` - `last_seen_at: string` - `metadata: Record | null` Built-in, configured filterable, and retained source metadata for the item. - `string` - `number` - `boolean` - `namespace: string` - `next_action: "INDEX" | "DELETE" | null` - `"INDEX"` - `"DELETE"` - `source_id: string | null` Identifies which data source this item belongs to. "builtin" for uploaded files, "{type}:{source}" for external sources, null for legacy items. - `status: "queued" | "running" | "completed" | 3 more` - `"queued"` - `"running"` - `"completed"` - `"error"` - `"skipped"` - `"outdated"` - `error?: string` ### Item Upload Response - `ItemUploadResponse` - `id: string` - `checksum: string` - `chunks_count: number | null` - `created_at: string` - `file_size: number | null` - `key: string` - `last_seen_at: string` - `metadata: Record | null` Built-in, configured filterable, and retained source metadata for the item. - `string` - `number` - `boolean` - `namespace: string` - `next_action: "INDEX" | "DELETE" | null` - `"INDEX"` - `"DELETE"` - `source_id: string | null` Identifies which data source this item belongs to. "builtin" for uploaded files, "{type}:{source}" for external sources, null for legacy items. - `status: "queued" | "running" | "completed" | 3 more` - `"queued"` - `"running"` - `"completed"` - `"error"` - `"skipped"` - `"outdated"` - `error?: string` ### Item Create Or Update Response - `ItemCreateOrUpdateResponse` - `id: string` - `checksum: string` - `chunks_count: number | null` - `created_at: string` - `file_size: number | null` - `key: string` - `last_seen_at: string` - `metadata: Record | null` Built-in, configured filterable, and retained source metadata for the item. - `string` - `number` - `boolean` - `namespace: string` - `next_action: "INDEX" | "DELETE" | null` - `"INDEX"` - `"DELETE"` - `source_id: string | null` Identifies which data source this item belongs to. "builtin" for uploaded files, "{type}:{source}" for external sources, null for legacy items. - `status: "queued" | "running" | "completed" | 3 more` - `"queued"` - `"running"` - `"completed"` - `"error"` - `"skipped"` - `"outdated"` - `error?: string` ### Item Get Response - `ItemGetResponse` - `id: string` - `checksum: string` - `chunks_count: number | null` - `created_at: string` - `file_size: number | null` - `key: string` - `last_seen_at: string` - `metadata: Record | null` Built-in, configured filterable, and retained source metadata for the item. - `string` - `number` - `boolean` - `namespace: string` - `next_action: "INDEX" | "DELETE" | null` - `"INDEX"` - `"DELETE"` - `source_id: string | null` Identifies which data source this item belongs to. "builtin" for uploaded files, "{type}:{source}" for external sources, null for legacy items. - `status: "queued" | "running" | "completed" | 3 more` - `"queued"` - `"running"` - `"completed"` - `"error"` - `"skipped"` - `"outdated"` - `error?: string` ### Item Sync Response - `ItemSyncResponse` - `id: string` - `checksum: string` - `chunks_count: number | null` - `created_at: string` - `file_size: number | null` - `key: string` - `last_seen_at: string` - `metadata: Record | null` Built-in, configured filterable, and retained source metadata for the item. - `string` - `number` - `boolean` - `namespace: string` - `next_action: "INDEX" | "DELETE" | null` - `"INDEX"` - `"DELETE"` - `source_id: string | null` Identifies which data source this item belongs to. "builtin" for uploaded files, "{type}:{source}" for external sources, null for legacy items. - `status: "queued" | "running" | "completed" | 3 more` - `"queued"` - `"running"` - `"completed"` - `"error"` - `"skipped"` - `"outdated"` - `error?: string` ### Item Delete Response - `ItemDeleteResponse` - `key: string` ### Item Logs Response - `ItemLogsResponse = Array` - `action: string` - `chunkCount: number | null` - `errorType: string | null` - `fileKey: string` - `message: string | null` - `processingTimeMs: number | null` - `timestamp: string` ### Item Chunks Response - `ItemChunksResponse = Array` - `id: string` - `item: Item` - `key: string` - `metadata?: Record` - `timestamp?: number` - `text: string` - `end_byte?: number` - `start_byte?: number` # Instances ## List AI Search instances. `client.aiSearch.instances.list(InstanceListParamsparams, RequestOptionsoptions?): V4PagePaginationArray` **get** `/accounts/{account_id}/ai-search/instances` List all AI Search instances in the account. ### Parameters - `params: InstanceListParams` - `account_id: string` Path param - `namespace?: string` Query param: Filter by namespace. - `order_by?: "created_at"` Query param: Field to order results by. - `"created_at"` - `order_by_direction?: "asc" | "desc"` Query param: Order direction. - `"asc"` - `"desc"` - `page?: number` Query param: Page number (1-indexed). - `per_page?: number` Query param: Number of results per page. - `search?: string` Query param: Filter instances whose id contains this string (case-insensitive). ### Returns - `InstanceListResponse` - `id: string` - `ai_gateway_id: string | null` - `ai_search_model: string | null` - `cache: boolean` - `cache_threshold: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes" | null` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl: 600 | 1800 | 3600 | 7 more` - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk: boolean` - `chunk_overlap: number | null` - `chunk_size: number | null` - `created_at: string` - `created_by: string | null` - `custom_metadata: Array | null` - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model: string | null` - `enable: boolean` - `engine_version: number` - `fusion_method: "max" | "rrf"` - `"max"` - `"rrf"` - `hybrid_search_enabled: boolean` - `index_method: IndexMethod` - `keyword: boolean` - `vector: boolean` - `indexing_options: IndexingOptions | null` - `keyword_tokenizer?: "porter" | "trigram"` - `"porter"` - `"trigram"` - `last_activity: string | null` - `max_num_results: number | null` - `metadata: Metadata | null` - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `modified_at: string` - `modified_by: string | null` - `namespace: string` - `paused: boolean` - `public_endpoint_id: string | null` - `public_endpoint_params: PublicEndpointParams | null` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` - `custom_domains?: Array | null` - `default_domain_enabled?: boolean` - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` - `reranking: boolean` - `reranking_model: string | null` - `retrieval_options: RetrievalOptions | null` - `boost_by?: Array` - `field: string` - `dataType?: "number" | "datetime" | "text" | "boolean"` - `"number"` - `"datetime"` - `"text"` - `"boolean"` - `direction?: "asc" | "desc" | "exists" | "not_exists"` - `"asc"` - `"desc"` - `"exists"` - `"not_exists"` - `keyword_match_mode?: "and" | "or"` - `"and"` - `"or"` - `rewrite_model: string | null` - `rewrite_query: boolean` - `score_threshold: number | null` - `source: string | null` - `source_params: SourceParams | null` - `exclude_items?: Array` - `include_items?: Array` - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` - `depth?: number` - `include_external_links?: boolean` - `include_subdomains?: boolean` - `limit?: number` Maximum number of pages to crawl. New values are capped at 100000; instances configured before that cap may report a higher stored value, which the crawler clamps at run time. - `max_age?: number` - `source?: "all" | "sitemaps" | "links"` - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` - `path: string` - `selector: string` - `include_headers?: Record` - `include_images?: boolean` - `specific_sitemaps?: Array` - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` - `"sitemap"` - `"discover"` - `status: string` - `summarization: boolean` - `summarization_model: string | null` - `sync_interval: 900 | 1800 | 3600 | 5 more` - `900` - `1800` - `3600` - `7200` - `14400` - `21600` - `43200` - `86400` - `system_prompt_ai_search: string | null` - `system_prompt_index_summarization: string | null` - `system_prompt_rewrite_query: string | null` - `token_id: string | null` - `type: "r2" | "web-crawler" | null` - `"r2"` - `"web-crawler"` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const instanceListResponse of client.aiSearch.instances.list({ account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', })) { console.log(instanceListResponse.id); } ``` #### Response ```json { "result": [ { "id": "id", "ai_gateway_id": "ai_gateway_id", "ai_search_model": "ai_search_model", "cache": true, "cache_threshold": "super_strict_match", "cache_ttl": 600, "chunk": true, "chunk_overlap": 0, "chunk_size": 0, "created_at": "2019-12-27T18:11:19.117Z", "created_by": "created_by", "custom_metadata": [ { "data_type": "text", "field_name": "field_name" } ], "embedding_model": "embedding_model", "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": 0, "metadata": { "created_from_aisearch_wizard": true, "worker_domain": "worker_domain" }, "modified_at": "2019-12-27T18:11:19.117Z", "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 }, "custom_domains": [ "x" ], "default_domain_enabled": 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": "reranking_model", "retrieval_options": { "boost_by": [ { "field": "x", "dataType": "number", "direction": "asc" } ], "keyword_match_mode": "and" }, "rewrite_model": "rewrite_model", "rewrite_query": true, "score_threshold": 0, "source": "source", "source_params": { "exclude_items": [ "string" ], "include_items": [ "string" ], "prefix": "prefix", "r2_jurisdiction": "r2_jurisdiction", "web_crawler": { "discover_options": { "depth": 1, "include_external_links": true, "include_subdomains": true, "limit": 1, "max_age": 0, "source": "all" }, "parse_options": { "content_selector": [ { "path": "x", "selector": "x" } ], "include_headers": { "foo": "string" }, "include_images": true, "specific_sitemaps": [ "https://example.com" ], "use_browser_rendering": true }, "parse_type": "sitemap" } }, "status": "status", "summarization": true, "summarization_model": "summarization_model", "sync_interval": 900, "system_prompt_ai_search": "system_prompt_ai_search", "system_prompt_index_summarization": "system_prompt_index_summarization", "system_prompt_rewrite_query": "system_prompt_rewrite_query", "token_id": "token_id", "type": "r2" } ], "result_info": { "count": 0, "page": 0, "per_page": 0, "total_count": 0 }, "success": true } ``` ## Create an AI Search instance. `client.aiSearch.instances.create(InstanceCreateParamsparams, RequestOptionsoptions?): InstanceCreateResponse` **post** `/accounts/{account_id}/ai-search/instances` Create a new AI Search instance with the given configuration. ### Parameters - `params: InstanceCreateParams` - `account_id: string` Path param - `id: string` Body param: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `ai_gateway_id?: string | null` Body param - `ai_search_model?: "@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 | null` Body param - `"@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?: boolean` Body param - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` Body param - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl?: 600 | 1800 | 3600 | 7 more` Body param: Cache entry TTL in seconds. Allowed values: 600 (10min), 1800 (30min), 3600 (1h), 7200 (2h), 21600 (6h), 43200 (12h), 86400 (24h), 172800 (48h), 259200 (72h), 518400 (6d). - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk?: boolean` Body param - `chunk_overlap?: number` Body param - `chunk_size?: number` Body param - `custom_metadata?: Array` Body param - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model?: "@cf/qwen/qwen3-embedding-0.6b" | "@cf/qwen/qwen3-vl-embedding-2b" | "@cf/baai/bge-m3" | 8 more | null` Body param - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/qwen/qwen3-vl-embedding-2b"` - `"@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"` - `"google-ai-studio/gemini-embedding-2"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `fusion_method?: "max" | "rrf"` Body param - `"max"` - `"rrf"` - `hybrid_search_enabled?: boolean` Body param: Deprecated — use index_method instead. - `index_method?: IndexMethod` Body param: Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: boolean` Enable keyword (BM25) storage backend. - `vector: boolean` Enable vector (embedding) storage backend. - `indexing_options?: IndexingOptions | null` Body param - `keyword_tokenizer?: "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?: number` Body param - `metadata?: Metadata` Body param - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `public_endpoint_params?: PublicEndpointParams` Body param - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint - `reranking?: boolean` Body param - `reranking_model?: "@cf/baai/bge-reranker-base" | "" | null` Body param - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options?: RetrievalOptions | null` Body param - `boost_by?: Array` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric/datetime fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: "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. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'. - `"and"` - `"or"` - `rewrite_model?: "@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 | null` Body param - `"@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?: boolean` Body param - `score_threshold?: number` Body param - `source?: string | null` Body param - `source_params?: SourceParams | null` Body param - `exclude_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `include_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` Options for parse_type 'discover', where Browser Run discovers URLs by link following and sitemaps. Ignored for 'sitemap'. - `depth?: number` Maximum link-follow depth from the seed URL. - `include_external_links?: boolean` Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own. - `include_subdomains?: boolean` Follow links to subdomains of the source host. - `limit?: number` Maximum number of pages to crawl (1-100000). - `max_age?: number` Maximum content age in seconds to accept (0–604800). - `source?: "all" | "sitemaps" | "links"` Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both. - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` 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. Omit the field to disable content selection — empty arrays are rejected. - `path: string` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: string` CSS selector to extract content from pages matching the path pattern. Must not contain disallowed characters (;, `, $, {, }, ). Must target a single element; if multiple elements match, the selector is ignored and the full page is used. - `include_headers?: Record` Up to 5 custom HTTP headers sent with each crawl request. Names must be RFC-7230 token characters (no spaces, colons, or control characters); values must be HTAB + printable ASCII (no CR/LF). - `include_images?: boolean` - `specific_sitemaps?: Array` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account. - `"sitemap"` - `"discover"` - `sync_interval?: 900 | 1800 | 3600 | 5 more` Body param: 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?: string` Body param - `type?: "r2" | "web-crawler" | null` Body param - `"r2"` - `"web-crawler"` ### Returns - `InstanceCreateResponse` - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: string` - `modified_at: string` - `ai_gateway_id?: string | null` - `ai_search_model?: "@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 | null` - `"@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?: boolean` - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl?: 600 | 1800 | 3600 | 7 more` Cache entry TTL in seconds. Allowed values: 600 (10min), 1800 (30min), 3600 (1h), 7200 (2h), 21600 (6h), 43200 (12h), 86400 (24h), 172800 (48h), 259200 (72h), 518400 (6d). - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk_overlap?: number` - `chunk_size?: number` - `created_by?: string | null` - `custom_metadata?: Array` - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model?: "@cf/qwen/qwen3-embedding-0.6b" | "@cf/qwen/qwen3-vl-embedding-2b" | "@cf/baai/bge-m3" | 8 more | null` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/qwen/qwen3-vl-embedding-2b"` - `"@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"` - `"google-ai-studio/gemini-embedding-2"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable?: boolean` - `engine_version?: number` - `fusion_method?: "max" | "rrf"` - `"max"` - `"rrf"` - `hybrid_search_enabled?: boolean` Deprecated — use index_method instead. - `index_method?: IndexMethod` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: boolean` Enable keyword (BM25) storage backend. - `vector: boolean` Enable vector (embedding) storage backend. - `indexing_options?: IndexingOptions | null` - `keyword_tokenizer?: "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?: string | null` - `max_num_results?: number` - `metadata?: Metadata` - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `modified_by?: string | null` - `namespace?: string | null` - `paused?: boolean` - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint - `reranking?: boolean` - `reranking_model?: "@cf/baai/bge-reranker-base" | "" | null` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options?: RetrievalOptions | null` - `boost_by?: Array` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric/datetime fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: "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. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'. - `"and"` - `"or"` - `rewrite_model?: "@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 | null` - `"@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?: boolean` - `score_threshold?: number` - `source?: string | null` - `source_params?: SourceParams | null` - `exclude_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `include_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` Options for parse_type 'discover', where Browser Run discovers URLs by link following and sitemaps. Ignored for 'sitemap'. - `depth?: number` Maximum link-follow depth from the seed URL. - `include_external_links?: boolean` Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own. - `include_subdomains?: boolean` Follow links to subdomains of the source host. - `limit?: number` Maximum number of pages to crawl (1-100000). - `max_age?: number` Maximum content age in seconds to accept (0–604800). - `source?: "all" | "sitemaps" | "links"` Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both. - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` 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. Omit the field to disable content selection — empty arrays are rejected. - `path: string` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: string` CSS selector to extract content from pages matching the path pattern. Must not contain disallowed characters (;, `, $, {, }, ). Must target a single element; if multiple elements match, the selector is ignored and the full page is used. - `include_headers?: Record` Up to 5 custom HTTP headers sent with each crawl request. Names must be RFC-7230 token characters (no spaces, colons, or control characters); values must be HTAB + printable ASCII (no CR/LF). - `include_images?: boolean` - `specific_sitemaps?: Array` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account. - `"sitemap"` - `"discover"` - `status?: string` - `sync_interval?: 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?: string` - `type?: "r2" | "web-crawler" | null` - `"r2"` - `"web-crawler"` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const instance = await client.aiSearch.instances.create({ account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', id: 'my-ai-search', }); console.log(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", "cache_ttl": 600, "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, "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 }, "custom_domains": [ "search.example.com" ], "default_domain_enabled": 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": { "discover_options": { "depth": 5, "include_external_links": false, "include_subdomains": false, "limit": 10000, "max_age": 86400, "source": "all" }, "parse_options": { "content_selector": [ { "path": "**/blog/**", "selector": "article div.post-body" }, { "path": "**/docs/**", "selector": "main" } ], "include_headers": { "cache-control": "no-cache, no-store" }, "include_images": true, "specific_sitemaps": [ "https://example.com/sitemap.xml", "https://example.com/blog-sitemap.xml" ], "use_browser_rendering": true }, "parse_type": "sitemap" } }, "status": "status", "sync_interval": 900, "token_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "type": "r2" }, "success": true } ``` ## Get an AI Search instance. `client.aiSearch.instances.read(stringid, InstanceReadParamsparams, RequestOptionsoptions?): InstanceReadResponse` **get** `/accounts/{account_id}/ai-search/instances/{id}` Retrieve the configuration and status of an AI Search instance. ### Parameters - `id: string` - `params: InstanceReadParams` - `account_id: string` ### Returns - `InstanceReadResponse` - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: string` - `modified_at: string` - `ai_gateway_id?: string | null` - `ai_search_model?: "@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 | null` - `"@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?: boolean` - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl?: 600 | 1800 | 3600 | 7 more` Cache entry TTL in seconds. Allowed values: 600 (10min), 1800 (30min), 3600 (1h), 7200 (2h), 21600 (6h), 43200 (12h), 86400 (24h), 172800 (48h), 259200 (72h), 518400 (6d). - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk_overlap?: number` - `chunk_size?: number` - `created_by?: string | null` - `custom_metadata?: Array` - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model?: "@cf/qwen/qwen3-embedding-0.6b" | "@cf/qwen/qwen3-vl-embedding-2b" | "@cf/baai/bge-m3" | 8 more | null` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/qwen/qwen3-vl-embedding-2b"` - `"@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"` - `"google-ai-studio/gemini-embedding-2"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable?: boolean` - `engine_version?: number` - `fusion_method?: "max" | "rrf"` - `"max"` - `"rrf"` - `hybrid_search_enabled?: boolean` Deprecated — use index_method instead. - `index_method?: IndexMethod` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: boolean` Enable keyword (BM25) storage backend. - `vector: boolean` Enable vector (embedding) storage backend. - `indexing_options?: IndexingOptions | null` - `keyword_tokenizer?: "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?: string | null` - `max_num_results?: number` - `metadata?: Metadata` - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `modified_by?: string | null` - `namespace?: string | null` - `paused?: boolean` - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint - `reranking?: boolean` - `reranking_model?: "@cf/baai/bge-reranker-base" | "" | null` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options?: RetrievalOptions | null` - `boost_by?: Array` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric/datetime fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: "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. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'. - `"and"` - `"or"` - `rewrite_model?: "@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 | null` - `"@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?: boolean` - `score_threshold?: number` - `source?: string | null` - `source_params?: SourceParams | null` - `exclude_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `include_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` Options for parse_type 'discover', where Browser Run discovers URLs by link following and sitemaps. Ignored for 'sitemap'. - `depth?: number` Maximum link-follow depth from the seed URL. - `include_external_links?: boolean` Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own. - `include_subdomains?: boolean` Follow links to subdomains of the source host. - `limit?: number` Maximum number of pages to crawl (1-100000). - `max_age?: number` Maximum content age in seconds to accept (0–604800). - `source?: "all" | "sitemaps" | "links"` Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both. - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` 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. Omit the field to disable content selection — empty arrays are rejected. - `path: string` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: string` CSS selector to extract content from pages matching the path pattern. Must not contain disallowed characters (;, `, $, {, }, ). Must target a single element; if multiple elements match, the selector is ignored and the full page is used. - `include_headers?: Record` Up to 5 custom HTTP headers sent with each crawl request. Names must be RFC-7230 token characters (no spaces, colons, or control characters); values must be HTAB + printable ASCII (no CR/LF). - `include_images?: boolean` - `specific_sitemaps?: Array` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account. - `"sitemap"` - `"discover"` - `status?: string` - `sync_interval?: 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?: string` - `type?: "r2" | "web-crawler" | null` - `"r2"` - `"web-crawler"` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiSearch.instances.read('my-ai-search', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', }); console.log(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", "cache_ttl": 600, "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, "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 }, "custom_domains": [ "search.example.com" ], "default_domain_enabled": 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": { "discover_options": { "depth": 5, "include_external_links": false, "include_subdomains": false, "limit": 10000, "max_age": 86400, "source": "all" }, "parse_options": { "content_selector": [ { "path": "**/blog/**", "selector": "article div.post-body" }, { "path": "**/docs/**", "selector": "main" } ], "include_headers": { "cache-control": "no-cache, no-store" }, "include_images": true, "specific_sitemaps": [ "https://example.com/sitemap.xml", "https://example.com/blog-sitemap.xml" ], "use_browser_rendering": true }, "parse_type": "sitemap" } }, "status": "status", "sync_interval": 900, "token_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "type": "r2" }, "success": true } ``` ## Update an AI Search instance. `client.aiSearch.instances.update(stringid, InstanceUpdateParamsparams, RequestOptionsoptions?): InstanceUpdateResponse` **put** `/accounts/{account_id}/ai-search/instances/{id}` Update the configuration of an AI Search instance. ### Parameters - `id: string` - `params: InstanceUpdateParams` - `account_id: string` Path param - `ai_gateway_id?: string | null` Body param - `ai_search_model?: "@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 | null` Body param - `"@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?: boolean` Body param - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` Body param - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl?: 600 | 1800 | 3600 | 7 more` Body param: Cache entry TTL in seconds. Allowed values: 600 (10min), 1800 (30min), 3600 (1h), 7200 (2h), 21600 (6h), 43200 (12h), 86400 (24h), 172800 (48h), 259200 (72h), 518400 (6d). - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk?: boolean` Body param - `chunk_overlap?: number` Body param - `chunk_size?: number` Body param - `custom_metadata?: Array` Body param - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model?: "@cf/qwen/qwen3-embedding-0.6b" | "@cf/qwen/qwen3-vl-embedding-2b" | "@cf/baai/bge-m3" | 8 more | null` Body param - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/qwen/qwen3-vl-embedding-2b"` - `"@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"` - `"google-ai-studio/gemini-embedding-2"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `fusion_method?: "max" | "rrf"` Body param - `"max"` - `"rrf"` - `index_method?: IndexMethod` Body param: Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: boolean` Enable keyword (BM25) storage backend. - `vector: boolean` Enable vector (embedding) storage backend. - `indexing_options?: IndexingOptions | null` Body param - `keyword_tokenizer?: "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?: number` Body param - `metadata?: Metadata` Body param - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `paused?: boolean` Body param - `public_endpoint_params?: PublicEndpointParams` Body param - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint - `reranking?: boolean` Body param - `reranking_model?: "@cf/baai/bge-reranker-base" | "" | null` Body param - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options?: RetrievalOptions | null` Body param - `boost_by?: Array` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric/datetime fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: "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. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'. - `"and"` - `"or"` - `rewrite_model?: "@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 | null` Body param - `"@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?: boolean` Body param - `score_threshold?: number` Body param - `source?: string | null` Body param - `source_params?: SourceParams | null` Body param - `exclude_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `include_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` Options for parse_type 'discover', where Browser Run discovers URLs by link following and sitemaps. Ignored for 'sitemap'. - `depth?: number` Maximum link-follow depth from the seed URL. - `include_external_links?: boolean` Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own. - `include_subdomains?: boolean` Follow links to subdomains of the source host. - `limit?: number` Maximum number of pages to crawl (1-100000). - `max_age?: number` Maximum content age in seconds to accept (0–604800). - `source?: "all" | "sitemaps" | "links"` Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both. - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` 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. Omit the field to disable content selection — empty arrays are rejected. - `path: string` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: string` CSS selector to extract content from pages matching the path pattern. Must not contain disallowed characters (;, `, $, {, }, ). Must target a single element; if multiple elements match, the selector is ignored and the full page is used. - `include_headers?: Record` Up to 5 custom HTTP headers sent with each crawl request. Names must be RFC-7230 token characters (no spaces, colons, or control characters); values must be HTAB + printable ASCII (no CR/LF). - `include_images?: boolean` - `specific_sitemaps?: Array` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account. - `"sitemap"` - `"discover"` - `summarization?: boolean` Body param - `summarization_model?: "@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 | null` Body param - `"@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?: 900 | 1800 | 3600 | 5 more` Body param: 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_ai_search?: string | null` Body param - `system_prompt_index_summarization?: string | null` Body param - `system_prompt_rewrite_query?: string | null` Body param - `token_id?: string` Body param ### Returns - `InstanceUpdateResponse` - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: string` - `modified_at: string` - `ai_gateway_id?: string | null` - `ai_search_model?: "@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 | null` - `"@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?: boolean` - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl?: 600 | 1800 | 3600 | 7 more` Cache entry TTL in seconds. Allowed values: 600 (10min), 1800 (30min), 3600 (1h), 7200 (2h), 21600 (6h), 43200 (12h), 86400 (24h), 172800 (48h), 259200 (72h), 518400 (6d). - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk_overlap?: number` - `chunk_size?: number` - `created_by?: string | null` - `custom_metadata?: Array` - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model?: "@cf/qwen/qwen3-embedding-0.6b" | "@cf/qwen/qwen3-vl-embedding-2b" | "@cf/baai/bge-m3" | 8 more | null` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/qwen/qwen3-vl-embedding-2b"` - `"@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"` - `"google-ai-studio/gemini-embedding-2"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable?: boolean` - `engine_version?: number` - `fusion_method?: "max" | "rrf"` - `"max"` - `"rrf"` - `hybrid_search_enabled?: boolean` Deprecated — use index_method instead. - `index_method?: IndexMethod` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: boolean` Enable keyword (BM25) storage backend. - `vector: boolean` Enable vector (embedding) storage backend. - `indexing_options?: IndexingOptions | null` - `keyword_tokenizer?: "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?: string | null` - `max_num_results?: number` - `metadata?: Metadata` - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `modified_by?: string | null` - `namespace?: string | null` - `paused?: boolean` - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint - `reranking?: boolean` - `reranking_model?: "@cf/baai/bge-reranker-base" | "" | null` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options?: RetrievalOptions | null` - `boost_by?: Array` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric/datetime fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: "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. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'. - `"and"` - `"or"` - `rewrite_model?: "@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 | null` - `"@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?: boolean` - `score_threshold?: number` - `source?: string | null` - `source_params?: SourceParams | null` - `exclude_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `include_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` Options for parse_type 'discover', where Browser Run discovers URLs by link following and sitemaps. Ignored for 'sitemap'. - `depth?: number` Maximum link-follow depth from the seed URL. - `include_external_links?: boolean` Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own. - `include_subdomains?: boolean` Follow links to subdomains of the source host. - `limit?: number` Maximum number of pages to crawl (1-100000). - `max_age?: number` Maximum content age in seconds to accept (0–604800). - `source?: "all" | "sitemaps" | "links"` Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both. - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` 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. Omit the field to disable content selection — empty arrays are rejected. - `path: string` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: string` CSS selector to extract content from pages matching the path pattern. Must not contain disallowed characters (;, `, $, {, }, ). Must target a single element; if multiple elements match, the selector is ignored and the full page is used. - `include_headers?: Record` Up to 5 custom HTTP headers sent with each crawl request. Names must be RFC-7230 token characters (no spaces, colons, or control characters); values must be HTAB + printable ASCII (no CR/LF). - `include_images?: boolean` - `specific_sitemaps?: Array` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account. - `"sitemap"` - `"discover"` - `status?: string` - `sync_interval?: 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?: string` - `type?: "r2" | "web-crawler" | null` - `"r2"` - `"web-crawler"` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const instance = await client.aiSearch.instances.update('my-ai-search', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', }); console.log(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", "cache_ttl": 600, "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, "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 }, "custom_domains": [ "search.example.com" ], "default_domain_enabled": 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": { "discover_options": { "depth": 5, "include_external_links": false, "include_subdomains": false, "limit": 10000, "max_age": 86400, "source": "all" }, "parse_options": { "content_selector": [ { "path": "**/blog/**", "selector": "article div.post-body" }, { "path": "**/docs/**", "selector": "main" } ], "include_headers": { "cache-control": "no-cache, no-store" }, "include_images": true, "specific_sitemaps": [ "https://example.com/sitemap.xml", "https://example.com/blog-sitemap.xml" ], "use_browser_rendering": true }, "parse_type": "sitemap" } }, "status": "status", "sync_interval": 900, "token_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "type": "r2" }, "success": true } ``` ## Delete an AI Search instance. `client.aiSearch.instances.delete(stringid, InstanceDeleteParamsparams, RequestOptionsoptions?): InstanceDeleteResponse` **delete** `/accounts/{account_id}/ai-search/instances/{id}` Permanently delete an AI Search instance and all its indexed data. ### Parameters - `id: string` - `params: InstanceDeleteParams` - `account_id: string` ### Returns - `InstanceDeleteResponse` - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: string` - `modified_at: string` - `ai_gateway_id?: string | null` - `ai_search_model?: "@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 | null` - `"@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?: boolean` - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl?: 600 | 1800 | 3600 | 7 more` Cache entry TTL in seconds. Allowed values: 600 (10min), 1800 (30min), 3600 (1h), 7200 (2h), 21600 (6h), 43200 (12h), 86400 (24h), 172800 (48h), 259200 (72h), 518400 (6d). - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk_overlap?: number` - `chunk_size?: number` - `created_by?: string | null` - `custom_metadata?: Array` - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model?: "@cf/qwen/qwen3-embedding-0.6b" | "@cf/qwen/qwen3-vl-embedding-2b" | "@cf/baai/bge-m3" | 8 more | null` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/qwen/qwen3-vl-embedding-2b"` - `"@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"` - `"google-ai-studio/gemini-embedding-2"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable?: boolean` - `engine_version?: number` - `fusion_method?: "max" | "rrf"` - `"max"` - `"rrf"` - `hybrid_search_enabled?: boolean` Deprecated — use index_method instead. - `index_method?: IndexMethod` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: boolean` Enable keyword (BM25) storage backend. - `vector: boolean` Enable vector (embedding) storage backend. - `indexing_options?: IndexingOptions | null` - `keyword_tokenizer?: "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?: string | null` - `max_num_results?: number` - `metadata?: Metadata` - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `modified_by?: string | null` - `namespace?: string | null` - `paused?: boolean` - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint - `reranking?: boolean` - `reranking_model?: "@cf/baai/bge-reranker-base" | "" | null` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options?: RetrievalOptions | null` - `boost_by?: Array` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric/datetime fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: "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. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'. - `"and"` - `"or"` - `rewrite_model?: "@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 | null` - `"@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?: boolean` - `score_threshold?: number` - `source?: string | null` - `source_params?: SourceParams | null` - `exclude_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `include_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` Options for parse_type 'discover', where Browser Run discovers URLs by link following and sitemaps. Ignored for 'sitemap'. - `depth?: number` Maximum link-follow depth from the seed URL. - `include_external_links?: boolean` Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own. - `include_subdomains?: boolean` Follow links to subdomains of the source host. - `limit?: number` Maximum number of pages to crawl (1-100000). - `max_age?: number` Maximum content age in seconds to accept (0–604800). - `source?: "all" | "sitemaps" | "links"` Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both. - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` 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. Omit the field to disable content selection — empty arrays are rejected. - `path: string` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: string` CSS selector to extract content from pages matching the path pattern. Must not contain disallowed characters (;, `, $, {, }, ). Must target a single element; if multiple elements match, the selector is ignored and the full page is used. - `include_headers?: Record` Up to 5 custom HTTP headers sent with each crawl request. Names must be RFC-7230 token characters (no spaces, colons, or control characters); values must be HTAB + printable ASCII (no CR/LF). - `include_images?: boolean` - `specific_sitemaps?: Array` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account. - `"sitemap"` - `"discover"` - `status?: string` - `sync_interval?: 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?: string` - `type?: "r2" | "web-crawler" | null` - `"r2"` - `"web-crawler"` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const instance = await client.aiSearch.instances.delete('my-ai-search', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', }); console.log(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", "cache_ttl": 600, "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, "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 }, "custom_domains": [ "search.example.com" ], "default_domain_enabled": 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": { "discover_options": { "depth": 5, "include_external_links": false, "include_subdomains": false, "limit": 10000, "max_age": 86400, "source": "all" }, "parse_options": { "content_selector": [ { "path": "**/blog/**", "selector": "article div.post-body" }, { "path": "**/docs/**", "selector": "main" } ], "include_headers": { "cache-control": "no-cache, no-store" }, "include_images": true, "specific_sitemaps": [ "https://example.com/sitemap.xml", "https://example.com/blog-sitemap.xml" ], "use_browser_rendering": true }, "parse_type": "sitemap" } }, "status": "status", "sync_interval": 900, "token_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "type": "r2" }, "success": true } ``` ## Get instance statistics. `client.aiSearch.instances.stats(stringid, InstanceStatsParamsparams, RequestOptionsoptions?): InstanceStatsResponse` **get** `/accounts/{account_id}/ai-search/instances/{id}/stats` Retrieve usage and indexing statistics for an AI Search instance. ### Parameters - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `params: InstanceStatsParams` - `account_id: string` ### Returns - `InstanceStatsResponse` - `completed?: number` - `degraded?: boolean` True when status counts are unavailable (e.g. legacy stats query exceeded D1 statement-size limit). Counts are omitted in this case. - `engine?: Engine` Engine-specific metadata. Present only for managed (v3) instances. - `r2?: R2` R2 bucket storage usage in bytes. - `metadataSizeBytes: number` - `objectCount: number` - `payloadSizeBytes: number` - `vectorize?: Vectorize` Vectorize index metadata (dimensions, vector count). - `dimensions: number` - `vectorsCount: number` - `error?: number` - `file_embed_errors?: Record` - `index_source_errors?: Record` - `last_activity?: string` - `outdated?: number` - `queued?: number` - `running?: number` - `skipped?: number` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiSearch.instances.stats('my-ai-search', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', }); console.log(response.completed); ``` #### Response ```json { "result": { "completed": 0, "degraded": true, "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 `client.aiSearch.instances.search(stringid, InstanceSearchParamsparams, RequestOptionsoptions?): InstanceSearchResponse` **post** `/accounts/{account_id}/ai-search/instances/{id}/search` Executes a semantic search query against an AI Search instance to find relevant indexed content. ### Parameters - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `params: InstanceSearchParams` - `account_id: string` Path param - `ai_search_options?: AISearchOptions` Body param - `cache?: Cache` - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `enabled?: boolean` - `query_rewrite?: QueryRewrite` - `enabled?: boolean` - `model?: "@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?: string` - `reranking?: Reranking` - `enabled?: boolean` - `match_threshold?: number` - `model?: "@cf/baai/bge-reranker-base" | ""` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval?: Retrieval` - `boost_by?: Array` 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: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: number` - `filters?: Record` - `fusion_method?: "max" | "rrf"` - `"max"` - `"rrf"` - `keyword_match_mode?: "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. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'. - `"and"` - `"or"` - `match_threshold?: number` - `max_num_results?: number` - `retrieval_type?: "vector" | "keyword" | "hybrid"` - `"vector"` - `"keyword"` - `"hybrid"` - `return_on_failure?: boolean` - `messages?: Array` Body param: OpenAI-compatible message array. For multimodal queries, set the last user message's `content` to an array of typed parts: `[{type:'text', text:'…'}, {type:'image_url', image_url:{url:'…'}}]`. Image inputs require the RAG's embedding_model to declare 'image' in supported_modalities. - `content: string | Array | null` - `string` - `Array` - `UnionMember0` - `text: string` - `type: "text"` - `"text"` - `UnionMember1` - `image_url: ImageURL` - `url: string` - `type: "image_url"` - `"image_url"` - `UnionMember2` - `file: File` - `filename: string` - `file_data?: string` - `file_id?: string` - `type: "file"` - `"file"` - `role: "system" | "developer" | "user" | 2 more` - `"system"` - `"developer"` - `"user"` - `"assistant"` - `"tool"` - `query?: string` Body param: A simple text query string. Alternative to 'messages' — provide either this or 'messages', not both. ### Returns - `InstanceSearchResponse` - `chunks: Array` - `id: string` - `score: number` - `text: string` - `type: string` - `item?: Item` - `key: string` - `metadata?: Record` - `timestamp?: number` - `scoring_details?: ScoringDetails` - `fusion_method?: "rrf" | "max"` - `"rrf"` - `"max"` - `keyword_rank?: number` - `keyword_score?: number` - `reranking_score?: number` - `vector_rank?: number` - `vector_score?: number` - `query_kind: "text" | "image" | "multimodal"` - `"text"` - `"image"` - `"multimodal"` - `search_query?: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiSearch.instances.search('my-ai-search', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', }); console.log(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 } } ], "query_kind": "text", "search_query": "search_query" }, "success": true } ``` ## Chat Completions `client.aiSearch.instances.chatCompletions(stringid, InstanceChatCompletionsParamsparams, RequestOptionsoptions?): InstanceChatCompletionsResponse` **post** `/accounts/{account_id}/ai-search/instances/{id}/chat/completions` Performs a chat completion request against an AI Search instance, using indexed content as context for generating responses. ### Parameters - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `params: InstanceChatCompletionsParams` - `account_id: string` Path param - `messages: Array` Body param - `content: string | Array | null` - `string` - `Array` - `UnionMember0` - `text: string` - `type: "text"` - `"text"` - `UnionMember1` - `image_url: ImageURL` - `url: string` - `type: "image_url"` - `"image_url"` - `UnionMember2` - `file: File` - `filename: string` - `file_data?: string` - `file_id?: string` - `type: "file"` - `"file"` - `role: "system" | "developer" | "user" | 2 more` - `"system"` - `"developer"` - `"user"` - `"assistant"` - `"tool"` - `ai_search_options?: AISearchOptions` Body param - `cache?: Cache` - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `enabled?: boolean` - `query_rewrite?: QueryRewrite` - `enabled?: boolean` - `model?: "@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?: string` - `reranking?: Reranking` - `enabled?: boolean` - `match_threshold?: number` - `model?: "@cf/baai/bge-reranker-base" | ""` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval?: Retrieval` - `boost_by?: Array` 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: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: number` - `filters?: Record` - `fusion_method?: "max" | "rrf"` - `"max"` - `"rrf"` - `keyword_match_mode?: "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. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'. - `"and"` - `"or"` - `match_threshold?: number` - `max_num_results?: number` - `retrieval_type?: "vector" | "keyword" | "hybrid"` - `"vector"` - `"keyword"` - `"hybrid"` - `return_on_failure?: boolean` - `model?: "@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` Body param - `"@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?: boolean` Body param ### Returns - `InstanceChatCompletionsResponse` - `choices: Array` - `message: Message` - `content: string | Array | null` - `string` - `Array` - `UnionMember0` - `text: string` - `type: "text"` - `"text"` - `UnionMember1` - `image_url: ImageURL` - `url: string` - `type: "image_url"` - `"image_url"` - `UnionMember2` - `file: File` - `filename: string` - `file_data?: string` - `file_id?: string` - `type: "file"` - `"file"` - `role: "system" | "developer" | "user" | 2 more` - `"system"` - `"developer"` - `"user"` - `"assistant"` - `"tool"` - `index?: number` - `chunks: Array` - `id: string` - `score: number` - `text: string` - `type: string` - `item?: Item` - `key: string` - `metadata?: Record` - `timestamp?: number` - `scoring_details?: ScoringDetails` - `fusion_method?: "rrf" | "max"` - `"rrf"` - `"max"` - `keyword_rank?: number` - `keyword_score?: number` - `reranking_score?: number` - `vector_rank?: number` - `vector_score?: number` - `id?: string` - `model?: string` - `object?: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiSearch.instances.chatCompletions('my-ai-search', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', messages: [{ content: 'string', role: 'system' }], }); console.log(response.id); ``` #### Response ```json { "choices": [ { "message": { "content": "string", "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 - `InstanceListResponse` - `id: string` - `ai_gateway_id: string | null` - `ai_search_model: string | null` - `cache: boolean` - `cache_threshold: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes" | null` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl: 600 | 1800 | 3600 | 7 more` - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk: boolean` - `chunk_overlap: number | null` - `chunk_size: number | null` - `created_at: string` - `created_by: string | null` - `custom_metadata: Array | null` - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model: string | null` - `enable: boolean` - `engine_version: number` - `fusion_method: "max" | "rrf"` - `"max"` - `"rrf"` - `hybrid_search_enabled: boolean` - `index_method: IndexMethod` - `keyword: boolean` - `vector: boolean` - `indexing_options: IndexingOptions | null` - `keyword_tokenizer?: "porter" | "trigram"` - `"porter"` - `"trigram"` - `last_activity: string | null` - `max_num_results: number | null` - `metadata: Metadata | null` - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `modified_at: string` - `modified_by: string | null` - `namespace: string` - `paused: boolean` - `public_endpoint_id: string | null` - `public_endpoint_params: PublicEndpointParams | null` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` - `custom_domains?: Array | null` - `default_domain_enabled?: boolean` - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` - `reranking: boolean` - `reranking_model: string | null` - `retrieval_options: RetrievalOptions | null` - `boost_by?: Array` - `field: string` - `dataType?: "number" | "datetime" | "text" | "boolean"` - `"number"` - `"datetime"` - `"text"` - `"boolean"` - `direction?: "asc" | "desc" | "exists" | "not_exists"` - `"asc"` - `"desc"` - `"exists"` - `"not_exists"` - `keyword_match_mode?: "and" | "or"` - `"and"` - `"or"` - `rewrite_model: string | null` - `rewrite_query: boolean` - `score_threshold: number | null` - `source: string | null` - `source_params: SourceParams | null` - `exclude_items?: Array` - `include_items?: Array` - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` - `depth?: number` - `include_external_links?: boolean` - `include_subdomains?: boolean` - `limit?: number` Maximum number of pages to crawl. New values are capped at 100000; instances configured before that cap may report a higher stored value, which the crawler clamps at run time. - `max_age?: number` - `source?: "all" | "sitemaps" | "links"` - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` - `path: string` - `selector: string` - `include_headers?: Record` - `include_images?: boolean` - `specific_sitemaps?: Array` - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` - `"sitemap"` - `"discover"` - `status: string` - `summarization: boolean` - `summarization_model: string | null` - `sync_interval: 900 | 1800 | 3600 | 5 more` - `900` - `1800` - `3600` - `7200` - `14400` - `21600` - `43200` - `86400` - `system_prompt_ai_search: string | null` - `system_prompt_index_summarization: string | null` - `system_prompt_rewrite_query: string | null` - `token_id: string | null` - `type: "r2" | "web-crawler" | null` - `"r2"` - `"web-crawler"` ### Instance Create Response - `InstanceCreateResponse` - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: string` - `modified_at: string` - `ai_gateway_id?: string | null` - `ai_search_model?: "@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 | null` - `"@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?: boolean` - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl?: 600 | 1800 | 3600 | 7 more` Cache entry TTL in seconds. Allowed values: 600 (10min), 1800 (30min), 3600 (1h), 7200 (2h), 21600 (6h), 43200 (12h), 86400 (24h), 172800 (48h), 259200 (72h), 518400 (6d). - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk_overlap?: number` - `chunk_size?: number` - `created_by?: string | null` - `custom_metadata?: Array` - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model?: "@cf/qwen/qwen3-embedding-0.6b" | "@cf/qwen/qwen3-vl-embedding-2b" | "@cf/baai/bge-m3" | 8 more | null` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/qwen/qwen3-vl-embedding-2b"` - `"@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"` - `"google-ai-studio/gemini-embedding-2"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable?: boolean` - `engine_version?: number` - `fusion_method?: "max" | "rrf"` - `"max"` - `"rrf"` - `hybrid_search_enabled?: boolean` Deprecated — use index_method instead. - `index_method?: IndexMethod` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: boolean` Enable keyword (BM25) storage backend. - `vector: boolean` Enable vector (embedding) storage backend. - `indexing_options?: IndexingOptions | null` - `keyword_tokenizer?: "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?: string | null` - `max_num_results?: number` - `metadata?: Metadata` - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `modified_by?: string | null` - `namespace?: string | null` - `paused?: boolean` - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint - `reranking?: boolean` - `reranking_model?: "@cf/baai/bge-reranker-base" | "" | null` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options?: RetrievalOptions | null` - `boost_by?: Array` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric/datetime fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: "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. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'. - `"and"` - `"or"` - `rewrite_model?: "@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 | null` - `"@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?: boolean` - `score_threshold?: number` - `source?: string | null` - `source_params?: SourceParams | null` - `exclude_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `include_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` Options for parse_type 'discover', where Browser Run discovers URLs by link following and sitemaps. Ignored for 'sitemap'. - `depth?: number` Maximum link-follow depth from the seed URL. - `include_external_links?: boolean` Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own. - `include_subdomains?: boolean` Follow links to subdomains of the source host. - `limit?: number` Maximum number of pages to crawl (1-100000). - `max_age?: number` Maximum content age in seconds to accept (0–604800). - `source?: "all" | "sitemaps" | "links"` Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both. - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` 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. Omit the field to disable content selection — empty arrays are rejected. - `path: string` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: string` CSS selector to extract content from pages matching the path pattern. Must not contain disallowed characters (;, `, $, {, }, ). Must target a single element; if multiple elements match, the selector is ignored and the full page is used. - `include_headers?: Record` Up to 5 custom HTTP headers sent with each crawl request. Names must be RFC-7230 token characters (no spaces, colons, or control characters); values must be HTAB + printable ASCII (no CR/LF). - `include_images?: boolean` - `specific_sitemaps?: Array` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account. - `"sitemap"` - `"discover"` - `status?: string` - `sync_interval?: 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?: string` - `type?: "r2" | "web-crawler" | null` - `"r2"` - `"web-crawler"` ### Instance Read Response - `InstanceReadResponse` - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: string` - `modified_at: string` - `ai_gateway_id?: string | null` - `ai_search_model?: "@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 | null` - `"@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?: boolean` - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl?: 600 | 1800 | 3600 | 7 more` Cache entry TTL in seconds. Allowed values: 600 (10min), 1800 (30min), 3600 (1h), 7200 (2h), 21600 (6h), 43200 (12h), 86400 (24h), 172800 (48h), 259200 (72h), 518400 (6d). - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk_overlap?: number` - `chunk_size?: number` - `created_by?: string | null` - `custom_metadata?: Array` - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model?: "@cf/qwen/qwen3-embedding-0.6b" | "@cf/qwen/qwen3-vl-embedding-2b" | "@cf/baai/bge-m3" | 8 more | null` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/qwen/qwen3-vl-embedding-2b"` - `"@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"` - `"google-ai-studio/gemini-embedding-2"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable?: boolean` - `engine_version?: number` - `fusion_method?: "max" | "rrf"` - `"max"` - `"rrf"` - `hybrid_search_enabled?: boolean` Deprecated — use index_method instead. - `index_method?: IndexMethod` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: boolean` Enable keyword (BM25) storage backend. - `vector: boolean` Enable vector (embedding) storage backend. - `indexing_options?: IndexingOptions | null` - `keyword_tokenizer?: "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?: string | null` - `max_num_results?: number` - `metadata?: Metadata` - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `modified_by?: string | null` - `namespace?: string | null` - `paused?: boolean` - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint - `reranking?: boolean` - `reranking_model?: "@cf/baai/bge-reranker-base" | "" | null` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options?: RetrievalOptions | null` - `boost_by?: Array` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric/datetime fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: "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. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'. - `"and"` - `"or"` - `rewrite_model?: "@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 | null` - `"@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?: boolean` - `score_threshold?: number` - `source?: string | null` - `source_params?: SourceParams | null` - `exclude_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `include_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` Options for parse_type 'discover', where Browser Run discovers URLs by link following and sitemaps. Ignored for 'sitemap'. - `depth?: number` Maximum link-follow depth from the seed URL. - `include_external_links?: boolean` Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own. - `include_subdomains?: boolean` Follow links to subdomains of the source host. - `limit?: number` Maximum number of pages to crawl (1-100000). - `max_age?: number` Maximum content age in seconds to accept (0–604800). - `source?: "all" | "sitemaps" | "links"` Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both. - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` 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. Omit the field to disable content selection — empty arrays are rejected. - `path: string` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: string` CSS selector to extract content from pages matching the path pattern. Must not contain disallowed characters (;, `, $, {, }, ). Must target a single element; if multiple elements match, the selector is ignored and the full page is used. - `include_headers?: Record` Up to 5 custom HTTP headers sent with each crawl request. Names must be RFC-7230 token characters (no spaces, colons, or control characters); values must be HTAB + printable ASCII (no CR/LF). - `include_images?: boolean` - `specific_sitemaps?: Array` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account. - `"sitemap"` - `"discover"` - `status?: string` - `sync_interval?: 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?: string` - `type?: "r2" | "web-crawler" | null` - `"r2"` - `"web-crawler"` ### Instance Update Response - `InstanceUpdateResponse` - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: string` - `modified_at: string` - `ai_gateway_id?: string | null` - `ai_search_model?: "@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 | null` - `"@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?: boolean` - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl?: 600 | 1800 | 3600 | 7 more` Cache entry TTL in seconds. Allowed values: 600 (10min), 1800 (30min), 3600 (1h), 7200 (2h), 21600 (6h), 43200 (12h), 86400 (24h), 172800 (48h), 259200 (72h), 518400 (6d). - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk_overlap?: number` - `chunk_size?: number` - `created_by?: string | null` - `custom_metadata?: Array` - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model?: "@cf/qwen/qwen3-embedding-0.6b" | "@cf/qwen/qwen3-vl-embedding-2b" | "@cf/baai/bge-m3" | 8 more | null` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/qwen/qwen3-vl-embedding-2b"` - `"@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"` - `"google-ai-studio/gemini-embedding-2"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable?: boolean` - `engine_version?: number` - `fusion_method?: "max" | "rrf"` - `"max"` - `"rrf"` - `hybrid_search_enabled?: boolean` Deprecated — use index_method instead. - `index_method?: IndexMethod` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: boolean` Enable keyword (BM25) storage backend. - `vector: boolean` Enable vector (embedding) storage backend. - `indexing_options?: IndexingOptions | null` - `keyword_tokenizer?: "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?: string | null` - `max_num_results?: number` - `metadata?: Metadata` - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `modified_by?: string | null` - `namespace?: string | null` - `paused?: boolean` - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint - `reranking?: boolean` - `reranking_model?: "@cf/baai/bge-reranker-base" | "" | null` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options?: RetrievalOptions | null` - `boost_by?: Array` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric/datetime fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: "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. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'. - `"and"` - `"or"` - `rewrite_model?: "@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 | null` - `"@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?: boolean` - `score_threshold?: number` - `source?: string | null` - `source_params?: SourceParams | null` - `exclude_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `include_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` Options for parse_type 'discover', where Browser Run discovers URLs by link following and sitemaps. Ignored for 'sitemap'. - `depth?: number` Maximum link-follow depth from the seed URL. - `include_external_links?: boolean` Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own. - `include_subdomains?: boolean` Follow links to subdomains of the source host. - `limit?: number` Maximum number of pages to crawl (1-100000). - `max_age?: number` Maximum content age in seconds to accept (0–604800). - `source?: "all" | "sitemaps" | "links"` Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both. - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` 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. Omit the field to disable content selection — empty arrays are rejected. - `path: string` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: string` CSS selector to extract content from pages matching the path pattern. Must not contain disallowed characters (;, `, $, {, }, ). Must target a single element; if multiple elements match, the selector is ignored and the full page is used. - `include_headers?: Record` Up to 5 custom HTTP headers sent with each crawl request. Names must be RFC-7230 token characters (no spaces, colons, or control characters); values must be HTAB + printable ASCII (no CR/LF). - `include_images?: boolean` - `specific_sitemaps?: Array` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account. - `"sitemap"` - `"discover"` - `status?: string` - `sync_interval?: 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?: string` - `type?: "r2" | "web-crawler" | null` - `"r2"` - `"web-crawler"` ### Instance Delete Response - `InstanceDeleteResponse` - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `created_at: string` - `modified_at: string` - `ai_gateway_id?: string | null` - `ai_search_model?: "@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 | null` - `"@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?: boolean` - `cache_threshold?: "super_strict_match" | "close_enough" | "flexible_friend" | "anything_goes"` - `"super_strict_match"` - `"close_enough"` - `"flexible_friend"` - `"anything_goes"` - `cache_ttl?: 600 | 1800 | 3600 | 7 more` Cache entry TTL in seconds. Allowed values: 600 (10min), 1800 (30min), 3600 (1h), 7200 (2h), 21600 (6h), 43200 (12h), 86400 (24h), 172800 (48h), 259200 (72h), 518400 (6d). - `600` - `1800` - `3600` - `7200` - `21600` - `43200` - `86400` - `172800` - `259200` - `518400` - `chunk_overlap?: number` - `chunk_size?: number` - `created_by?: string | null` - `custom_metadata?: Array` - `data_type: "text" | "number" | "boolean" | "datetime"` - `"text"` - `"number"` - `"boolean"` - `"datetime"` - `field_name: string` - `embedding_model?: "@cf/qwen/qwen3-embedding-0.6b" | "@cf/qwen/qwen3-vl-embedding-2b" | "@cf/baai/bge-m3" | 8 more | null` - `"@cf/qwen/qwen3-embedding-0.6b"` - `"@cf/qwen/qwen3-vl-embedding-2b"` - `"@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"` - `"google-ai-studio/gemini-embedding-2"` - `"openai/text-embedding-3-small"` - `"openai/text-embedding-3-large"` - `""` - `enable?: boolean` - `engine_version?: number` - `fusion_method?: "max" | "rrf"` - `"max"` - `"rrf"` - `hybrid_search_enabled?: boolean` Deprecated — use index_method instead. - `index_method?: IndexMethod` Controls which storage backends are used during indexing. Defaults to vector-only. - `keyword: boolean` Enable keyword (BM25) storage backend. - `vector: boolean` Enable vector (embedding) storage backend. - `indexing_options?: IndexingOptions | null` - `keyword_tokenizer?: "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?: string | null` - `max_num_results?: number` - `metadata?: Metadata` - `created_from_aisearch_wizard?: boolean` - `worker_domain?: string` - `modified_by?: string | null` - `namespace?: string | null` - `paused?: boolean` - `public_endpoint_id?: string | null` - `public_endpoint_params?: PublicEndpointParams` - `authorized_hosts?: Array` - `chat_completions_endpoint?: ChatCompletionsEndpoint` - `disabled?: boolean` Disable chat completions endpoint for this public endpoint - `custom_domains?: Array | null` Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged). - `default_domain_enabled?: boolean` When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true. - `enabled?: boolean` - `mcp?: Mcp` - `description?: string` - `disabled?: boolean` Disable MCP endpoint for this public endpoint - `rate_limit?: RateLimit` - `period_ms?: number` - `requests?: number` - `technique?: "fixed" | "sliding"` - `"fixed"` - `"sliding"` - `search_endpoint?: SearchEndpoint` - `disabled?: boolean` Disable search endpoint for this public endpoint - `reranking?: boolean` - `reranking_model?: "@cf/baai/bge-reranker-base" | "" | null` - `"@cf/baai/bge-reranker-base"` - `""` - `retrieval_options?: RetrievalOptions | null` - `boost_by?: Array` Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric/datetime fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. - `field: string` Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists. - `direction?: "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?: "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. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'. - `"and"` - `"or"` - `rewrite_model?: "@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 | null` - `"@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?: boolean` - `score_threshold?: number` - `source?: string | null` - `source_params?: SourceParams | null` - `exclude_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `include_items?: Array` 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). Most accounts are limited to 10 rules; contact support to raise it. - `prefix?: string` - `r2_jurisdiction?: string` - `web_crawler?: WebCrawler` - `discover_options?: DiscoverOptions` Options for parse_type 'discover', where Browser Run discovers URLs by link following and sitemaps. Ignored for 'sitemap'. - `depth?: number` Maximum link-follow depth from the seed URL. - `include_external_links?: boolean` Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own. - `include_subdomains?: boolean` Follow links to subdomains of the source host. - `limit?: number` Maximum number of pages to crawl (1-100000). - `max_age?: number` Maximum content age in seconds to accept (0–604800). - `source?: "all" | "sitemaps" | "links"` Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both. - `"all"` - `"sitemaps"` - `"links"` - `parse_options?: ParseOptions` - `content_selector?: Array` 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. Omit the field to disable content selection — empty arrays are rejected. - `path: string` Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories. - `selector: string` CSS selector to extract content from pages matching the path pattern. Must not contain disallowed characters (;, `, $, {, }, ). Must target a single element; if multiple elements match, the selector is ignored and the full page is used. - `include_headers?: Record` Up to 5 custom HTTP headers sent with each crawl request. Names must be RFC-7230 token characters (no spaces, colons, or control characters); values must be HTAB + printable ASCII (no CR/LF). - `include_images?: boolean` - `specific_sitemaps?: Array` List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'. - `use_browser_rendering?: boolean` - `parse_type?: "sitemap" | "discover"` How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account. - `"sitemap"` - `"discover"` - `status?: string` - `sync_interval?: 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?: string` - `type?: "r2" | "web-crawler" | null` - `"r2"` - `"web-crawler"` ### Instance Stats Response - `InstanceStatsResponse` - `completed?: number` - `degraded?: boolean` True when status counts are unavailable (e.g. legacy stats query exceeded D1 statement-size limit). Counts are omitted in this case. - `engine?: Engine` Engine-specific metadata. Present only for managed (v3) instances. - `r2?: R2` R2 bucket storage usage in bytes. - `metadataSizeBytes: number` - `objectCount: number` - `payloadSizeBytes: number` - `vectorize?: Vectorize` Vectorize index metadata (dimensions, vector count). - `dimensions: number` - `vectorsCount: number` - `error?: number` - `file_embed_errors?: Record` - `index_source_errors?: Record` - `last_activity?: string` - `outdated?: number` - `queued?: number` - `running?: number` - `skipped?: number` ### Instance Search Response - `InstanceSearchResponse` - `chunks: Array` - `id: string` - `score: number` - `text: string` - `type: string` - `item?: Item` - `key: string` - `metadata?: Record` - `timestamp?: number` - `scoring_details?: ScoringDetails` - `fusion_method?: "rrf" | "max"` - `"rrf"` - `"max"` - `keyword_rank?: number` - `keyword_score?: number` - `reranking_score?: number` - `vector_rank?: number` - `vector_score?: number` - `query_kind: "text" | "image" | "multimodal"` - `"text"` - `"image"` - `"multimodal"` - `search_query?: string` ### Instance Chat Completions Response - `InstanceChatCompletionsResponse` - `choices: Array` - `message: Message` - `content: string | Array | null` - `string` - `Array` - `UnionMember0` - `text: string` - `type: "text"` - `"text"` - `UnionMember1` - `image_url: ImageURL` - `url: string` - `type: "image_url"` - `"image_url"` - `UnionMember2` - `file: File` - `filename: string` - `file_data?: string` - `file_id?: string` - `type: "file"` - `"file"` - `role: "system" | "developer" | "user" | 2 more` - `"system"` - `"developer"` - `"user"` - `"assistant"` - `"tool"` - `index?: number` - `chunks: Array` - `id: string` - `score: number` - `text: string` - `type: string` - `item?: Item` - `key: string` - `metadata?: Record` - `timestamp?: number` - `scoring_details?: ScoringDetails` - `fusion_method?: "rrf" | "max"` - `"rrf"` - `"max"` - `keyword_rank?: number` - `keyword_score?: number` - `reranking_score?: number` - `vector_rank?: number` - `vector_score?: number` - `id?: string` - `model?: string` - `object?: string` # Jobs ## List Jobs `client.aiSearch.instances.jobs.list(stringid, JobListParamsparams, RequestOptionsoptions?): V4PagePaginationArray` **get** `/accounts/{account_id}/ai-search/instances/{id}/jobs` Lists indexing jobs for an AI Search instance. ### Parameters - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `params: JobListParams` - `account_id: string` Path param - `page?: number` Query param - `per_page?: number` Query param ### Returns - `JobListResponse` - `id: string` - `source: "user" | "schedule"` - `"user"` - `"schedule"` - `description?: string` - `end_reason?: string` - `ended_at?: string` - `last_seen_at?: string` - `started_at?: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const jobListResponse of client.aiSearch.instances.jobs.list('my-ai-search', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', })) { console.log(jobListResponse.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 `client.aiSearch.instances.jobs.create(stringid, JobCreateParamsparams, RequestOptionsoptions?): JobCreateResponse` **post** `/accounts/{account_id}/ai-search/instances/{id}/jobs` Creates a new indexing job for an AI Search instance. ### Parameters - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `params: JobCreateParams` - `account_id: string` Path param - `description?: string` Body param ### Returns - `JobCreateResponse` - `id: string` - `source: "user" | "schedule"` - `"user"` - `"schedule"` - `description?: string` - `end_reason?: string` - `ended_at?: string` - `last_seen_at?: string` - `started_at?: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const job = await client.aiSearch.instances.jobs.create('my-ai-search', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', }); console.log(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 `client.aiSearch.instances.jobs.get(stringjobID, JobGetParamsparams, RequestOptionsoptions?): JobGetResponse` **get** `/accounts/{account_id}/ai-search/instances/{id}/jobs/{job_id}` Retrieves details for a specific AI Search indexing job. ### Parameters - `jobID: string` - `params: JobGetParams` - `account_id: string` - `id: string` AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. ### Returns - `JobGetResponse` - `id: string` - `source: "user" | "schedule"` - `"user"` - `"schedule"` - `description?: string` - `end_reason?: string` - `ended_at?: string` - `last_seen_at?: string` - `started_at?: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const job = await client.aiSearch.instances.jobs.get('job_id', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', id: 'my-ai-search', }); console.log(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 `client.aiSearch.instances.jobs.logs(stringjobID, JobLogsParamsparams, RequestOptionsoptions?): JobLogsResponse` **get** `/accounts/{account_id}/ai-search/instances/{id}/jobs/{job_id}/logs` Lists log entries for an AI Search indexing job. ### Parameters - `jobID: string` - `params: JobLogsParams` - `account_id: string` Path param - `id: string` Path param: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. - `page?: number` Query param - `per_page?: number` Query param ### Returns - `JobLogsResponse = Array` - `id: number` - `created_at: number` - `message: string` - `message_type: number` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiSearch.instances.jobs.logs('job_id', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', id: 'my-ai-search', }); console.log(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 - `JobListResponse` - `id: string` - `source: "user" | "schedule"` - `"user"` - `"schedule"` - `description?: string` - `end_reason?: string` - `ended_at?: string` - `last_seen_at?: string` - `started_at?: string` ### Job Create Response - `JobCreateResponse` - `id: string` - `source: "user" | "schedule"` - `"user"` - `"schedule"` - `description?: string` - `end_reason?: string` - `ended_at?: string` - `last_seen_at?: string` - `started_at?: string` ### Job Get Response - `JobGetResponse` - `id: string` - `source: "user" | "schedule"` - `"user"` - `"schedule"` - `description?: string` - `end_reason?: string` - `ended_at?: string` - `last_seen_at?: string` - `started_at?: string` ### Job Logs Response - `JobLogsResponse = Array` - `id: number` - `created_at: number` - `message: string` - `message_type: number` # Tokens ## List tokens `client.aiSearch.tokens.list(TokenListParamsparams, RequestOptionsoptions?): V4PagePaginationArray` **get** `/accounts/{account_id}/ai-search/tokens` List stored AI Search credentials in the account without exposing their secrets. ### Parameters - `params: TokenListParams` - `account_id: string` Path param - `page?: number` Query param: Page number (1-indexed). - `per_page?: number` Query param: Number of results per page. - `search?: string` Query param: Filter tokens whose name contains this string (case-insensitive). ### Returns - `TokenListResponse` - `id: string` - `cf_api_id: string` - `created_at: string` - `modified_at: string` - `name: string` - `created_by?: string | null` - `enabled?: boolean` - `legacy?: boolean` - `modified_by?: string | null` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const tokenListResponse of client.aiSearch.tokens.list({ account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', })) { console.log(tokenListResponse.id); } ``` #### Response ```json { "result": [ { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "cf_api_id": "cf_api_id", "created_at": "2019-12-27T18:11:19.117Z", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name", "created_by": "created_by", "enabled": true, "legacy": true, "modified_by": "modified_by" } ], "result_info": { "count": 0, "page": 0, "per_page": 0, "total_count": 0 }, "success": true } ``` ## Create a token `client.aiSearch.tokens.create(TokenCreateParamsparams, RequestOptionsoptions?): TokenCreateResponse` **post** `/accounts/{account_id}/ai-search/tokens` Create a stored Cloudflare credential for an AI Search instance to access its data source. ### Parameters - `params: TokenCreateParams` - `account_id: string` Path param - `cf_api_id: string` Body param - `cf_api_key: string` Body param - `name: string` Body param - `legacy?: boolean` Body param ### Returns - `TokenCreateResponse` - `id: string` - `cf_api_id: string` - `created_at: string` - `modified_at: string` - `name: string` - `created_by?: string | null` - `enabled?: boolean` - `legacy?: boolean` - `modified_by?: string | null` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const token = await client.aiSearch.tokens.create({ account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', cf_api_id: 'a1b2c3d4e5f6', cf_api_key: 'abc123', name: 'my-token', }); console.log(token.id); ``` #### Response ```json { "result": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "cf_api_id": "cf_api_id", "created_at": "2019-12-27T18:11:19.117Z", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name", "created_by": "created_by", "enabled": true, "legacy": true, "modified_by": "modified_by" }, "success": true } ``` ## Get a token `client.aiSearch.tokens.read(stringid, TokenReadParamsparams, RequestOptionsoptions?): TokenReadResponse` **get** `/accounts/{account_id}/ai-search/tokens/{id}` Retrieve a stored AI Search credential without exposing its secret. ### Parameters - `id: string` - `params: TokenReadParams` - `account_id: string` ### Returns - `TokenReadResponse` - `id: string` - `cf_api_id: string` - `created_at: string` - `modified_at: string` - `name: string` - `created_by?: string | null` - `enabled?: boolean` - `legacy?: boolean` - `modified_by?: string | null` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiSearch.tokens.read('62af0db3-c410-40b2-9ee3-0e93f6dd1de0', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', }); console.log(response.id); ``` #### Response ```json { "result": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "cf_api_id": "cf_api_id", "created_at": "2019-12-27T18:11:19.117Z", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name", "created_by": "created_by", "enabled": true, "legacy": true, "modified_by": "modified_by" }, "success": true } ``` ## Update a token `client.aiSearch.tokens.update(stringid, TokenUpdateParamsparams, RequestOptionsoptions?): TokenUpdateResponse` **put** `/accounts/{account_id}/ai-search/tokens/{id}` Replace a stored AI Search credential and invalidate cached credentials for instances that use it. ### Parameters - `id: string` - `params: TokenUpdateParams` - `account_id: string` Path param - `cf_api_id: string` Body param - `cf_api_key: string` Body param - `name: string` Body param - `legacy?: boolean` Body param ### Returns - `TokenUpdateResponse` - `id: string` - `cf_api_id: string` - `created_at: string` - `modified_at: string` - `name: string` - `created_by?: string | null` - `enabled?: boolean` - `legacy?: boolean` - `modified_by?: string | null` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const token = await client.aiSearch.tokens.update('62af0db3-c410-40b2-9ee3-0e93f6dd1de0', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', cf_api_id: 'a1b2c3d4e5f6', cf_api_key: 'abc123', name: 'my-token', }); console.log(token.id); ``` #### Response ```json { "result": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "cf_api_id": "cf_api_id", "created_at": "2019-12-27T18:11:19.117Z", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name", "created_by": "created_by", "enabled": true, "legacy": true, "modified_by": "modified_by" }, "success": true } ``` ## Delete a token `client.aiSearch.tokens.delete(stringid, TokenDeleteParamsparams, RequestOptionsoptions?): TokenDeleteResponse` **delete** `/accounts/{account_id}/ai-search/tokens/{id}` Permanently delete a stored AI Search credential. Credentials in use by an instance cannot be deleted. ### Parameters - `id: string` - `params: TokenDeleteParams` - `account_id: string` ### Returns - `TokenDeleteResponse = unknown` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const token = await client.aiSearch.tokens.delete('62af0db3-c410-40b2-9ee3-0e93f6dd1de0', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', }); console.log(token); ``` #### Response ```json { "result": {}, "success": true } ``` ## Domain Types ### Token List Response - `TokenListResponse` - `id: string` - `cf_api_id: string` - `created_at: string` - `modified_at: string` - `name: string` - `created_by?: string | null` - `enabled?: boolean` - `legacy?: boolean` - `modified_by?: string | null` ### Token Create Response - `TokenCreateResponse` - `id: string` - `cf_api_id: string` - `created_at: string` - `modified_at: string` - `name: string` - `created_by?: string | null` - `enabled?: boolean` - `legacy?: boolean` - `modified_by?: string | null` ### Token Read Response - `TokenReadResponse` - `id: string` - `cf_api_id: string` - `created_at: string` - `modified_at: string` - `name: string` - `created_by?: string | null` - `enabled?: boolean` - `legacy?: boolean` - `modified_by?: string | null` ### Token Update Response - `TokenUpdateResponse` - `id: string` - `cf_api_id: string` - `created_at: string` - `modified_at: string` - `name: string` - `created_by?: string | null` - `enabled?: boolean` - `legacy?: boolean` - `modified_by?: string | null` ### Token Delete Response - `TokenDeleteResponse = unknown`