Connect a React chat screen to a Firebase callable function and use server-side identity for model access.
Build the example
Build a neutral hobby assistant that suggests public reading topics. Authenticate the request, enforce a length limit and call Vertex AI from the function’s configured identity with only the required permissions. Return a compact response and surface permission and quota failures separately. Apply rate limits and check pricing before enabling real traffic.
Create an emulator fixture that returns a fixed reading suggestion and increments a counter. A successful call should invoke it once. Then deny the caller and send a long payload; both cases should leave the count unchanged. Keep provider request configuration in the server project, and show deployment instructions separately from the emulator exercise.
Chat request boundary
Connect a React chat screen to a Firebase callable function and use server-side identity for model access.
Example
- React client
send a bounded hobby question
- Callable function
check caller and rate limits
- Vertex AI
use server identity to call the model
use server identity to call the model
Watch the failure boundary
Return an explicit error when the caller has hit a limit or the model service is unavailable. If a message is retried, track the same request reference to help detect duplicate effects. Start with a non-streaming response for the demo and add streaming only when you can test interruption and reconnect behavior.
Verify the behavior
Use the Firebase emulator and a model stub for the first test. Verify that an unauthenticated request and an oversized message fail before the stub runs. Then test model timeouts and duplicate sends. Run any live model smoke test with a harmless example and a defined budget.
Sources
Technical references checked .



