Skip to main content

Crate tt_shared

Crate tt_shared 

Source
Expand description

Shared types, errors, and traits for the TokenTrimmer workspace.

No business logic lives here — only the contracts that other crates implement. See docs/02-provider-adapter-guide.md for the Provider trait.

Re-exports§

pub use capability_check::message_text_for_estimation;
pub use capability_check::RequiredCapabilities;
pub use context::CallerTier;
pub use context::RequestContext;
pub use error::ProviderError;
pub use messages::parse_cache_control;
pub use messages::CacheControlConfig;
pub use messages::CacheMode;
pub use messages::ChatCompletionChunk;
pub use messages::ChatCompletionRequest;
pub use messages::ChatCompletionResponse;
pub use messages::Choice;
pub use messages::ContentPart;
pub use messages::EmbeddingsRequest;
pub use messages::EmbeddingsResponse;
pub use messages::Message;
pub use messages::MessageContent;
pub use messages::Tool;
pub use messages::ToolCall;
pub use messages::ToolChoice;
pub use pricing::ModelInfo;
pub use pricing::ModelPricing;
pub use provider::Provider;
pub use url_guard::filter_extra_headers;
pub use url_guard::find_denied_header;
pub use url_guard::validate_provider_url;
pub use url_guard::UrlGuardError;
pub use usage::Usage;

Modules§

capability_check
Capability and context-window guard for the routing / failover path.
context
RequestContext carries authenticated identity, trace IDs, and credentials through the request lifecycle. Adapters are stateless — every call gets a fresh context.
error
Error types returned by provider adapters. The core layer maps these to HTTP status codes and decides retry strategy — adapters do not retry.
messages
OpenAI-compatible request/response shapes. Canonical wire format across all providers — adapters translate to/from provider-native formats.
pricing
Pricing tables per model. Values are a manually-curated snapshot taken from provider pricing pages; they are NOT refreshed automatically. effective_at records when each rate took effect and lets us replay historical telemetry against the correct rate. To refresh rates, edit data/pricing.toml and append new entries — see scripts/refresh-pricing.sh for the manual workflow. See also docs/02-provider-adapter-guide.md.
provider
The Provider trait every adapter implements. See docs/02-provider-adapter-guide.md for the contract and the worked Anthropic example.
providers
Lightweight model → provider lookup.
url_guard
SSRF and header-injection guard for customer-supplied provider URLs.
usage
Token usage and cost accounting. Token counts come from provider responses — we never estimate locally for billing.