Skip to main content

llm_verify/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2//! Black-box verification for LLM API endpoints, as a library.
3//!
4//! The [`llm-verify`](https://crates.io/crates/llm-verify) binary is a thin CLI
5//! over this crate. Everything it does is reachable here, so a caller embedding
6//! the engine gets the same probes, the same order and the same verdict as the
7//! published tool — which is what lets it claim the two agree.
8//!
9//! ```no_run
10//! use llm_verify::{engine, probes::Cancel, Endpoint};
11//!
12//! # async fn demo() -> anyhow::Result<()> {
13//! let cfg = engine::RunConfig::new(Endpoint {
14//!     base_url: "https://api.anthropic.com".into(),
15//!     api_key: std::env::var("ANTHROPIC_API_KEY").unwrap_or_default(),
16//!     model: "claude-opus-4-5".into(),
17//!     ..Default::default()
18//! });
19//! let report = engine::run(cfg, &Cancel::new(), &mut |_| {}).await?;
20//! println!("{:?} {}", report.verdict.authenticity, report.verdict.score);
21//! # Ok(())
22//! # }
23//! ```
24//!
25//! # Probing something you reach through a relay
26//!
27//! Half the suite asks questions *about the endpoint* — its error envelopes,
28//! its response headers, the token counts it reports. Those answers describe
29//! whichever hop is nearest the caller, so behind a relay they describe the
30//! relay. Ask for [`probes::Selection::model_only`] and only the steps whose
31//! evidence is the generated text itself will run. See [`probes::Subject`].
32//!
33//! ```no_run
34//! # use llm_verify::{engine, probes::Cancel, Endpoint};
35//! # async fn demo(endpoint: Endpoint) -> anyhow::Result<()> {
36//! let cfg = engine::RunConfig::new(endpoint)
37//!     .model_only()
38//!     .depth(llm_verify::probes::Depth::Fast)
39//!     // Chosen by the caller, recorded in the report, so a contested verdict
40//!     // can be replayed probe for probe.
41//!     .seed(0x5EED);
42//! let report = engine::run(cfg, &Cancel::new(), &mut |_| {}).await?;
43//! # Ok(())
44//! # }
45//! ```
46
47#[macro_use]
48pub mod i18n;
49
50pub mod client;
51pub mod engine;
52pub mod pricing;
53pub mod probes;
54pub mod protocol;
55pub mod report;
56pub mod util;
57pub mod verdict;
58
59#[cfg(feature = "html")]
60pub mod html;
61
62pub use client::{Endpoint, RequestOpts};
63pub use engine::{run, RunConfig};
64pub use i18n::Lang;
65pub use probes::{Cancel, Depth, Event, Pace, Selection, Subject};
66pub use protocol::Protocol;
67pub use report::{Authenticity, Channel, ProbeResult, Report, Status, Verdict};