Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix: ChatGPT OAuth provider now works in pipes

Louis Beaumontf5624281a327
diff --git a/crates/screenpipe-core/src/agents/pi.rs b/crates/screenpipe-core/src/agents/pi.rs
index fe018a89b..5f1c71586 100644
--- a/crates/screenpipe-core/src/agents/pi.rs
+++ b/crates/screenpipe-core/src/agents/pi.rs
@@ -221,12 +221,23 @@ impl PiExecutor {
provider_url.unwrap_or("https://api.openai.com/v1"),
"OPENAI_API_KEY",
),
+ "openai-chatgpt" => (
+ "openai-chatgpt",
+ "https://api.openai.com/v1",
+ "OPENAI_CHATGPT_TOKEN",
+ ),
other => (other, provider_url.unwrap_or(""), "CUSTOM_API_KEY"),
};
+ let wire_api = if prov == "openai-chatgpt" {
+ "openai-codex-responses"
+ } else {
+ "openai-completions"
+ };
+
let user_provider = json!({
"baseUrl": base_url,
- "api": "openai-completions",
+ "api": wire_api,
"apiKey": api_key,
"models": [{
"id": mdl,
@@ -355,6 +366,9 @@ impl PiExecutor {
"openai" | "openai-byok" => {
cmd.env("OPENAI_API_KEY", key);
}
+ "openai-chatgpt" => {
+ cmd.env("OPENAI_CHATGPT_TOKEN", key);
+ }
"custom" => {
cmd.env("CUSTOM_API_KEY", key);
}
@@ -444,6 +458,9 @@ impl PiExecutor {
"openai" | "openai-byok" => {
cmd.env("OPENAI_API_KEY", key);
}
+ "openai-chatgpt" => {
+ cmd.env("OPENAI_CHATGPT_TOKEN", key);
+ }
"custom" => {
cmd.env("CUSTOM_API_KEY", key);
}
diff --git a/crates/screenpipe-core/src/pipes/mod.rs b/crates/screenpipe-core/src/pipes/mod.rs
index bbf32fe67..ac68c0119 100644
--- a/crates/screenpipe-core/src/pipes/mod.rs
+++ b/crates/screenpipe-core/src/pipes/mod.rs
@@ -271,6 +271,7 @@ fn resolve_preset(pipes_dir: &Path, preset_id: &str) -> Option<ResolvedPreset> {
"pi" => Some("screenpipe"),
"native-ollama" => Some("ollama"),
"openai" => Some("openai"),
+ "openai-chatgpt" => Some("openai-chatgpt"),
"custom" => Some("custom"), // custom uses openai-compatible API at a user-specified URL
_ => None,
})
@@ -282,12 +283,28 @@ fn resolve_preset(pipes_dir: &Path, preset_id: &str) -> Option<ResolvedPreset> {
.filter(|s| !s.is_empty())
.map(|s| s.to_string());
- let api_key = preset
+ let mut api_key = preset
.get("apiKey")
.and_then(|v| v.as_str())
.filter(|s| !s.is_empty())
.map(|s| s.to_string());
+ // ChatGPT OAuth: read token from stored file (no apiKey in preset)
+ if provider.as_deref() == Some("openai-chatgpt") && api_key.is_none() {
+ let token_path = dirs::home_dir()
+ .map(|h| h.join(".screenpipe").join("chatgpt-oauth.json"));
+ if let Some(path) = token_path {
+ if let Ok(content) = std::fs::read_to_string(&path) {
+ if let Ok(token_data) = serde_json::from_str::<serde_json::Value>(&content) {
+ api_key = token_data
+ .get("access_token")
+ .and_then(|v| v.as_str())
+ .map(|s| s.to_string());
+ }
+ }
+ }
+ }
+
let prompt = preset
.get("prompt")
.and_then(|v| v.as_str())