| [ Web Proxy ] |
| Viewing: https://developers.cloudflare.com/api/resources/ai_search/subresources/namespaces/methods/search | [Back] [Original] |
Performs a semantic search query against multiple AI Search instances in parallel, merging the retrieved results into a single ranked response.
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYYThe previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
X-Auth-Email: user@example.comThe previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194Metadata 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.
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.
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.
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.
OpenAI-compatible message array. For multimodal queries, set the last user messages content to an array of typed parts: [{type:'text', text:''}, {type:'image_url', image_url:{url:''}}]. Image inputs require the RAGs embedding_model to declare image in supported_modalities.
curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/ai-search/namespaces/$NAME/search \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
-d '{
"ai_search_options": {
"instance_ids": [
"my-ai-search"
]
}
}'{
"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
}{
"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
}| Web Proxy Viewer | New URL | Original Page |