AI Search public endpoints allow you to expose AI Search capabilities without requiring authentication. This enables you to integrate AI Search into public-facing applications or share it with external users.
For pre-built search and chat components you can embed on your website using the public endpoints, refer to UI snippets.
Enable public endpoints for your AI Search instance:
- Go to AI Search in the Cloudflare dashboard. Go to AI Search ↗
- Select your AI Search instance.
- Go to Settings > Public Endpoint.
- Turn on Enable Public Endpoint.
- Copy the public endpoint URL.
For configuration options like rate limiting and CORS, refer to Public endpoint configuration.
You can enable a public endpoint on a single instance or on a whole namespace. A namespace endpoint serves the same three paths and searches across the instances you allow in that namespace, merging the results.
Cloudflare generates the hostname when you enable the endpoint:
| Hostname | Description |
|---|---|
<PUBLIC_ENDPOINT_ID>.search.ai.cloudflare.com |
Serves a single instance. |
ns-<NAMESPACE_ENDPOINT_ID>.search.ai.cloudflare.com |
Serves a namespace, searching across several instances. |
The request and response formats are identical for both. The examples on this page use the instance hostname.
You can serve the same endpoints from a hostname that you own, such as search.example.com, instead of the generated one:
https://search.example.com/search
https://search.example.com/chat/completions
https://search.example.com/mcpThe hostname must belong to a zone on the same Cloudflare account. To attach a custom domain:
- Go to AI Search in the Cloudflare dashboard. Go to AI Search ↗
- Select your instance or namespace.
- Go to Public Endpoints and enable the public endpoint. A custom domain requires an active public endpoint.
- Go to Custom Domains and attach your hostname.
A custom domain routes requests through your own zone, so you can also put Cloudflare Access in front of the endpoint and require callers to authenticate before they reach AI Search. Access only protects the custom hostname, so set default_domain_enabled to false as well. Otherwise the default <PUBLIC_ENDPOINT_ID>.search.ai.cloudflare.com hostname keeps answering unauthenticated requests.
To attach a domain through the API instead, refer to Custom domains.
The /chat/completions endpoint searches your data source and generates a response using the model and retrieved context. It uses the same OpenAI-compatible format as the REST API.
curl https://<PUBLIC_ENDPOINT_ID>.search.ai.cloudflare.com/chat/completions \
-H "Content-Type: application/json" \
-d '{
"messages": [
{
"content": "How do I configure AI Search?",
"role": "user"
}
]
}'For the full list of options, refer to the Chat Completions API reference.
The /search endpoint returns relevant chunks from your data source without generating a response. It uses the same format as the REST API.
curl https://<PUBLIC_ENDPOINT_ID>.search.ai.cloudflare.com/search \
-H "Content-Type: application/json" \
-d '{
"messages": [
{
"content": "How do I configure AI Search?",
"role": "user"
}
]
}'For the full list of options, refer to the Search API reference.
- UI snippets - Add pre-built search and chat components to your website.
- MCP - Connect AI agents using the Model Context Protocol.
- Public endpoint configuration - Configure rate limiting, CORS, and security settings.
- Custom domains - Serve these endpoints from a hostname that you own.
- Cloudflare Access - Require callers to authenticate before they reach these endpoints.