diff --git a/codex-rs/Cargo.lock b/codex-rs/Cargo.lock
index eab2dede1..3955f79f1 100644
--- a/codex-rs/Cargo.lock
+++ b/codex-rs/Cargo.lock
@@ -561,7 +561,6 @@ dependencies = [
"clap",
"codex-common",
"codex-core",
- "codex-protocol",
"serde",
"serde_json",
"tempfile",
diff --git a/codex-rs/chatgpt/Cargo.toml b/codex-rs/chatgpt/Cargo.toml
index db6e754f9..af5f910ef 100644
--- a/codex-rs/chatgpt/Cargo.toml
+++ b/codex-rs/chatgpt/Cargo.toml
@@ -11,7 +11,6 @@ anyhow = "1"
clap = { version = "4", features = ["derive"] }
codex-common = { path = "../common", features = ["cli"] }
codex-core = { path = "../core" }
-codex-protocol = { path = "../protocol" }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tokio = { version = "1", features = ["full"] }
diff --git a/codex-rs/chatgpt/src/chatgpt_token.rs b/codex-rs/chatgpt/src/chatgpt_token.rs
index 15192ce3f..ce9b7475c 100644
--- a/codex-rs/chatgpt/src/chatgpt_token.rs
+++ b/codex-rs/chatgpt/src/chatgpt_token.rs
@@ -1,5 +1,4 @@
use codex_core::CodexAuth;
-use codex_protocol::mcp_protocol::AuthMode;
use std::path::Path;
use std::sync::LazyLock;
use std::sync::RwLock;
@@ -20,7 +19,7 @@ pub fn set_chatgpt_token_data(value: TokenData) {
/// Initialize the ChatGPT token from auth.json file
pub async fn init_chatgpt_token_from_auth(codex_home: &Path) -> std::io::Result<()> {
- let auth = CodexAuth::from_codex_home(codex_home, AuthMode::ChatGPT)?;
+ let auth = CodexAuth::from_codex_home(codex_home)?;
if let Some(auth) = auth {
let token_data = auth.get_token_data().await?;
set_chatgpt_token_data(token_data);
diff --git a/codex-rs/cli/src/login.rs b/codex-rs/cli/src/login.rs
index f03509618..f0816d0b2 100644
--- a/codex-rs/cli/src/login.rs
+++ b/codex-rs/cli/src/login.rs
@@ -1,7 +1,6 @@
use codex_common::CliConfigOverrides;
use codex_core::CodexAuth;
use codex_core::auth::CLIENT_ID;
-use codex_core::auth::OPENAI_API_KEY_ENV_VAR;
use codex_core::auth::login_with_api_key;
use codex_core::auth::logout;
use codex_core::config::Config;
@@ -9,7 +8,6 @@ use codex_core::config::ConfigOverrides;
use codex_login::ServerOptions;
use codex_login::run_login_server;
use codex_protocol::mcp_protocol::AuthMode;
-use std::env;
use std::path::PathBuf;
pub async fn login_with_chatgpt(codex_home: PathBuf) -> std::io::Result<()> {
@@ -60,19 +58,11 @@ pub async fn run_login_with_api_key(
pub async fn run_login_status(cli_config_overrides: CliConfigOverrides) -> ! {
let config = load_config_or_exit(cli_config_overrides);
- match CodexAuth::from_codex_home(&config.codex_home, config.preferred_auth_method) {
+ match CodexAuth::from_codex_home(&config.codex_home) {
Ok(Some(auth)) => match auth.mode {
AuthMode::ApiKey => match auth.get_token().await {
Ok(api_key) => {
eprintln!("Logged in using an API key - {}", safe_format_key(&api_key));
-
- if let Ok(env_api_key) = env::var(OPENAI_API_KEY_ENV_VAR)
- && env_api_key == api_key
- {
- eprintln!(
- " API loaded from OPENAI_API_KEY environment variable or .env file"
- );
- }
std::process::exit(0);
}
Err(e) => {
diff --git a/codex-rs/cli/src/proto.rs b/codex-rs/cli/src/proto.rs
index 9b8cb92ee..623edca5a 100644
--- a/codex-rs/cli/src/proto.rs
+++ b/codex-rs/cli/src/proto.rs
@@ -37,10 +37,8 @@ pub async fn run_main(opts: ProtoCli) -> anyhow::Result<()> {
let config = Config::load_with_cli_overrides(overrides_vec, ConfigOverrides::default())?;
// Use conversation_manager API to start a conversation
- let conversation_manager = ConversationManager::new(AuthManager::shared(
- config.codex_home.clone(),
- config.preferred_auth_method,
- ));
+ let conversation_manager =
+ ConversationManager::new(AuthManager::shared(config.codex_home.clone()));
let NewConversation {
conversation_id: _,
conversation,
diff --git a/codex-rs/core/src/auth.rs b/codex-rs/core/src/auth.rs
index 1256584ce..e2dd1d73d 100644
--- a/codex-rs/core/src/auth.rs
+++ b/codex-rs/core/src/auth.rs
@@ -70,13 +70,9 @@ impl CodexAuth {
Ok(access)
}
- /// Loads the available auth information from the auth.json or
- /// OPENAI_API_KEY environment variable.
- pub fn from_codex_home(
- codex_home: &Path,
- preferred_auth_method: AuthMode,
- ) -> std::io::Result