Skip to Content
DocsAPI ReferenceAI Search (Semantic)

AI Semantic Search

GET /api/v1/ai/search/semantic

Expands a search query into ~30 associated words via OpenAI, then searches Elasticsearch for all of them using exact, analyzed, and ngram matching. Supports the same filters as Global Search.

Cached expansions are served to all users. Generating new expansions (cache miss) requires authentication. Rate limited to 30 requests/minute per IP.

Authentication: Optional (required to generate new expansions on cache miss)

Cache: 15s (Redis) + 30 days (DB for expansions)

Query Parameters

ParameterTypeDefaultDescription
qstringRequired. Search query (min 2 chars)
pagenumber1Page number
limitnumber20Results per page (max 100)
sortBystringSort field (same as Global Search)
sortOrderstringasc or desc

Filters

Same bracket notation as Global Search filters.

Sample Request

curl "https://api.grails.app/api/v1/ai/search/semantic?q=finance&limit=10"

Response

// 200 OK { "success": true, "data": { "results": [ { "name": "bank.eth", // ... standard search result fields } ], "pagination": { "page": 1, "limit": 10, "total": 85, "totalPages": 9, "hasNext": true, "hasPrev": false } }, "meta": { "timestamp": "2026-04-08T00:00:00.000Z", "expansionsCount": 30, "semanticTotal": 85 } }

Error Responses

StatusCodeDescription
400VALIDATION_ERRORQuery missing or fewer than 2 characters
401UNAUTHORIZEDAuthentication required to generate new expansions
500INTERNAL_ERRORSemantic search failed
Last updated on