Date: 2026-05-06
Build a Rust CLI tool for testing an LLM relay service. The tool should start with reliable single-request checks, then grow into RPM/concurrency testing and dataset-based accuracy evaluation.
The first implementation will use a modular single-crate architecture. This keeps initialization light while still giving clear boundaries for config loading, CLI parsing, protocol adapters, request execution, benchmarks, and metrics.
First phase:
Later phase:
Use scheme B: one binary crate split into internal modules.
Planned structure:
src/
main.rs
cli.rs
config.rs
runner.rs
metrics.rs
protocols/
mod.rs
openai.rs
anthropic.rs
benchmarks/
mod.rs
aime.rs
gpqa.rs
judge.rs
Module responsibilities:
cli: Defines subcommands and flags using clap.config: Loads YAML config, resolves environment variable references, and validates provider settings.protocols: Converts internal request data into provider-specific HTTP requests and parses responses.runner: Executes one logical model request and returns response text, elapsed time, provider metadata, and errors.benchmarks: Loads official benchmark datasets, runs them through the runner, and judges answers.metrics: Aggregates latency, success rate, error distribution, and accuracy summaries.main: Wires the CLI, config, runner, and command handlers together.Initial commands:
lq_token_test check --config config.yaml --provider openai --model gpt-4o-mini --prompt "hello"
lq_token_test dataset fetch aime2026
lq_token_test dataset fetch gpqa-diamond
lq_token_test bench aime2026 --config config.yaml --provider openai --model gpt-4o-mini --concurrency 4
lq_token_test bench gpqa-diamond --config config.yaml --provider anthropic --model claude-3-5-sonnet-latest --limit 100 --concurrency 4
lq_token_test rpm --config config.yaml --provider openai --rpm 60 --duration 60s --prompt "hello"
The check command proves that a relay, token, model, and protocol shape work.
The dataset fetch command downloads an official dataset into local storage and writes source metadata.
The bench command runs an official benchmark dataset and reports accuracy plus request metrics.
The rpm command sends repeated requests at a target rate and reports latency and error behavior.
Example:
default_provider: openai
providers:
openai:
protocol: openai
base_url: "https://relay.example.com/v1"
api_token: "${OPENAI_RELAY_TOKEN}"
default_model: "gpt-4o-mini"
anthropic:
protocol: anthropic
base_url: "https://relay.example.com"
api_token: "${ANTHROPIC_RELAY_TOKEN}"
default_model: "claude-3-5-sonnet-latest"
benchmarks:
data_dir: "data/benchmarks"
aime2026:
source: "huggingface:MathArena/aime_2026"
split: "train"
gpqa_diamond:
source: "huggingface:Idavidrein/gpqa"
split: "gpqa_diamond"
API tokens should be allowed directly in YAML for local testing, but environment variable references are preferred.
First benchmark datasets:
MathArena/aime_2026.
problem_idx, problem, answer.Idavidrein/gpqa.
HF_TOKEN.Downloaded data should live under data/benchmarks/ by default and should not be committed to git. Each download writes a metadata.yaml with dataset name, source, split, download time, file hash, row count, and license note. Benchmark commands should read from local files and tell the user to run dataset fetch if required data is missing.
Judging rules:
aime2026: extract the final integer answer from model output and compare with the official answer.gpqa-diamond: ask the model to answer with one option letter and compare against the official correct option.The first phase accuracy score is an official-dataset relay evaluation signal. It should not be presented as matching or disproving official model accuracy until dataset revision, prompt template, sample count, temperature, and scoring method are aligned with the official report.
Recommended crates:
clap: CLI parser and subcommands.serde, serde_yaml, serde_json: config and dataset parsing.tokio: async runtime.reqwest: HTTP client.anyhow: simple top-level CLI error handling.thiserror: structured module-level errors.tracing, tracing-subscriber: logs.indicatif: progress display for benchmark and RPM runs.hdrhistogram: latency percentiles.regex: answer extraction for numeric and multiple-choice judging.Prefer reqwest with Rustls TLS. Avoid provider SDKs in the first phase so protocol compatibility remains transparent and easy to inspect.
The CLI should surface concise user-facing errors:
Benchmark and RPM commands should continue after per-request failures and include failures in the final summary.
Initial tests should cover:
Network tests should be kept opt-in because they require real relay credentials.
/chat/completions.