page:recipes:ai chat application:gin:response streaming

Host ai chat application with Gin: streamed responses

Summary

Deploy an ai chat application built with Gin on Ample using the streaming response service pattern. Compute runs the app in an isolated microVM behind a public HTTPS URL. A managed PostgreSQL 16 database is auto-provisioned and injected as DATABASE_URL. Verified on Gin through a Server-Sent Events endpoint, the first chunk arrives within seconds, and the 70-second stream of 36 chunks completed past common 60-second idle timeouts.

Representative Queries

Resource Requirements

Infrastructure Requirements

Compute

Postgres

Prerequisites

Workflow Steps

  1. Build and start

    • CGO_ENABLED=0 go build -o app ./... then ./app on the ubuntu-24.04 template. The server must bind 0.0.0.0 on PORT.
  2. Implement the pattern on PostgreSQL

    • The fixture's module implements streaming response service. Copy the approach into your schema; keep migrations idempotent and run them with --release-command.
  3. Deploy

    • Run the synchronous deploy once and read the result.
    • Command: ample deploy . --name --public
  4. Verify

    • Fetch the live URL and check self-test route(s), then run your own checks.
    • Command: ample logs --kind build

Success Checks

Limitations

Cost Estimate

Evidence Summary

Formats