{"command":{"effect":"write","timeoutSeconds":30,"inputSchema":{"type":"object","description":"Executes a semantic search query against an AI Search instance to find relevant indexed content.","properties":{"path":{"type":"object","properties":{"id":{"description":"AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.","type":"string","maxLength":64,"minLength":1,"pattern":"^[a-z0-9_]+(?:-[a-z0-9_]+)*$","examples":["my-ai-search"]},"account_id":{"type":"string","examples":["c3dc5f0b34a14ff8e1b3ec04895e1b22"]},"namespace":{"type":"string","default":"default","examples":["my-namespace"],"description":"Namespace name."}},"required":["id","account_id","namespace"],"additionalProperties":false},"body":{"type":"object","properties":{"ai_search_options":{"type":"object","properties":{"cache":{"type":"object","properties":{"cache_threshold":{"type":"string","enum":["super_strict_match","close_enough","flexible_friend","anything_goes"]},"enabled":{"type":"boolean"}}},"custom_metadata":{"description":"Metadata added to AI Gateway logs for requests this operation triggers. Accepts up to 2 string, number, or boolean entries. Reserved keys: 'ai-search', 'task', 'origin', and any key beginning with 'cf.'.","type":"object","additionalProperties":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}]},"maxProperties":2,"examples":[{"test":true,"user_id":"user-123"}]},"query_rewrite":{"type":"object","properties":{"enabled":{"type":"boolean"},"model":{"description":"A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.","type":"string"},"rewrite_prompt":{"type":"string"}}},"reranking":{"type":"object","properties":{"enabled":{"type":"boolean"},"match_threshold":{"type":"number","default":0.4,"maximum":1,"minimum":0},"model":{"type":"string"}}},"retrieval":{"type":"object","properties":{"boost_by":{"description":"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.","type":"array","items":{"properties":{"direction":{"description":"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.","type":"string","enum":["asc","desc","exists","not_exists"]},"field":{"description":"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.","type":"string","maxLength":64,"minLength":1,"examples":["timestamp"]}},"required":["field"],"type":"object"},"maxItems":3,"examples":[[{"direction":"desc","field":"timestamp"}]]},"context_expansion":{"type":"integer","default":0,"maximum":3,"minimum":0},"filters":{"type":"object","additionalProperties":true},"fusion_method":{"type":"string","enum":["max","rrf"]},"keyword_match_mode":{"description":"Controls which documents become candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term and ranks results according to BM25 relevance. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'.","type":"string","enum":["and","or"]},"match_threshold":{"description":"Minimum similarity score a chunk must reach to be returned. When omitted, falls back to the instance-level score_threshold, then to 0.4.","type":"number","maximum":1,"minimum":0},"max_num_results":{"description":"Maximum number of results to return. When omitted, falls back to the instance-level max_num_results, then to 10.","type":"integer","maximum":50,"minimum":1},"retrieval_type":{"type":"string","enum":["vector","keyword","hybrid"]},"return_on_failure":{"type":"boolean","default":true}}}}},"messages":{"description":"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.","type":"array","items":{"additionalProperties":true,"properties":{"content":{"anyOf":[{"type":"string"},{"items":{"oneOf":[{"properties":{"text":{"type":"string","minLength":1},"type":{"type":"string","enum":["text"]}},"required":["type","text"],"type":"object"},{"properties":{"image_url":{"type":"object","properties":{"url":{"type":"string","maxLength":20971520,"minLength":1}},"required":["url"]},"type":{"type":"string","enum":["image_url"]}},"required":["type","image_url"],"type":"object"},{"properties":{"file":{"type":"object","properties":{"file_data":{"type":"string","maxLength":13981144,"minLength":1},"file_id":{"type":"string"},"filename":{"type":"string","maxLength":255,"minLength":1}},"required":["filename"]},"type":{"type":"string","enum":["file"]}},"required":["type","file"],"type":"object"}]},"minItems":1,"type":"array"},{"enum":[null],"type":["string","null"]}]},"role":{"type":"string","enum":["system","developer","user","assistant","tool"]}},"required":["role","content"],"type":"object"},"minItems":1},"query":{"description":"A simple text query string. Alternative to 'messages' — provide either this or 'messages', not both.","minLength":1,"type":"string"}}}},"required":["path"],"additionalProperties":false},"name":"Search","id":"cloudflare.ai-search-namespace-instance-search","example":{"path":{"id":"my-ai-search","account_id":"c3dc5f0b34a14ff8e1b3ec04895e1b22","namespace":"my-namespace"}},"maxRequests":1,"summary":false}}