MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / from_env

Method from_env

claw-code/rust/crates/api/src/client.rs:34–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32
33impl AuthSource {
34 pub fn from_env() -> Result<Self, ApiError> {
35 let api_key = read_env_non_empty("ANTHROPIC_API_KEY")?;
36 let auth_token = read_env_non_empty("ANTHROPIC_AUTH_TOKEN")?;
37 match (api_key, auth_token) {
38 (Some(api_key), Some(bearer_token)) => Ok(Self::ApiKeyAndBearer {
39 api_key,
40 bearer_token,
41 }),
42 (Some(api_key), None) => Ok(Self::ApiKey(api_key)),
43 (None, Some(bearer_token)) => Ok(Self::BearerToken(bearer_token)),
44 (None, None) => Err(ApiError::MissingApiKey),
45 }
46 }
47
48 #[must_use]
49 pub fn api_key(&self) -> Option<&str> {

Callers

nothing calls this directly

Calls 3

read_env_non_emptyFunction · 0.85
read_base_urlFunction · 0.85
with_base_urlMethod · 0.80

Tested by

no test coverage detected