This endpoint calls Google Gemini to produce three open-ended, audience-appropriate question suggestions that a visitor can send as anonymous messages on the platform. The questions are returned as a single pipe-delimited string, ready for the frontend to split and display as selectable prompts.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/dev0302/nextjs-project-1/llms.txt
Use this file to discover all available pages before exploring further.
Method and URL
Request Parameters
This endpoint accepts no query parameters, path parameters, or request body. Every call generates a fresh set of suggestions from the model.How It Works
- The handler reads
GOOGLE_API_KEYfrom the environment and initialises aGoogleGenAIclient from@google/genai. - It resolves the model name from
process.env.GEMINI_MODEL, falling back togemini-1.5-flash. - A few-shot prompt is sent to
ai.models.generateContent()requesting exactly three questions separated by||. - The response text is read from the
response.textgetter (a direct string property on the result object, notresponse.candidates[0]...). - The raw text is trimmed and returned in the
suggestionsfield. - If the model returns no text (e.g., blocked by safety filters) the endpoint responds with
400. - Any API-level exception (quota exceeded, invalid key, network error) is caught and returned as a
500with the original error message.
The Prompt
The following prompt is sent verbatim to the model on every request:Responses
200 — Success
Three AI-generated questions are returned as a||-delimited string.
400 — No content from AI
The model returned an empty response, most likely because the safety filter blocked output.500 — Gemini API error
An error was thrown by the Gemini SDK, such as an invalid API key, exhausted quota, or a network failure.Response Fields
true when the model returned usable content; false on any error condition.Present only on a successful (
200) response. Three questions joined by || with no leading or trailing whitespace. Split on || to obtain individual suggestion strings.Example value:Example Request
Parsing the Response
The frontend splits thesuggestions string into an array before rendering each question as a clickable chip:
Configuration
| Environment variable | Required | Default | Description |
|---|---|---|---|
GOOGLE_API_KEY | ✅ Yes | — | Google AI Studio API key passed to GoogleGenAI({ apiKey }). |
GEMINI_MODEL | No | gemini-1.5-flash | Gemini model name forwarded to ai.models.generateContent(). |