Streaming built in
SSE, NDJSON, and raw streams. Events flush immediately. Heartbeats keep idle connections alive.
DocumentationPhoton
Server-sent events, cancellation, and back-pressure built into a small net/http server. Your handlers and middleware stay the same.
go get github.com/agenticmarket/photonGo 1.24+ · Zero dependencies · Apache 2.0
app := photon.New()
app.POST("/chat", photon.SSE(func(
s *photon.Stream, r *http.Request,
) error {
for token := range model.Stream(r.Context()) {
if err := s.Event("token", []byte(token)); err != nil {
return err
}
}
return s.Event("done", nil)
}))
app.Run(":8080")app := photon.New()
app.GET("/users/:id", func(
w http.ResponseWriter, r *http.Request,
) {
photon.JSON(w, http.StatusOK, map[string]string{
"id": photon.PathParam(r, "id"),
})
})
// Keep your existing handlers and middleware.
app.Mount("/api", existingRouter)
app.Run(":8080")SSE, NDJSON, and raw streams. Events flush immediately. Heartbeats keep idle connections alive.
DocumentationClient disconnects cancel the request context. Stop upstream work when there’s no one left to receive it.
DocumentationPer-stream buffers, back-pressure, and connection limits. Slow clients stay within a defined memory budget.
DocumentationPlain net/http handlers and middleware. HTTP/2 support. No runtime, adapters, or third-party dependencies.
DocumentationPerformance
Switch the stream count to compare published SSE results. Select a framework to inspect its throughput and measured process memory.
Ordinary HTTP requests tie within measurement noise. These results measure streaming over loopback, rather than production capacity.
Methodology & raw resultsRyzen 7 6800HS · Go 1.27.1 · Windows 11
Node.js 24.19 · client and server on the same machine.
Photon10 concurrent streams
Published medians · higher throughput is better. Memory was measured at 10 streams only.
Getting started
Scaffold an agent backend, an OpenAI-compatible proxy, or a plain HTTP API.
Installation guide$ go install github.com/agenticmarket/photon/cmd/photon@latest
$ photon init my-agent -template agent
$ cd my-agent && go mod tidy && go run .