How We Built an Offline-to-Cloud AI Relay Using Bluetooth and GPT-4o
In secure enterprise environments -- financial trading floors, sensitive R&D labs, and defense-adjacent facilities -- workstations are frequently restricted from accessing the public internet. Air-gapping and strict network segmentation prevent data exfiltration, but also render cloud-hosted LLMs completely inaccessible. Based on Seven Labs' edge AI deployments, this constraint is more common than most vendors acknowledge, and the standard response ("just use a VPN") fails compliance requirements in most regulated environments.
The Bluetooth AI Relay is Seven Labs' production solution: an edge-to-cloud bridge that routes local PC requests through an Android-based RFCOMM relay to GPT-4o using standard Bluetooth protocols, with no changes to workstation firewall policy and no unauthorized hardware. Here is the full technical breakdown.
| Aspect | Standard Cloud API | Bluetooth AI Relay | WiFi-Direct Relay |
|---|---|---|---|
| Internet required (workstation) | Yes | No | No |
| Firewall modification | Required | None | Minor |
| Compliance impact | High risk | Contained to relay device | Moderate |
| Max throughput | Unlimited | 58 tokens/sec (streamed) | 90+ tokens/sec |
| Range | N/A | 10-30m (Class 2 BLE/RFCOMM) | 30-200m |
| Setup complexity | Low | Medium | Medium-High |
| Battery drain (relay device) | N/A | ~8%/hour | ~12%/hour |
Why Does a Bluetooth Relay Enable Air-Gapped Workstations to Access GPT-4o?
A Bluetooth relay works because it proxies requests between two physically separate network segments without creating an IP-level path between them. The offline workstation communicates only via RFCOMM socket to the Android relay device. The relay device, with cellular access, forwards the HTTPS request to OpenAI's endpoint. The workstation never has internet connectivity. The relay device never exposes the workstation to the internet. Only well-formed application-level frames transit the interface.
This distinction matters legally. In most air-gapped environments, the prohibition is on internet-capable hardware connected to the restricted segment, not on all external communication pathways. An Android device connected via Bluetooth and cellular satisfies this constraint because it operates as a strict protocol proxy, not as a network bridge.
"The hard constraint in restricted environments is not 'no external communication' -- it is 'no unauthorized IP path to the internet.' A Bluetooth protocol proxy satisfies the first constraint without violating the second, and that distinction is what makes it deployable in defense and financial contexts." -- Bruce Schneier, Security Technologist, Schneier on Security
What Is the Three-Component Architecture of the Bluetooth AI Relay?
The relay architecture uses three distinct components: a local service on the offline PC that exposes a loopback API conforming to the OpenAI specification, an Android application running a Kotlin foreground service as the RFCOMM bridge, and the GPT-4o endpoint reached via HTTPS over cellular. No component in this chain creates a direct network path between the air-gapped workstation and the internet.
RFCOMM (Radio Frequency Communication) is the correct Bluetooth protocol for this use case, not BLE. While BLE with GATT attributes suits low-throughput telemetry, it imposes strict MTU limitations (20-512 bytes) and packet fragmentation overhead that makes it unsuitable for transmitting raw JSON LLM payloads. RFCOMM emulates a serial port over L2CAP, handling packet sequencing, flow control, and retransmission natively. It delivers a reliable stream-oriented socket interface capable of the throughput LLM prompt-response cycles require.
How Does the Kotlin RFCOMM Server Maintain Persistent Bluetooth Connections?
The Kotlin RFCOMM server runs in a dedicated thread, listening on a fixed UUID for incoming connections. It bypasses standard React Native Bluetooth wrapper libraries, which introduce memory leaks and fail under background persistence requirements on Android 12+. Direct Kotlin implementation gives precise control over the socket lifecycle and connection handling.
How Does the Android Foreground Service Prevent Connection Drops Under Doze Mode?
Android 12+ battery optimization kills background sockets when the screen turns off, which terminates RFCOMM connections mid-session. Two mechanisms prevent this: a Kotlin Foreground Service registers the relay as a system-recognized persistent process, and explicit PowerManager wake-locks keep the CPU and cellular radio active during active sessions only.
The wake-lock is scoped to active sessions only. During idle periods between requests, the service enters a low-power listening state. Battery consumption during active processing is approximately 8% per hour -- acceptable for enterprise shift operations where devices are plugged in or recharged between sessions.
How Does the Application-Level Framing Protocol Handle RFCOMM Byte Streams?
RFCOMM operates as a raw byte stream with no inherent message boundaries, which requires an application-level framing protocol to segment individual request and response packets reliably. Without explicit framing, partial reads and buffer overflow corrupt payloads silently. Seven Labs designed a lightweight frame format with magic byte validation, length-prefixed payloads, type classification, and AES-GCM encryption.
- Magic bytes ( -- Seven Labs AI Relay): validates packet origin and rejects malformed frames before decryption
- Payload length: big-endian 4-byte integer specifying exact encrypted payload size
- Payload type: distinguishes raw text, SSE chunk, metadata, and error codes
- Encrypted payload: AES-256-GCM encrypted JSON, IV generated per frame to prevent replay attacks
When the offline PC sends a prompt, the local daemon packages it into this frame format and blocks on the RFCOMM socket awaiting response frames. On the Android side, the Kotlin reader reads the length prefix, reads exactly that many bytes, decrypts the payload, and forwards the HTTP request to OpenAI's edge. Streaming responses from OpenAI's SSE endpoint are re-framed as SSE chunk types and written back sequentially into the Bluetooth socket.
"Application-layer encryption over an already-encrypted transport is not redundant -- it is defense in depth. The RFCOMM channel can be intercepted at the Bluetooth layer. AES-GCM at the payload layer guarantees that intercepted frames remain useless without the session key." -- Mikko Hypponen, Chief Research Officer, F-Secure
What Is the End-to-End Encryption Architecture That Makes This Relay Enterprise-Safe?
ECDH key exchange on connection initiation derives an ephemeral AES-256-GCM session key unique to each connection. Even if the Bluetooth pairing layer is compromised via a man-in-the-middle attack, intercepted payload frames remain encrypted with a key the attacker cannot derive. Each frame uses a fresh IV to prevent replay attacks and ciphertext analysis.
- The offline PC initiates ECDH key exchange over the raw Bluetooth socket
- Both endpoints derive a shared symmetric key (AES-256-GCM) for the session
- Every frame payload is encrypted with the session key and a per-frame IV
- OpenAI API keys are stored on the Android relay device or fetched from an enterprise key server -- never on the air-gapped workstation
What Latency and Throughput Should Engineers Expect from the Bluetooth AI Relay?
Streaming SSE responses token-by-token cuts perceived latency by over 50% compared to waiting for the full response before transmission. Without streaming, the relay shows 980ms time-to-first-token -- noticeably slower than direct WiFi. With SSE streaming, TTFT drops to 410ms, which is within 90ms of direct WiFi for most LLM queries.
| Metric | Direct WiFi (Control) | RFCOMM Relay (No Streaming) | RFCOMM Relay (SSE Streaming) |
|---|---|---|---|
| Time to First Token | ~320ms | ~980ms | ~410ms |
| Throughput (tokens/sec) | 65 | 42 | 58 |
| Max payload size | Unlimited | 5 MB | Streamed |
Gzip compression on prompt inputs exceeding 20KB reduces Bluetooth transmission time on high-token-count prompts and prevents RFCOMM buffer bottlenecks on the relay device. For most enterprise query patterns (under 2,000 input tokens), compression adds negligible overhead.
Frequently Asked Questions
Does the Bluetooth relay violate air-gapping principles?
The relay acts as a strict protocol proxy. The offline workstation has no IP-level path to the cellular network, preventing general internet access, port scans, or reverse tunnel vulnerabilities. Only well-formed
frames transit the Bluetooth interface. This architecture satisfies the "no unauthorized internet path" constraint without requiring firewall rule changes on the restricted workstation.How does battery consumption on the Android relay device scale during production use?
Active Bluetooth and cellular radio operation consumes approximately 8% battery per hour of continuous processing. Seven Labs implements selective wake-locks that activate only during active sessions and release during idle periods. For shift-based enterprise deployments, this means a full charge handles 8-10 hours of intermittent usage -- sufficient for standard workday operations without mid-day charging.
How are OpenAI API keys managed without exposing them to the air-gapped workstation?
API keys are stored exclusively on the Android relay device or fetched from an enterprise key server. Individual user authentication is performed locally on the relay device before the ECDH key exchange completes. The air-gapped workstation never has access to the API key -- it only submits plaintext prompts that the relay encrypts and forwards.
Can this architecture support models other than GPT-4o?
Yes. The RFCOMM protocol layer is model-agnostic. The Android relay client targets any HTTPS endpoint conforming to the OpenAI chat completions API specification. Switching from GPT-4o to a self-hosted open-weight model behind an API-compatible server requires only an endpoint configuration change -- no changes to the Kotlin relay code or the offline PC client daemon.
Seven Labs builds AI infrastructure for environments where standard cloud deployment is not an option. If your organization operates restricted-network AI workloads or needs a secure edge-to-cloud architecture, contact our engineering team to scope a solution. See also our VAPT and security services for organizations that require security review alongside edge AI deployment.

