Skip to content

Commit 3a79cbe

Browse files
committed
Add OpenAI key wiring for clawdinator
1 parent 4e9ce1c commit 3a79cbe

File tree

6 files changed

+27
-2
lines changed

6 files changed

+27
-2
lines changed

.github/workflows/image-build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ jobs:
6363
for file in \
6464
nix/age-secrets/clawdinator-github-app.pem.age \
6565
nix/age-secrets/clawdinator-discord-token.age \
66-
nix/age-secrets/clawdinator-anthropic-api-key.age
66+
nix/age-secrets/clawdinator-anthropic-api-key.age \
67+
nix/age-secrets/clawdinator-openai-api-key.age
6768
do
6869
test -f "$file"
6970
done

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ Secrets (required):
7777
- Discord bot token (per instance).
7878
- Discord bot tokens are explicit files via agenix.
7979
- Anthropic API key (Claude models).
80+
- OpenAI API key (OpenAI models).
8081
- AWS credentials (image pipeline + infra).
8182
- Agenix image key (baked into AMI via CI).
8283

docs/SECRETS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ Runtime (CLAWDINATOR):
1818
- Discord bot token (required, per instance).
1919
- GitHub token (required): GitHub App installation token (preferred) or a read-only PAT.
2020
- Anthropic API key (required for Claude models).
21+
- OpenAI API key (required for OpenAI models).
2122

2223
Explicit token files (standard):
2324
- `services.clawdinator.discordTokenFile`
2425
- `services.clawdinator.anthropicApiKeyFile`
26+
- `services.clawdinator.openaiApiKeyFile`
2527
- `services.clawdinator.githubPatFile` (PAT path, if not using GitHub App; exports `GITHUB_TOKEN` + `GH_TOKEN`)
2628

2729
GitHub App (preferred):
@@ -35,6 +37,7 @@ Agenix (local secrets repo):
3537
- Decrypt on host with agenix; point NixOS options at `/run/agenix/*`.
3638
- Image builds bake the agenix identity to `/etc/agenix/keys/clawdinator.agekey`; do not commit this key.
3739
- Required files (minimum): `clawdinator-github-app.pem.age`, `clawdinator-discord-token.age`, `clawdinator-anthropic-api-key.age`.
40+
- Also required for OpenAI: `clawdinator-openai-api-key.age`.
3841
- CI image pipeline (stored locally, not on hosts): `clawdinator-image-uploader-access-key-id.age`, `clawdinator-image-uploader-secret-access-key.age`, `clawdinator-image-bucket-name.age`, `clawdinator-image-bucket-region.age`.
3942

4043
Example NixOS wiring (agenix):
@@ -47,13 +50,17 @@ Example NixOS wiring (agenix):
4750
"/var/lib/clawd/nix-secrets/clawdinator-github-app.pem.age";
4851
age.secrets."clawdinator-anthropic-api-key".file =
4952
"/var/lib/clawd/nix-secrets/clawdinator-anthropic-api-key.age";
53+
age.secrets."clawdinator-openai-api-key".file =
54+
"/var/lib/clawd/nix-secrets/clawdinator-openai-api-key.age";
5055
age.secrets."clawdinator-discord-token".file =
5156
"/var/lib/clawd/nix-secrets/clawdinator-discord-token.age";
5257
5358
services.clawdinator.githubApp.privateKeyFile =
5459
"/run/agenix/clawdinator-github-app.pem";
5560
services.clawdinator.anthropicApiKeyFile =
5661
"/run/agenix/clawdinator-anthropic-api-key";
62+
services.clawdinator.openaiApiKeyFile =
63+
"/run/agenix/clawdinator-openai-api-key";
5764
services.clawdinator.discordTokenFile =
5865
"/run/agenix/clawdinator-discord-token";
5966
}

nix/examples/clawdinator-host.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"/var/lib/clawd/nix-secrets/clawdinator-github-app.pem.age";
55
age.secrets."clawdinator-anthropic-api-key".file =
66
"/var/lib/clawd/nix-secrets/clawdinator-anthropic-api-key.age";
7+
age.secrets."clawdinator-openai-api-key".file =
8+
"/var/lib/clawd/nix-secrets/clawdinator-openai-api-key.age";
79
age.secrets."clawdinator-discord-token".file =
810
"/var/lib/clawd/nix-secrets/clawdinator-discord-token.age";
911

@@ -47,6 +49,7 @@
4749
};
4850

4951
anthropicApiKeyFile = "/run/agenix/clawdinator-anthropic-api-key";
52+
openaiApiKeyFile = "/run/agenix/clawdinator-openai-api-key";
5053
discordTokenFile = "/run/agenix/clawdinator-discord-token";
5154

5255
githubApp = {

nix/hosts/clawdinator-1-common.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ in
3737
owner = "clawdinator";
3838
group = "clawdinator";
3939
};
40+
age.secrets."clawdinator-openai-api-key" = {
41+
file = "${secretsPath}/clawdinator-openai-api-key.age";
42+
owner = "clawdinator";
43+
group = "clawdinator";
44+
};
4045
age.secrets."clawdinator-discord-token" = {
4146
file = "${secretsPath}/clawdinator-discord-token.age";
4247
owner = "clawdinator";
@@ -122,6 +127,7 @@ in
122127
};
123128

124129
anthropicApiKeyFile = "/run/agenix/clawdinator-anthropic-api-key";
130+
openaiApiKeyFile = "/run/agenix/clawdinator-openai-api-key";
125131
discordTokenFile = "/run/agenix/clawdinator-discord-token";
126132

127133
githubApp = {

nix/modules/clawdinator.nix

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ let
8888
toolchain.docs;
8989

9090
tokenWrapper =
91-
if cfg.anthropicApiKeyFile != null || cfg.discordTokenFile != null || cfg.githubPatFile != null then
91+
if cfg.anthropicApiKeyFile != null || cfg.discordTokenFile != null || cfg.githubPatFile != null || cfg.openaiApiKeyFile != null then
9292
pkgs.writeShellScriptBin "clawdinator-gateway" ''
9393
set -euo pipefail
9494
@@ -116,6 +116,7 @@ let
116116
${lib.optionalString (cfg.anthropicApiKeyFile != null) "read_token ANTHROPIC_API_KEY \"${cfg.anthropicApiKeyFile}\""}
117117
${lib.optionalString (cfg.discordTokenFile != null) "read_token DISCORD_BOT_TOKEN \"${cfg.discordTokenFile}\""}
118118
${lib.optionalString (cfg.githubPatFile != null) "read_token \"GITHUB_TOKEN GH_TOKEN\" \"${cfg.githubPatFile}\""}
119+
${lib.optionalString (cfg.openaiApiKeyFile != null) "read_token \"OPENAI_API_KEY OPEN_AI_APIKEY\" \"${cfg.openaiApiKeyFile}\""}
119120
120121
exec "${cfg.package}/bin/clawdbot" gateway --port ${toString cfg.gatewayPort}
121122
''
@@ -251,6 +252,12 @@ in
251252
description = "Path to file containing Anthropic API key (plain text).";
252253
};
253254

255+
openaiApiKeyFile = mkOption {
256+
type = types.nullOr types.str;
257+
default = null;
258+
description = "Path to file containing OpenAI API key (plain text).";
259+
};
260+
254261
discordTokenFile = mkOption {
255262
type = types.nullOr types.str;
256263
default = null;

0 commit comments

Comments
 (0)