Skip to content
Start here

Get an AI Search instance.

client.AISearch.Instances.Read(ctx, id, query) (*InstanceReadResponse, error)
GET/accounts/{account_id}/ai-search/instances/{id}

Retrieve the configuration and status of an AI Search instance.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
ParametersExpand Collapse
id string
query InstanceReadParams
AccountID param.Field[string]
ReturnsExpand Collapse
type InstanceReadResponse struct{…}
ID string

AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.

maxLength64
minLength1
CreatedAt Time
formatdate-time
ModifiedAt Time
formatdate-time
AIGatewayID stringOptional
AISearchModel stringOptional

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.

Cache boolOptional
CacheThreshold InstanceReadResponseCacheThresholdOptional
One of the following:
const InstanceReadResponseCacheThresholdSuperStrictMatch InstanceReadResponseCacheThreshold = "super_strict_match"
const InstanceReadResponseCacheThresholdCloseEnough InstanceReadResponseCacheThreshold = "close_enough"
const InstanceReadResponseCacheThresholdFlexibleFriend InstanceReadResponseCacheThreshold = "flexible_friend"
const InstanceReadResponseCacheThresholdAnythingGoes InstanceReadResponseCacheThreshold = "anything_goes"
CacheTTL InstanceReadResponseCacheTTLOptional

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).

One of the following:
const InstanceReadResponseCacheTTL600 InstanceReadResponseCacheTTL = 600
const InstanceReadResponseCacheTTL1800 InstanceReadResponseCacheTTL = 1800
const InstanceReadResponseCacheTTL3600 InstanceReadResponseCacheTTL = 3600
const InstanceReadResponseCacheTTL7200 InstanceReadResponseCacheTTL = 7200
const InstanceReadResponseCacheTTL21600 InstanceReadResponseCacheTTL = 21600
const InstanceReadResponseCacheTTL43200 InstanceReadResponseCacheTTL = 43200
const InstanceReadResponseCacheTTL86400 InstanceReadResponseCacheTTL = 86400
const InstanceReadResponseCacheTTL172800 InstanceReadResponseCacheTTL = 172800
const InstanceReadResponseCacheTTL259200 InstanceReadResponseCacheTTL = 259200
const InstanceReadResponseCacheTTL518400 InstanceReadResponseCacheTTL = 518400
ChunkOverlap int64Optional
maximum30
minimum0
ChunkSize int64Optional
minimum64
CreatedBy stringOptional
CustomMetadata []InstanceReadResponseCustomMetadataOptional
DataType InstanceReadResponseCustomMetadataDataType
One of the following:
const InstanceReadResponseCustomMetadataDataTypeText InstanceReadResponseCustomMetadataDataType = "text"
const InstanceReadResponseCustomMetadataDataTypeNumber InstanceReadResponseCustomMetadataDataType = "number"
const InstanceReadResponseCustomMetadataDataTypeBoolean InstanceReadResponseCustomMetadataDataType = "boolean"
const InstanceReadResponseCustomMetadataDataTypeDatetime InstanceReadResponseCustomMetadataDataType = "datetime"
FieldName string
maxLength64
minLength1
EmbeddingModel stringOptional
Enable boolOptional
EngineVersion float64Optional
FusionMethod InstanceReadResponseFusionMethodOptional
One of the following:
const InstanceReadResponseFusionMethodMax InstanceReadResponseFusionMethod = "max"
const InstanceReadResponseFusionMethodRrf InstanceReadResponseFusionMethod = "rrf"
DeprecatedHybridSearchEnabled boolOptional

Deprecated — use index_method instead.

IndexMethod InstanceReadResponseIndexMethodOptional

Controls which storage backends are used during indexing. Defaults to vector-only.

Keyword bool

Enable keyword (BM25) storage backend.

Vector bool

Enable vector (embedding) storage backend.

IndexingOptions InstanceReadResponseIndexingOptionsOptional
KeywordTokenizer InstanceReadResponseIndexingOptionsKeywordTokenizerOptional

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.

