1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! The Claude Code command line tool.
//!
//! Signs in on this machine and sends every prompt to Anthropic, which is why its reach is
//! [`crate::Reach::LocalCli`] rather than self hosted: the credential is local and the data
//! is not.
use crate;
use Duration;
/// The program this preset runs.
pub const PROGRAM: &str = "claude";
/// What `claude --output-format json` prints.
///
/// The answer is at `/result` and the usage at `/usage`, spelled the way Anthropic spells it
/// everywhere else.
/// A provider that runs the Claude Code tool.
///
/// JSON mode, deliberately. In plain mode the whole document is the answer and the call
/// reports as unmeasured, which every cost report reads as free.
///
/// It knows no models until you name them. A command line tool cannot be asked what it
/// serves, so a provider that answered for every name would turn a typo into a real model.
///
/// [`llmr::Provider::validate`](crate::Provider::validate) probes with `--version`, which
/// establishes that the tool is installed and nothing about the login inside it. That is all
/// this tool answers for free, and a `Ready` from here should be read as no more than that.
///
/// ```no_run
/// use llmr::providers::anthropic::cli;
/// use llmr::{ChatRequest, Message, Provider};
/// use std::time::Duration;
///
/// # async fn example() -> llmr::Result<()> {
/// let claude = cli::provider(Duration::from_secs(300))
/// .serving(["claude-sonnet-5"]);
///
/// let reply = claude
/// .chat(ChatRequest::new("claude-sonnet-5", vec![Message::user("Hello")]))
/// .await?;
/// # Ok(())
/// # }
/// ```