AI Search: New REST API endpoints for /search and /chat/completions
Key Points
- OpenAI-compatible messages array
- New POST endpoints for chat and search
- Migrate from AutoRAG; 90-day notice
Summary
Cloudflare AI Search now exposes OpenAI-compatible REST endpoints for search and chat. The endpoints accept a messages array (roles and content), allowing you to maintain session context across turns and reuse existing OpenAI SDKs and tooling.
Key Points
- Endpoints:
POST /accounts/{account_id}/ai-search/instances/{name}/chat/completionsandPOST /accounts/{account_id}/ai-search/instances/{name}/search. - Request format: use a
messagesarray with entries like{"role":"system","content":"..."}and{"role":"user","content":"..."}to pass prior turns and preserve context. - Example cURL: 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?" } ] }'
- Migration: if you use the older AutoRAG endpoints (
/autorag/rags/), migrate to the new API as soon as possible — new features will be added only to the new endpoints. Existing AutoRAG endpoints will continue to work for now; Cloudflare will provide at least 90 days notice before changes. - Practical checklist: update client endpoint URLs, switch payloads to the
messagesarray, preserve and replay prior messages for multi-turn context, verifyAuthorization: Bearer {API_TOKEN}and run integration tests.