widevin for Rust
Rust 1.85+ bindings for Devin/Cascade OAuth login, caller-controlled token
storage, model discovery, and streaming chat/tool events. This crate mirrors
the behavior of the TypeScript widevin package and uses Reqwest with Rustls.
Only use Devin/Cascade programmatic access when permitted by your organization and applicable terms.
Install
[]
= "0.3.0"
= "0.3"
= { = "1", = ["macros", "rt-multi-thread"] }
Quick start
use StreamExt;
use ;
async
Store raw tokens. The devin-session-token$ prefix is added only at request
boundaries; an empty token is treated as absent. File token stores create
private 0600 files on Unix. ToolCallDelta.arguments may contain a
throttled parsed JSON snapshot; the final ToolCallEnd.arguments value is
authoritative.
Enterprise client metadata
If your Devin organization authorizes Cascade models by client identity, set
the approved fields in DevinProviderOptions. They are applied to model
discovery, JWT auth, assignment, and chat requests.
use ;
let provider = create_devin_provider;
Discovery defaults to the native Chisel dev identity; auth, assignment, and
chat use the released Devin CLI identity (3000.11.3). Discovery falls back
to the Windsurf identity and raw key for legacy Enterprise seats. Custom
fields override these identities consistently.
Native discovery and routing
provider.list_models() retains the current credential's configurations for
provider.stream_chat(). Adaptive routers are assigned before chat; native
Fusion pairings run their live lead. When using stream_devin_chat directly,
pass a discovered model as StreamDevinChatOptions.model_config, alongside
its ID in model. The configuration supplies output limits and parallel-tool
capabilities. Credential changes invalidate the provider's stored catalog.
Discovery keeps each native reasoning-effort UID, with family axes, account
default, presentation flags, raw token rates, and authoritative capabilities.
max_tokens describes output; context_window describes input/context.
SWE-1.6 variants are text-only, following upstream's documented limitation.
Raw rates do not include pricing tiers or cache-write estimates.
Default chat sampling is temperature 1, float32-widened top-p 0.95, and no
implicit stop patterns. Caller overrides take precedence. Inline Gemini
nullable and mixed-type schemas are adapted on the wire without changing
the caller's schema. Parent and branch constraints are both preserved;
overlapping keywords keep the non-null branch under anyOf. Supply inline
schemas rather than $ref references. History tool IDs remain paired after
sanitization and 40-character capping; empty assistant rows are omitted.
DevinStreamEvent::Done includes optional response_id for replay and
upstream_model for the actual/assigned model. Existing matches can use
Done { reason, .. }. The new Credits variant exposes raw billing values
reported on a response frame. Existing token-usage fields stay separate.
Use ..Default::default() when constructing public request/config structs
to accommodate new fields. This update adds fields to DevinModel,
DevinClientMetadata, DevinChatRequest, and StreamDevinChatOptions.
Run the full smoke-test example from the repository:
The example uses DEVIN_TOKEN, .devin-token, or the OAuth callback flow in
that order. Delete .devin-token to remove the cached local token; this does
not revoke the credential server-side.