One of the following:
const InstanceReadResponseIndexingOptionsKeywordTokenizerPorter InstanceReadResponseIndexingOptionsKeywordTokenizer = "porter"
const InstanceReadResponseIndexingOptionsKeywordTokenizerTrigram InstanceReadResponseIndexingOptionsKeywordTokenizer = "trigram"
LastActivity TimeOptional
formatdate-time
MaxNumResults int64Optional
maximum50
minimum1
Metadata InstanceReadResponseMetadataOptional
CreatedFromAISearchWizard boolOptional
WorkerDomain stringOptional
ModifiedBy stringOptional
Namespace stringOptional
Paused boolOptional
PublicEndpointID stringOptional
PublicEndpointParams InstanceReadResponsePublicEndpointParamsOptional
AuthorizedHosts []stringOptional
ChatCompletionsEndpoint InstanceReadResponsePublicEndpointParamsChatCompletionsEndpointOptional
Disabled boolOptional

Disable chat completions endpoint for this public endpoint

CustomDomains []stringOptional

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).

DefaultDomainEnabled boolOptional

When false, the instance is reachable only via a registered custom domain and the default <public_endpoint_id>.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 boolOptional
Mcp InstanceReadResponsePublicEndpointParamsMcpOptional
Description stringOptional
Disabled boolOptional

Disable MCP endpoint for this public endpoint

RateLimit InstanceReadResponsePublicEndpointParamsRateLimitOptional
PeriodMs int64Optional
maximum3600000
minimum60000
Requests int64Optional
minimum1
Technique InstanceReadResponsePublicEndpointParamsRateLimitTechniqueOptional
One of the following:
const InstanceReadResponsePublicEndpointParamsRateLimitTechniqueFixed InstanceReadResponsePublicEndpointParamsRateLimitTechnique = "fixed"
const InstanceReadResponsePublicEndpointParamsRateLimitTechniqueSliding InstanceReadResponsePublicEndpointParamsRateLimitTechnique = "sliding"
SearchEndpoint InstanceReadResponsePublicEndpointParamsSearchEndpointOptional
Disabled boolOptional

Disable search endpoint for this public endpoint

Reranking boolOptional
RerankingModel stringOptional
RetrievalOptions InstanceReadResponseRetrievalOptionsOptional
BoostBy []InstanceReadResponseRetrievalOptionsBoostByOptional

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.

maxLength64
minLength1
Direction InstanceReadResponseRetrievalOptionsBoostByDirectionOptional

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.

One of the following:
const InstanceReadResponseRetrievalOptionsBoostByDirectionAsc InstanceReadResponseRetrievalOptionsBoostByDirection = "asc"
const InstanceReadResponseRetrievalOptionsBoostByDirectionDesc InstanceReadResponseRetrievalOptionsBoostByDirection = "desc"
const InstanceReadResponseRetrievalOptionsBoostByDirectionExists InstanceReadResponseRetrievalOptionsBoostByDirection = "exists"
const InstanceReadResponseRetrievalOptionsBoostByDirectionNotExists InstanceReadResponseRetrievalOptionsBoostByDirection = "not_exists"
KeywordMatchMode InstanceReadResponseRetrievalOptionsKeywordMatchModeOptional

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’.

One of the following:
const InstanceReadResponseRetrievalOptionsKeywordMatchModeAnd InstanceReadResponseRetrievalOptionsKeywordMatchMode = "and"
const InstanceReadResponseRetrievalOptionsKeywordMatchModeOr InstanceReadResponseRetrievalOptionsKeywordMatchMode = "or"
RewriteModel stringOptional

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.

RewriteQuery boolOptional
ScoreThreshold float64Optional
maximum1
minimum0
Source stringOptional
SourceParams InstanceReadResponseSourceParamsOptional
ExcludeItems []stringOptional

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.

IncludeItems []stringOptional

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 stringOptional
R2Jurisdiction stringOptional
WebCrawler InstanceReadResponseSourceParamsWebCrawlerOptional
DiscoverOptions InstanceReadResponseSourceParamsWebCrawlerDiscoverOptionsOptional

Options for parse_type ‘discover’, where Browser Run discovers URLs by link following and sitemaps. Ignored for ‘sitemap’.

Depth float64Optional

Maximum link-follow depth from the seed URL.

maximum100000
minimum1
IncludeSubdomains boolOptional

Follow links to subdomains of the source host.

Limit float64Optional

Maximum number of pages to crawl (1-100000).

maximum100000
minimum1
MaxAge float64Optional

