WebSocket relay that bridges AI coding agent CLIs (Claude Code, Codex, Gemini CLI, Snowflake Cortex) to any web interface — stream reasoning, tool calls, and file changes in real time.
Project description
ai-relay
WebSocket relay that bridges AI coding agent CLIs (Claude Code, Codex, Gemini CLI, Snowflake Cortex, and more) to any web interface — stream reasoning, tool calls, and file changes in real time.
Install
pip install ai-relay
Quick start
# Start the relay server (default: ws://0.0.0.0:8765)
ai-relay --port 8765
Then connect from OhWise Lab (or any WebSocket client) and send a handshake:
{"tool": "claude", "folder": "/path/to/project", "model": "claude-sonnet-4-6"}
The relay spawns the CLI process, streams all output as structured JSON events over WebSocket, and forwards your messages as stdin to the process.
Event types
| Type | Description |
|---|---|
session_start |
Process spawned |
session_end |
Process exited (includes exit_code) |
stdout / stderr |
Raw output lines |
reasoning |
Agent thinking/planning text |
tool_call |
Agent invoking a tool (Read, Edit, Bash…) |
tool_result |
Result of a tool call |
file_diff |
File created or edited |
response |
Final answer text |
quota_warning |
API quota / rate limit detected |
context_warning |
Context window nearing limit (includes context_pct) |
context_compacted |
Context was compacted |
error |
Relay or process error |
input_ack |
Relay confirms your message was sent to the process |
Sending commands
Send JSON over WebSocket:
{"text": "refactor the authentication module to use JWT"}
To send CLI commands (e.g. /compact, /clear):
{"text": "/compact"}
Supported tools
| Tool | Adapter | tool value |
|---|---|---|
| Claude Code | ClaudeCodeAdapter |
"claude" / "claude-code" |
| OpenAI Codex | GenericAdapter |
"codex" |
| Gemini CLI | GenericAdapter |
"gemini" |
| Snowflake Cortex | GenericAdapter |
"cortex" |
| Any CLI | GenericAdapter |
"generic" |
Python API
from ai_relay import RelayServer
server = RelayServer(host="0.0.0.0", port=8765)
server.run()
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ai_relay-0.2.3.tar.gz.
File metadata
- Download URL: ai_relay-0.2.3.tar.gz
- Upload date:
- Size: 20.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f07c29699f0e473bb01a28547ab6e0f783a94528c2db6ebf0c13d5a8c1af970d
|
|
| MD5 |
dfdb90e9d905c22f1e0257590fbdd316
|
|
| BLAKE2b-256 |
a43a02572477b8c950e4c4376fc6a26e7ad6cf8bd5d9cb9bd1de730779c187c9
|
File details
Details for the file ai_relay-0.2.3-py3-none-any.whl.
File metadata
- Download URL: ai_relay-0.2.3-py3-none-any.whl
- Upload date:
- Size: 22.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ef0491059ebd675177ce30a96544230e86b410d90947148538b144c4ff24cad
|
|
| MD5 |
01c65b18718e6ba67d72f49190639fcb
|
|
| BLAKE2b-256 |
f834b3706f68eaf2ab122998b158a21ca5cf227118fa040ea0fbdb5022a14ff0
|