Skip to content

Public endpoint

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.

Prerequisites

Enable public endpoints for your AI Search instance:

  1. Go to AI Search in the Cloudflare dashboard. Go to AI Search
  2. Select your AI Search instance.
  3. Go to Settings > Public Endpoint.
  4. Turn on Enable Public Endpoint.
  5. Copy the public endpoint URL.

For configuration options like rate limiting and CORS, refer to Public endpoint configuration.

Chat completions

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.

Terminal window
curl https://<INSTANCE_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.

Terminal window
curl https://<INSTANCE_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.

Next steps

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