Maximum content age in seconds to accept (0–604800).

maximum604800
minimum0
Source InstanceReadResponseSourceParamsWebCrawlerDiscoverOptionsSourceOptional

Where the crawler looks for URLs: ‘sitemaps’ reads sitemap XML only, ‘links’ follows page links only, ‘all’ does both.

One of the following:
const InstanceReadResponseSourceParamsWebCrawlerDiscoverOptionsSourceAll InstanceReadResponseSourceParamsWebCrawlerDiscoverOptionsSource = "all"
const InstanceReadResponseSourceParamsWebCrawlerDiscoverOptionsSourceSitemaps InstanceReadResponseSourceParamsWebCrawlerDiscoverOptionsSource = "sitemaps"
const InstanceReadResponseSourceParamsWebCrawlerDiscoverOptionsSourceLinks InstanceReadResponseSourceParamsWebCrawlerDiscoverOptionsSource = "links"
ParseOptions InstanceReadResponseSourceParamsWebCrawlerParseOptionsOptional
ContentSelector []InstanceReadResponseSourceParamsWebCrawlerParseOptionsContentSelectorOptional

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.

maxLength200
minLength1
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.

maxLength200
minLength1
IncludeHeaders map[string, string]Optional

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).

IncludeImages boolOptional
SpecificSitemaps []stringOptional

List of specific sitemap URLs to use for crawling. Only valid when parse_type is ‘sitemap’.

UseBrowserRendering boolOptional
ParseType InstanceReadResponseSourceParamsWebCrawlerParseTypeOptional

How URLs are discovered. ‘sitemap’ reads XML sitemaps; ‘discover’ follows links recursively and requires the source to be a Verified zone on this account.

One of the following:
const InstanceReadResponseSourceParamsWebCrawlerParseTypeSitemap InstanceReadResponseSourceParamsWebCrawlerParseType = "sitemap"
const InstanceReadResponseSourceParamsWebCrawlerParseTypeDiscover InstanceReadResponseSourceParamsWebCrawlerParseType = "discover"
Status stringOptional
SyncInterval InstanceReadResponseSyncIntervalOptional

Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h).

One of the following:
const InstanceReadResponseSyncInterval900 InstanceReadResponseSyncInterval = 900
const InstanceReadResponseSyncInterval1800 InstanceReadResponseSyncInterval = 1800
const InstanceReadResponseSyncInterval3600 InstanceReadResponseSyncInterval = 3600
const InstanceReadResponseSyncInterval7200 InstanceReadResponseSyncInterval = 7200
const InstanceReadResponseSyncInterval14400 InstanceReadResponseSyncInterval = 14400
const InstanceReadResponseSyncInterval21600 InstanceReadResponseSyncInterval = 21600
const InstanceReadResponseSyncInterval43200 InstanceReadResponseSyncInterval = 43200
const InstanceReadResponseSyncInterval86400 InstanceReadResponseSyncInterval = 86400
TokenID stringOptional
formatuuid
Type InstanceReadResponseTypeOptional
One of the following:
const InstanceReadResponseTypeR2 InstanceReadResponseType = "r2"
const InstanceReadResponseTypeWebCrawler InstanceReadResponseType = "web-crawler"

Get an AI Search instance.

package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/ai_search"
  "github.com/cloudflare/cloudflare-go/option"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  response, err := client.AISearch.Instances.Read(
    context.TODO(),
    "my-ai-search",
    ai_search.InstanceReadParams{
      AccountID: cloudflare.F("c3dc5f0b34a14ff8e1b3ec04895e1b22"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.ID)
}
{
  "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": "ai_search_model",
    "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": "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": 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": "reranking_model",
    "retrieval_options": {
      "boost_by": [
        {
          "field": "timestamp",
          "direction": "desc"
        }
      ],
      "keyword_match_mode": "and"
    },
    "rewrite_model": "rewrite_model",
    "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
}
Returns Examples
{
  "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": "ai_search_model",
    "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": "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": 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": "reranking_model",
    "retrieval_options": {
      "boost_by": [
        {
          "field": "timestamp",
          "direction": "desc"
        }
      ],
      "keyword_match_mode": "and"
    },
    "rewrite_model": "rewrite_model",
    "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
}