OpenAICloudflare Developer PlatformMar 23, 2026, 12:00 AM

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

A condensed section focused on the key takeaways first.

Original Post

Quick Digest

Summary

A condensed section focused on the key takeaways first.

openaienmodel: gpt-5-mini-2025-08-07

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/completions and POST /accounts/{account_id}/ai-search/instances/{name}/search.
  • Request format: use a messages array 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 messages array, preserve and replay prior messages for multi-turn context, verify Authorization: Bearer {API_TOKEN} and run integration tests.

Full Translation

Translations

A translation section that keeps the flow of the original article.

openaijamodel: gpt-5-mini-2025-08-07

AI Search - /search と /chat/completions の新しい AI Search REST API エンドポイント

新しい AI Search REST API エンドポイント (/search と /chat/completions)

公開日: 2026-03-23

AI Search は、OpenAI 互換フォーマットを使用する検索およびチャット用の新しい REST API エンドポイントを提供します。これにより、既存の OpenAI SDK やツールで使われている馴染みのある messages 配列構造を利用できます。messages 配列を使うことで、セッション内の以前のメッセージを渡して、モデルが複数ターンにわたってコンテキストを維持できるようになります。

エンドポイントパス

  • Chat Completions

    POST /accounts/{account_id}/ai-search/instances/{name}/chat/completions

  • Search

    POST /accounts/{account_id}/ai-search/instances/{name}/search

例: Chat Completions エンドポイントへのリクエスト

ターミナル:

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?" } ] }'

詳細については、AI Search REST API guide を参照してください。

既存の AutoRAG API からの移行(推奨)

以前の AutoRAG API エンドポイント (/autorag/rags/) を使用している場合は、可能な限り早く新しいエンドポイントへ移行することを推奨します。新機能は今後新しいエンドポイントにのみ追加されます。以前の AutoRAG エンドポイントは当面の間は引き続き動作しますが、変更の少なくとも 90 日前に通知を行います。

移行手順の詳細については、migration guide を参照してください。

リソース

  • AI Search REST API guide
  • Migration guide

© 2026 Cloudflare, Inc. Privacy Policy Terms of Use