Skip to content

Changelog

New updates and improvements at Cloudflare.

hero image

New AI Search REST API endpoints for /search and /chat/completions

AI Search now offers new REST API endpoints for search and chat that use an OpenAI compatible format. This means you can use the familiar messages array structure that works with existing OpenAI SDKs and tools. The messages array also lets you pass previous messages within a session, so the model can maintain context across multiple turns.

EndpointPath
Chat CompletionsPOST /accounts/{account_id}/ai-search/instances/{name}/chat/completions
SearchPOST /accounts/{account_id}/ai-search/instances/{name}/search

Here is an example request to the Chat Completions endpoint using the new messages array format:

Terminal window
curl https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai-search/instances/{NAME}/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer {API_TOKEN}" \
-d '{
"messages": [
{
"role": "system",
"content": "You are a helpful documentation assistant."
},
{
"role": "user",
"content": "How do I get started?"
}
]
}'

For more details, refer to the AI Search REST API guide.

If you are using the previous AutoRAG API endpoints (/autorag/rags/), we recommend migrating to the new endpoints. The previous AutoRAG API endpoints will continue to be fully supported.

Refer to the migration guide for step-by-step instructions.