openclaw-aicodewith-auth 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -0
- package/clawdbot.plugin.json +13 -0
- package/index.ts +83 -0
- package/package.json +36 -0
- package/src/auth.ts +102 -0
- package/src/constants.ts +16 -0
- package/src/models.ts +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# openclaw-aicodewith-auth
|
|
2
|
+
|
|
3
|
+
AICodewith provider plugin for [OpenClaw](https://github.com/openclaw/openclaw).
|
|
4
|
+
|
|
5
|
+
Access GPT, Claude, and Gemini models through AICodewith API.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
openclaw plugins install openclaw-aicodewith-auth
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or install via npm:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install openclaw-aicodewith-auth
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Then enable the plugin:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
openclaw plugins enable openclaw-aicodewith-auth
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Authentication
|
|
26
|
+
|
|
27
|
+
After installing the plugin, authenticate with your AICodewith API key:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
openclaw models auth login --provider aicodewith-claude --set-default
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
You will be prompted to enter your AICodewith API key.
|
|
34
|
+
|
|
35
|
+
## Supported Models
|
|
36
|
+
|
|
37
|
+
| Provider | Model ID | Description |
|
|
38
|
+
|----------|----------|-------------|
|
|
39
|
+
| GPT | `aicodewith-gpt/gpt-5.2-codex` | GPT-5.2 Codex (400K context) |
|
|
40
|
+
| GPT | `aicodewith-gpt/gpt-5.2` | GPT-5.2 (400K context) |
|
|
41
|
+
| Claude | `aicodewith-claude/claude-sonnet-4-5-20250929` | Claude Sonnet 4.5 (200K context) |
|
|
42
|
+
| Claude | `aicodewith-claude/claude-opus-4-5-20251101` | Claude Opus 4.5 (200K context) |
|
|
43
|
+
| Gemini | `aicodewith-gemini/gemini-3-pro` | Gemini 3 Pro (1M context) |
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Use Claude Opus 4.5 (default after auth)
|
|
49
|
+
openclaw agent --message "Hello"
|
|
50
|
+
|
|
51
|
+
# Use a specific model
|
|
52
|
+
openclaw agent --model aicodewith-gpt/gpt-5.2-codex --message "Hello"
|
|
53
|
+
|
|
54
|
+
# List available models
|
|
55
|
+
openclaw models list | grep aicodewith
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Environment Variable
|
|
59
|
+
|
|
60
|
+
You can also set the API key via environment variable:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
export AICODEWITH_API_KEY=your-api-key
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
MIT
|
package/index.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { emptyPluginConfigSchema } from "clawdbot/plugin-sdk";
|
|
2
|
+
import {
|
|
3
|
+
PLUGIN_ID,
|
|
4
|
+
PLUGIN_NAME,
|
|
5
|
+
PLUGIN_DESCRIPTION,
|
|
6
|
+
PROVIDER_ID_GPT,
|
|
7
|
+
PROVIDER_ID_CLAUDE,
|
|
8
|
+
PROVIDER_ID_GEMINI,
|
|
9
|
+
AICODEWITH_GPT_BASE_URL,
|
|
10
|
+
AICODEWITH_CLAUDE_BASE_URL,
|
|
11
|
+
AICODEWITH_GEMINI_BASE_URL,
|
|
12
|
+
AICODEWITH_API_KEY_ENV,
|
|
13
|
+
} from "./src/constants.js";
|
|
14
|
+
import { GPT_MODELS, CLAUDE_MODELS, GEMINI_MODELS } from "./src/models.js";
|
|
15
|
+
import { createAicodewithAuthMethod } from "./src/auth.js";
|
|
16
|
+
|
|
17
|
+
const aicodewithPlugin = {
|
|
18
|
+
id: PLUGIN_ID,
|
|
19
|
+
name: PLUGIN_NAME,
|
|
20
|
+
description: PLUGIN_DESCRIPTION,
|
|
21
|
+
configSchema: emptyPluginConfigSchema(),
|
|
22
|
+
register(api: {
|
|
23
|
+
registerProvider: (provider: {
|
|
24
|
+
id: string;
|
|
25
|
+
label: string;
|
|
26
|
+
envVars?: string[];
|
|
27
|
+
models?: {
|
|
28
|
+
baseUrl: string;
|
|
29
|
+
api: string;
|
|
30
|
+
models: Array<{
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
reasoning: boolean;
|
|
34
|
+
input: readonly string[];
|
|
35
|
+
cost: { input: number; output: number; cacheRead: number; cacheWrite: number };
|
|
36
|
+
contextWindow: number;
|
|
37
|
+
maxTokens: number;
|
|
38
|
+
}>;
|
|
39
|
+
};
|
|
40
|
+
auth: Array<ReturnType<typeof createAicodewithAuthMethod>>;
|
|
41
|
+
}) => void;
|
|
42
|
+
}) {
|
|
43
|
+
const authMethod = createAicodewithAuthMethod();
|
|
44
|
+
|
|
45
|
+
api.registerProvider({
|
|
46
|
+
id: PROVIDER_ID_GPT,
|
|
47
|
+
label: "AICodewith GPT",
|
|
48
|
+
envVars: [AICODEWITH_API_KEY_ENV],
|
|
49
|
+
models: {
|
|
50
|
+
baseUrl: AICODEWITH_GPT_BASE_URL,
|
|
51
|
+
api: "openai-completions",
|
|
52
|
+
models: GPT_MODELS,
|
|
53
|
+
},
|
|
54
|
+
auth: [authMethod],
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
api.registerProvider({
|
|
58
|
+
id: PROVIDER_ID_CLAUDE,
|
|
59
|
+
label: "AICodewith Claude",
|
|
60
|
+
envVars: [AICODEWITH_API_KEY_ENV],
|
|
61
|
+
models: {
|
|
62
|
+
baseUrl: AICODEWITH_CLAUDE_BASE_URL,
|
|
63
|
+
api: "anthropic-messages",
|
|
64
|
+
models: CLAUDE_MODELS,
|
|
65
|
+
},
|
|
66
|
+
auth: [authMethod],
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
api.registerProvider({
|
|
70
|
+
id: PROVIDER_ID_GEMINI,
|
|
71
|
+
label: "AICodewith Gemini",
|
|
72
|
+
envVars: [AICODEWITH_API_KEY_ENV],
|
|
73
|
+
models: {
|
|
74
|
+
baseUrl: AICODEWITH_GEMINI_BASE_URL,
|
|
75
|
+
api: "google-generative-ai",
|
|
76
|
+
models: GEMINI_MODELS,
|
|
77
|
+
},
|
|
78
|
+
auth: [authMethod],
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export default aicodewithPlugin;
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "openclaw-aicodewith-auth",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "AICodewith provider plugin for OpenClaw - Access GPT, Claude, and Gemini models via AICodewith API",
|
|
6
|
+
"author": "daneel",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"openclaw",
|
|
10
|
+
"openclaw-plugin",
|
|
11
|
+
"aicodewith",
|
|
12
|
+
"openai",
|
|
13
|
+
"anthropic",
|
|
14
|
+
"claude",
|
|
15
|
+
"gemini",
|
|
16
|
+
"gpt"
|
|
17
|
+
],
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/DaneelOlivaw1/openclaw-aicodewith-auth"
|
|
21
|
+
},
|
|
22
|
+
"openclaw": {
|
|
23
|
+
"extensions": [
|
|
24
|
+
"./index.ts"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"index.ts",
|
|
29
|
+
"src",
|
|
30
|
+
"clawdbot.plugin.json",
|
|
31
|
+
"README.md"
|
|
32
|
+
],
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"openclaw": ">=2026.1.0"
|
|
35
|
+
}
|
|
36
|
+
}
|
package/src/auth.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AICODEWITH_GPT_BASE_URL,
|
|
3
|
+
AICODEWITH_CLAUDE_BASE_URL,
|
|
4
|
+
AICODEWITH_GEMINI_BASE_URL,
|
|
5
|
+
PROVIDER_ID_GPT,
|
|
6
|
+
PROVIDER_ID_CLAUDE,
|
|
7
|
+
PROVIDER_ID_GEMINI,
|
|
8
|
+
AUTH_PROFILE_ID,
|
|
9
|
+
} from "./constants.js";
|
|
10
|
+
import { GPT_MODELS, CLAUDE_MODELS, GEMINI_MODELS } from "./models.js";
|
|
11
|
+
|
|
12
|
+
function validateApiKey(value: string): string | undefined {
|
|
13
|
+
const trimmed = value.trim();
|
|
14
|
+
if (!trimmed) return "API key is required";
|
|
15
|
+
if (trimmed.length < 10) return "API key seems too short";
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function createAicodewithAuthMethod() {
|
|
20
|
+
return {
|
|
21
|
+
id: "api_key",
|
|
22
|
+
label: "AICodewith API Key",
|
|
23
|
+
hint: "Enter your AICodewith API key to access GPT, Claude, and Gemini models",
|
|
24
|
+
kind: "api_key" as const,
|
|
25
|
+
run: async (ctx: {
|
|
26
|
+
prompter: {
|
|
27
|
+
text: (opts: {
|
|
28
|
+
message: string;
|
|
29
|
+
placeholder?: string;
|
|
30
|
+
validate?: (value: string) => string | undefined;
|
|
31
|
+
}) => Promise<string>;
|
|
32
|
+
};
|
|
33
|
+
}) => {
|
|
34
|
+
const apiKey = await ctx.prompter.text({
|
|
35
|
+
message: "AICodewith API Key",
|
|
36
|
+
placeholder: "sk-...",
|
|
37
|
+
validate: validateApiKey,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const trimmedKey = apiKey.trim();
|
|
41
|
+
const defaultModelRef = `${PROVIDER_ID_CLAUDE}/claude-opus-4-5-20251101`;
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
profiles: [
|
|
45
|
+
{
|
|
46
|
+
profileId: AUTH_PROFILE_ID,
|
|
47
|
+
credential: {
|
|
48
|
+
type: "api_key" as const,
|
|
49
|
+
provider: "aicodewith",
|
|
50
|
+
key: trimmedKey,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
configPatch: {
|
|
55
|
+
models: {
|
|
56
|
+
providers: {
|
|
57
|
+
[PROVIDER_ID_GPT]: {
|
|
58
|
+
baseUrl: AICODEWITH_GPT_BASE_URL,
|
|
59
|
+
apiKey: trimmedKey,
|
|
60
|
+
api: "openai-completions",
|
|
61
|
+
models: GPT_MODELS,
|
|
62
|
+
},
|
|
63
|
+
[PROVIDER_ID_CLAUDE]: {
|
|
64
|
+
baseUrl: AICODEWITH_CLAUDE_BASE_URL,
|
|
65
|
+
apiKey: trimmedKey,
|
|
66
|
+
api: "anthropic-messages",
|
|
67
|
+
models: CLAUDE_MODELS,
|
|
68
|
+
},
|
|
69
|
+
[PROVIDER_ID_GEMINI]: {
|
|
70
|
+
baseUrl: AICODEWITH_GEMINI_BASE_URL,
|
|
71
|
+
apiKey: trimmedKey,
|
|
72
|
+
api: "google-generative-ai",
|
|
73
|
+
models: GEMINI_MODELS,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
agents: {
|
|
78
|
+
defaults: {
|
|
79
|
+
model: defaultModelRef,
|
|
80
|
+
models: {
|
|
81
|
+
...Object.fromEntries(
|
|
82
|
+
GPT_MODELS.map((m) => [`${PROVIDER_ID_GPT}/${m.id}`, {}])
|
|
83
|
+
),
|
|
84
|
+
...Object.fromEntries(
|
|
85
|
+
CLAUDE_MODELS.map((m) => [`${PROVIDER_ID_CLAUDE}/${m.id}`, {}])
|
|
86
|
+
),
|
|
87
|
+
...Object.fromEntries(
|
|
88
|
+
GEMINI_MODELS.map((m) => [`${PROVIDER_ID_GEMINI}/${m.id}`, {}])
|
|
89
|
+
),
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
defaultModel: defaultModelRef,
|
|
95
|
+
notes: [
|
|
96
|
+
"AICodewith provides access to GPT, Claude, and Gemini models.",
|
|
97
|
+
"Models are available under aicodewith-gpt/, aicodewith-claude/, and aicodewith-gemini/ prefixes.",
|
|
98
|
+
],
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const AICODEWITH_GPT_BASE_URL = "https://api.aicodewith.com/chatgpt/v1";
|
|
2
|
+
export const AICODEWITH_CLAUDE_BASE_URL = "https://api.aicodewith.com/v1";
|
|
3
|
+
export const AICODEWITH_GEMINI_BASE_URL = "https://api.aicodewith.com/gemini_cli";
|
|
4
|
+
|
|
5
|
+
export const PROVIDER_ID_GPT = "aicodewith-gpt";
|
|
6
|
+
export const PROVIDER_ID_CLAUDE = "aicodewith-claude";
|
|
7
|
+
export const PROVIDER_ID_GEMINI = "aicodewith-gemini";
|
|
8
|
+
|
|
9
|
+
export const AICODEWITH_API_KEY_ENV = "AICODEWITH_API_KEY";
|
|
10
|
+
|
|
11
|
+
export const AUTH_PROFILE_ID = "aicodewith:default";
|
|
12
|
+
|
|
13
|
+
export const PLUGIN_ID = "openclaw-aicodewith-auth";
|
|
14
|
+
export const PLUGIN_NAME = "AICodewith";
|
|
15
|
+
export const PLUGIN_DESCRIPTION =
|
|
16
|
+
"Access GPT, Claude, and Gemini models via AICodewith API";
|
package/src/models.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const DEFAULT_COST = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
|
2
|
+
|
|
3
|
+
export const GPT_MODELS = [
|
|
4
|
+
{
|
|
5
|
+
id: "gpt-5.2-codex",
|
|
6
|
+
name: "GPT-5.2 Codex",
|
|
7
|
+
reasoning: false,
|
|
8
|
+
input: ["text", "image"] as const,
|
|
9
|
+
cost: DEFAULT_COST,
|
|
10
|
+
contextWindow: 400000,
|
|
11
|
+
maxTokens: 128000,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
id: "gpt-5.2",
|
|
15
|
+
name: "GPT-5.2",
|
|
16
|
+
reasoning: false,
|
|
17
|
+
input: ["text", "image"] as const,
|
|
18
|
+
cost: DEFAULT_COST,
|
|
19
|
+
contextWindow: 400000,
|
|
20
|
+
maxTokens: 128000,
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
export const CLAUDE_MODELS = [
|
|
25
|
+
{
|
|
26
|
+
id: "claude-sonnet-4-5-20250929",
|
|
27
|
+
name: "Claude Sonnet 4.5",
|
|
28
|
+
reasoning: false,
|
|
29
|
+
input: ["text", "image"] as const,
|
|
30
|
+
cost: DEFAULT_COST,
|
|
31
|
+
contextWindow: 180000,
|
|
32
|
+
maxTokens: 64000,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: "claude-opus-4-5-20251101",
|
|
36
|
+
name: "Claude Opus 4.5",
|
|
37
|
+
reasoning: false,
|
|
38
|
+
input: ["text", "image"] as const,
|
|
39
|
+
cost: DEFAULT_COST,
|
|
40
|
+
contextWindow: 180000,
|
|
41
|
+
maxTokens: 64000,
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
export const GEMINI_MODELS = [
|
|
46
|
+
{
|
|
47
|
+
id: "gemini-3-pro",
|
|
48
|
+
name: "Gemini 3 Pro",
|
|
49
|
+
reasoning: false,
|
|
50
|
+
input: ["text", "image"] as const,
|
|
51
|
+
cost: DEFAULT_COST,
|
|
52
|
+
contextWindow: 1048576,
|
|
53
|
+
maxTokens: 65536,
|
|
54
|
+
},
|
|
55
|
+
];
|