Skip to content

[Enhancement] Add reactive streaming client with Project Reactor support #65

@deepgram-robot

Description

@deepgram-robot

Summary

Add a reactive streaming interface using Project Reactor (Mono/Flux) for the Java SDK's WebSocket clients, enabling non-blocking, backpressure-aware audio streaming and transcript consumption that integrates naturally with Spring WebFlux and other reactive Java frameworks.

Problem it solves

Modern Java applications increasingly use reactive programming (Spring WebFlux, Vert.x, Micronaut) for high-throughput, non-blocking I/O. The current Java SDK uses callback-based patterns that don't compose well with reactive pipelines. Developers building reactive applications must wrap Deepgram's callbacks in custom Flux/Mono adapters, handle backpressure manually, and bridge between reactive and imperative code. A native reactive interface lets developers use Deepgram's streaming APIs as natural elements in their reactive data pipelines — subscribing to transcript streams with operators like map, filter, buffer, and flatMap.

Proposed API

import com.deepgram.sdk.reactive.ReactiveDeepgramClient;
import reactor.core.publisher.Flux;

ReactiveDeepgramClient client = ReactiveDeepgramClient.create(apiKey);

// Streaming STT as a Flux
Flux<TranscriptResult> transcripts = client.listen()
    .model("nova-3")
    .language("en")
    .streamFrom(audioFlux)  // Flux<byte[]> of audio chunks
    .filter(result -> result.isFinal())
    .map(result -> result.getTranscript());

// Subscribe with backpressure
transcripts
    .bufferTimeout(10, Duration.ofSeconds(5))
    .flatMap(batch -> saveToDatabase(batch))
    .subscribe();

// TTS as a Flux of audio chunks
Flux<byte[]> audioStream = client.speak()
    .model("aura-asteria-en")
    .text("Hello from Deepgram")
    .stream();

Acceptance criteria

  • Provides reactive wrappers for Listen (STT) WebSocket client
  • Provides reactive wrappers for Speak (TTS) WebSocket client
  • Supports backpressure via Project Reactor's Flux/Mono
  • Integrates with Spring WebFlux WebSocket handlers
  • Handles connection lifecycle reactively (error signals, completion)
  • Documented with usage examples for Spring WebFlux
  • Compatible with existing SDK API (reactive client is additive)

Raised by the DX intelligence system.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions