New AI Search REST API endpoints for search and chat
AI Search introduces new OpenAI-compatible REST API endpoints for /search and /chat/completions, supporting a messages array format that enables multi-turn conversations with context retention. The previous AutoRAG API endpoints remain supported.
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.
| Endpoint | Path |
|---|---|
| Chat Completions | POST /accounts/{account_id}/ai-search/instances/{name}/chat/completions |
| Search | POST /accounts/{account_id}/ai-search/instances/{name}/search |
Here is an example request to the Chat Completions endpoint using the new messages array format:
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.
Migration from existing AutoRAG API (recommended)
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.
Source: original entry ↗
More from Cloudflare
Follow Cloudflare to get its new changes in your feed and email digest.
Cloudflare One Client for Windows hotfix - trusted certificate chains
A new GA release for Windows Cloudflare One Client is available, addressing an issue with building trusted certificate chains.
Cloudflare One Client for macOS - Trusted Certificate Chain Fix
A new GA release of the macOS Cloudflare One Client is available. This hotfix addresses an issue with building trusted certificate chains.
Cloudflare One Client for Linux
A new GA release of Cloudflare One Client for Linux is now available. This hotfix addresses an issue with building trusted certificate chains.