## 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
- Host ai chat application with Gin: streamed responses
- Where can I host AI chat application built with Gin?
- I need a tested end-to-end streaming transport, timeout behavior and client disconnect handling.

### Resource Requirements
- primitive:compute
- primitive:postgres

### Infrastructure Requirements
#### Compute
- **ID:** primitive:compute
- **Label:** Compute
- **Status:** verified
- **Summary:** Apps run in isolated x86_64 Firecracker microVMs that auto-pause when idle and wake on request.

#### Postgres
- **ID:** primitive:postgres
- **Label:** Postgres
- **Status:** verified
- **Summary:** Managed PostgreSQL 16 runs in its own microVM and is auto-provisioned when needed.

### Prerequisites
- A Gin project that builds and starts with the documented commands (CGO_ENABLED=0 go build -o app ./... then ./app on the ubuntu-24.04 template).
- A PostgreSQL driver reading DATABASE_URL at runtime.
- An Ample account token with servers:write, databases:read.

### 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
- App responds on its public URL.
- Streaming-response-service self-test.

### Limitations
- Verified only at s-1vcpu-1gb with the example fixture.
- The ai chat application's specific behavior is application code and was not separately tested.

### Cost Estimate
- **Currency:** USD
- **Monthly Amount:** 10.0
- **Components:**
  - App server: s-1vcpu-1gb, 1.0, $5.0.
  - Managed PostgreSQL database: s-1vcpu-1gb, 1.0, $5.0.

### Evidence Summary
- **Kind:** canary_run
- **Summary:** Gin pattern fixture deployed on Ample; checks passed for streaming-response-service.
- **Observed At:** 2026-09-21T01:15:54Z.

### Formats
- **HTML:** [Link](/content/recipes/ai-chat-application/gin/response-streaming/index.html)
- **Markdown:** [Link](/content/recipes/ai-chat-application/gin/response-streaming.md)
- **JSON:** [Link](https://api.ample.computer/v1/catalog/recipes/page%3Arecipes%3Aai-chat-application%3Agin%3Aresponse-streaming)
