diff --git a/src/Config.zig b/src/Config.zig index c885f527..afe5459d 100644 --- a/src/Config.zig +++ b/src/Config.zig @@ -220,7 +220,6 @@ pub const Agent = struct { common: Common = .{}, provider: AiProvider = .anthropic, model: ?[:0]const u8 = null, - api_key: ?[:0]const u8 = null, system_prompt: ?[:0]const u8 = null, repl: bool = true, script_file: ?[]const u8 = null, @@ -501,11 +500,11 @@ pub fn printUsageAndExit(self: *const Config, success: bool) void { \\--model The model name to use. \\ Defaults to a sensible default per provider. \\ - \\--api-key The API key. Can also be set via environment variable: - \\ ANTHROPIC_API_KEY, OPENAI_API_KEY, or GOOGLE_API_KEY. - \\ \\--system-prompt Override the default system prompt. \\ + \\The API key is read from the environment: + \\ANTHROPIC_API_KEY, OPENAI_API_KEY, or GOOGLE_API_KEY. + \\ ++ common_options ++ \\ \\version command @@ -927,15 +926,6 @@ fn parseAgentArgs( continue; } - if (std.mem.eql(u8, "--api-key", opt) or std.mem.eql(u8, "--api_key", opt)) { - const str = args.next() orelse { - log.fatal(.app, "missing argument value", .{ .arg = opt }); - return error.InvalidArgument; - }; - result.api_key = try allocator.dupeZ(u8, str); - continue; - } - if (std.mem.eql(u8, "--repl", opt)) { result.repl = true; continue; diff --git a/src/agent/Agent.zig b/src/agent/Agent.zig index 84236dbd..0441b868 100644 --- a/src/agent/Agent.zig +++ b/src/agent/Agent.zig @@ -84,9 +84,9 @@ pub fn init(allocator: std.mem.Allocator, app: *App, opts: Config.Agent) !*Self const is_script_mode = opts.script_file != null; // API key is only required for REPL mode and self-healing - const api_key: ?[:0]const u8 = opts.api_key orelse getEnvApiKey(opts.provider) orelse if (!is_script_mode) { + const api_key: ?[:0]const u8 = getEnvApiKey(opts.provider) orelse if (!is_script_mode) { log.fatal(.app, "missing API key", .{ - .hint = "Set the API key via --api-key or environment variable", + .hint = "Set ANTHROPIC_API_KEY, OPENAI_API_KEY, or GOOGLE_API_KEY", }); return error.MissingApiKey; } else null;