Crates.io | union_square |
lib.rs | union_square |
version | 0.2.0 |
created_at | 2025-07-24 16:09:05.459352+00 |
updated_at | 2025-07-28 21:20:44.362259+00 |
description | A proxy/wire-tap service for making LLM calls and recording everything that happens in a session for later analysis and test-case extraction |
homepage | |
repository | https://github.com/jwilger/union_square |
max_upload_size | |
id | 1766240 |
size | 2,582,739 |
"I don't care what they're talking about. All I want is a nice, fat recording."
— Harry Caul, The Conversation (1974)
|
Union SquareA transparent, high-performance proxy for LLM API calls |
Comprehensive observability, testing, and optimization for AI-powered applications.
🚧 Early Development - This project is in the initial development phase. Core functionality is being implemented.
Union Square acts as a drop-in proxy between your applications and LLM providers (OpenAI, Anthropic, AWS Bedrock, Google Vertex AI), capturing every interaction for analysis, debugging, and testing. It's designed to add minimal latency (< 5ms) while providing powerful observability features.
# Clone the repository
git clone https://github.com/jwilger/union_square.git
cd union_square
# Option 1: Using Nix (Recommended)
# This provides a consistent development environment with Rust 1.88.0
nix develop
# Option 2: Manual setup
# Ensure you have Rust 1.88+ installed
rustup update
# Start PostgreSQL
docker-compose up -d
# Build the project
cargo build --release
# Run the server
./target/release/union_square
This project includes a Nix flake that provides a complete development environment. The Nix shell includes:
To use the Nix development shell:
# Enter the development shell
nix develop
# All Rust tools are now available
cargo --version # Should show cargo 1.88.0
rustc --version # Should show rustc 1.88.0
# Run any cargo commands as usual
cargo build
cargo test
cargo run
The Nix shell ensures all developers and CI environments use identical tool versions, eliminating "works on my machine" issues.
Replace your LLM API endpoints with Union Square URLs:
- https://api.openai.com/v1/chat/completions
+ https://your-union-square.com/openai/v1/chat/completions
Add session tracking headers:
X-Union-Square-Session-ID: your-session-id
X-Union-Square-Metadata: {"user_id": "12345", "feature": "chat"}
Union Square uses a TOML configuration file. See config.example.toml
for all options.
[server]
port = 8080
host = "0.0.0.0"
[database]
url = "postgresql://user:pass@localhost/union_square"
[cache]
enabled = true
ttl_seconds = 3600
[privacy]
pii_detection = true
default_recording = true
Union Square follows a functional core, imperative shell architecture:
We use Architecture Decision Records (ADRs) to document significant architectural decisions.
docs/adr/
directorynpm run adr:new
Key architectural decisions are documented including technology choices, patterns, and design rationale.
See CONTRIBUTING.md for development guidelines.
We strongly recommend using the Nix development shell for a consistent environment:
# Enter the Nix shell (provides Rust 1.88.0 and all tools)
nix develop
# Format code
cargo fmt
# Run lints
cargo clippy --all-targets -- -D warnings
# Run tests
cargo test
# Type check
cargo check --all-targets
This project is licensed under the MIT License - see the LICENSE file for details.
We welcome contributions! Please see our Contributing Guidelines and Code of Conduct.
For security vulnerabilities, please email security@example.com instead of using the issue tracker.