Every Other Token is a tool that allows researchers to intercept OpenAI's streaming API and manipulate token responses in real-time. This innovative approach facilitates studies on token dependencies, interpretability, and creative AI collaborations, paving the way for new insights in LLM interaction.
A real-time LLM stream interceptor for token-level interaction research, built in Rust.
Every Other Token intercepts OpenAI's streaming API responses and applies transformations to alternating tokens in real-time. Instead of waiting for complete responses, it intervenes at the token level, creating a new paradigm for LLM interaction and analysis.

Screenshot showing the tool in action with the reverse transform
# Clone the repository
git clone https://github.com/yourusername/every-other-token-rust.git
cd every-other-token-rust
# Build the project
cargo build --release
# Set your OpenAI API key
set OPENAI_API_KEY=your-api-key-here
# Simple example with reverse transform
cargo run -- "Tell me a story about a robot"
# With specific transformation
cargo run -- "Explain quantum physics" uppercase
# With different model
cargo run -- "Write a haiku" mock gpt-4
| Transform | Description | Example Input | Example Output |
|---|---|---|---|
reverse | Reverses odd tokens | "hello world" | "hello dlrow" |
uppercase | Converts odd tokens to uppercase | "hello world" | "hello WORLD" |
mock | Alternating case (mocking text) | "hello world" | "hello WoRlD" |
noise | Adds random characters to odd tokens | "hello world" | "hello world*" |
This tool opens up novel research possibilities:
# Study how meaning degrades with token corruption
cargo run -- "Solve this math problem: 2+2=" reverse
# Test how well LLMs maintain coherence under disruption
cargo run -- "Continue this story logically..." noise
# Use transformations to create unexpected creative outputs
cargo run -- "Write a poem about nature" mock
every-other-token [PROMPT] [TRANSFORM] [MODEL]
Arguments:
PROMPT: Your input prompt (required)TRANSFORM: Transformation type - reverse, uppercase, mock, noise (default: reverse)MODEL: OpenAI model to use (default: gpt-3.5-turbo)Examples:
cargo run -- "Hello world"
cargo run -- "Hello world" uppercase
cargo run -- "Hello world" mock gpt-4
# Clone and build
git clone https://github.com/Mattbusel/Every-Other-Token.git
cd every-other-token-rust
cargo build --release
# Run tests
cargo test
# Run with debug info
RUST_LOG=debug cargo run -- "test prompt"
The Rust implementation offers significant performance improvements:
This project is licensed under the MIT License - see the LICENSE file for details.
"Every token tells a story. Every other token tells a different one."
No comments yet.
Sign in to be the first to comment.