Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/gcsconsultores/centros-estrategicos-gcs/llms.txt

Use this file to discover all available pages before exploring further.

Sally’s chat functionality is powered by Google Gemini 2.5 Flash, accessed through the Vercel AI SDK’s streamText function. The /api/chat route receives a conversation history and an optional context object, builds a context-aware system prompt by combining the global SALLY_SYSTEM_PROMPT constant with the visitor’s current room and name, then streams the model’s response token-by-token back to the client as a Vercel AI UIMessageStream. This produces the real-time typing effect visible in Sally’s chat panel across all salas.

Setup

1

Get a Google Gemini API key

Visit Google AI Studio and create a new API key. No billing is required to get started — the Gemini API includes a free tier.
2

Add the key to your environment

Add the following line to your .env.local file at the project root:
GOOGLE_GEMINI_API_KEY=your_key_here
3

Verify the Vercel AI SDK configuration

The Vercel AI SDK automatically picks up GOOGLE_GEMINI_API_KEY when you reference the google/gemini-2.5-flash model identifier. No additional SDK configuration is needed — the model string is passed directly to streamText.

Configuration

The /api/chat route calls streamText with the following parameters. These values are defined directly in app/api/chat/route.ts:
const result = streamText({
  model: 'google/gemini-2.5-flash',
  system: systemPrompt,              // SALLY_SYSTEM_PROMPT + room context
  messages: await convertToModelMessages(messages),
  maxOutputTokens: 500,              // keep responses concise
  temperature: 0.7,                  // balanced creativity
  abortSignal: req.signal,           // respects client disconnects
})

return result.toUIMessageStreamResponse()
The abortSignal is forwarded from the incoming request so that if the user closes the chat panel mid-stream, the model call is cancelled immediately and no further tokens are billed.

Model Parameters

ParameterValueEffect
modelgoogle/gemini-2.5-flashFast, capable Gemini model optimized for chat use cases
maxOutputTokens500Keeps Sally’s responses concise and suited to a chat UX
temperature0.7Balanced: professional and consistent, yet natural in tone
maxDuration30Vercel serverless function timeout for the /api/chat route

System Prompt Customization

Sally’s personality, expertise, tone, and objectives are all defined in the SALLY_SYSTEM_PROMPT constant in lib/constants.ts. To change how Sally behaves — her language, the services she recommends, or her escalation behavior — edit this constant directly. At request time, additional context is injected dynamically after the base prompt to make Sally aware of where the visitor is and who they are:
const contextInfo = context ? `
CONTEXTO ACTUAL:
- Sala actual: ${context.currentRoom || 'lobby'}
- Nombre del usuario: ${context.userName || 'Visitante'}
` : '';
The current prompt instructs Sally to:
  • Use formal usted address in Spanish
  • Guide visitors toward a concrete action (diagnostic, meeting, or contact)
  • Recommend the appropriate sala based on the visitor’s needs
  • Never invent prices or specific timelines — escalate to a human consultant instead
Each sala also has a dedicated greeting defined in the SALLY_GREETINGS record in lib/constants.ts, which initializes the chat panel when a visitor enters a new room.

Vercel AI SDK Imports

The /api/chat route uses three named exports from the ai package:
import { streamText, convertToModelMessages, UIMessage } from 'ai';
ImportPurpose
streamTextInitiates a streaming LLM call and returns a result object with a toUIMessageStreamResponse() helper
convertToModelMessagesConverts the Vercel AI SDK’s UIMessage[] format into the model-compatible message format expected by the provider
UIMessageTypeScript type for the Vercel AI SDK message shape, used to type the messages field in the request body
GOOGLE_GEMINI_API_KEY is required for the chat feature to function. Without it, the Vercel AI SDK will throw a configuration error when streamText is called, and POST /api/chat will return HTTP 500. Sally’s chat panel will be non-functional until the key is set.
For higher-quality, more detailed responses at the cost of slightly higher latency, change the model identifier to 'google/gemini-2.5-pro' in app/api/chat/route.ts. If Sally’s replies are being cut off mid-sentence, increase maxOutputTokens beyond 500 — a value of 8001000 gives more room for complex consulting answers without noticeably affecting response time.

Build docs developers (and LLMs) love