Skip to main content

Crate auth_cloudflare

Crate auth_cloudflare 

Source
Expand description

auth-cloudflare - Cloudflare Workers AI auth provider core.

Account/token resolution, Workers AI endpoint construction, model catalog normalization types, and account-scoped cache path helpers. The Hermes integration crate (auth-hermes-cloudflare) and the Python plugin both build on this crate so the endpoint/auth logic has exactly one source of truth.

Scope: direct Cloudflare-hosted @cf/... Workers AI text-generation models over the OpenAI-compatible Chat Completions surface. AI Gateway third-party models, non-chat modalities, and Cloudflare MCP operations are explicitly out of scope for this package.

Re-exports§

pub use auth::AccountCredentials;
pub use auth::AuthProvider;
pub use cache::cache_dir_for_account;
pub use cache::cache_is_stale;
pub use cache::read_catalog_cache;
pub use cache::write_catalog_cache;
pub use cache::CatalogCacheMeta;
pub use capabilities::infer_from_id;
pub use catalog::CapabilityState;
pub use catalog::ModelRecord;
pub use catalog::ModelRole;
pub use error::CloudflareError;
pub use fallback_catalog::experimental_models;
pub use fallback_catalog::fallback_models;
pub use health::CONFORMANCE_SUITE_VERSION;
pub use health::FailureClass;
pub use health::FailureEvidence;
pub use health::ModelHealthRecord;
pub use health::ModelVerification;
pub use health::VerificationConfidence;
pub use health::VerificationStatus;
pub use observability::debug_protocol_enabled;
pub use observability::redact;
pub use observability::Event;
pub use observability::EventLog;
pub use observability::DEBUG_PROTOCOL_ENV;
pub use observability::EVENT_LOG_ENV;
pub use observability::OBSERVABILITY_ENV;
pub use policy::ranking_score;
pub use policy::ModelPolicy;
pub use policy::ModelStatus;
pub use policy::PolicyEntry;
pub use policy::RankingBreakdown;
pub use policy::REFERENCE_CONTEXT_TOKENS;
pub use policy::REFERENCE_LATENCY_MS;
pub use policy::REFERENCE_PRICE_PER_MILLION;
pub use policy::WEIGHT_CONTEXT;
pub use policy::WEIGHT_DELIVERY;
pub use policy::WEIGHT_LATENCY;
pub use policy::WEIGHT_PRICE;
pub use policy::WEIGHT_TOOL_LOOP;
pub use schema::VersionInfo;
pub use schema::CATALOG_SCHEMA_VERSION;
pub use schema::PROTOCOL_VERSION;
pub use tool_loop::all_arguments_valid;
pub use tool_loop::execute_tool;
pub use tool_loop::find_duplicates;
pub use tool_loop::fixture_source;
pub use tool_loop::run_tool_loop;
pub use tool_loop::tool_schemas;
pub use tool_loop::validate_ordering;
pub use tool_loop::ToolCallObservation;
pub use tool_loop::ToolLoopOutcome;
pub use tool_loop::TOOL_LOOP_MAX_TURNS;
pub use tool_loop::TOOL_LOOP_SYSTEM_PROMPT;
pub use tool_loop::TOOL_LOOP_USER_PROMPT;
pub use verify::HealthStore;
pub use verify::SmokeRunReport;
pub use verify::SuiteKind;
pub use verify::MAX_COST_ENV;

Modules§

auth
Auth - Cloudflare account ID + API token → Workers AI endpoint resolution.
cache
Cache - account-scoped, atomic cache paths and versioned catalog cache for the Workers AI catalog.
capabilities
Capabilities - marker-based capability inference from a model id.
catalog
Catalog - Workers AI model records and OpenRouter-format payload normalization.
config
Config - typed account/token/base-url/cache resolution with strict precedence and secret-safe token handling.
error
Errors - actionable, token-free Cloudflare provider errors.
fallback_catalog
Fallback catalog - the offline model list when live discovery fails.
fetch
Fetch - live Workers AI model catalog retrieval over HTTPS.
health
Health - delivery health records, conformance verification, and typed failure evidence for Cloudflare Workers AI models.
observability
Observability - opt-in, local-first structured event logging and secret-safe protocol redaction.
policy
Policy - status, rank, and primary-agent eligibility for known models.
schema
Schema - versioned JSON contract metadata for the catalog cache and the auth-cloudflare version --format json CLI contract (feedback 06).
tool_loop
Tool loop - deterministic multi-turn fake-tool conformance harness (feedback 02, suite 40-multi-turn-tool-loop).
verify
Verify - the Phase-3 live conformance smoke suite, sanitized failure evidence, and the versioned model-health.json store (task sa-0).

Constants§

DEFAULT_MODEL
Default inference model - the project’s development default.
EXPERIMENTAL_MODEL
Experimental model - available but not default (delivery reliability not yet validated; requires passing conformance suite).
PREMIUM_CODING_MODEL
Premium coding model (higher capability tier).
PREMIUM_REASONING_MODEL
Premium reasoning model (higher capability tier).
VERSION
crate version, from Cargo.toml.