@defai.digital/automatosx 8.2.0 → 8.3.2

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.
@@ -0,0 +1,511 @@
1
+ # Grok CLI Integration with AutomatosX
2
+
3
+ This guide explains how to integrate Grok CLI with AutomatosX for AI-powered development.
4
+
5
+ ## Overview
6
+
7
+ AutomatosX supports **three** Grok provider options:
8
+ - **X.AI Official Grok** (grok-3-fast) - Fast, efficient, general-purpose
9
+ - **Z.AI GLM 4.6** (glm-4.6) - Code-optimized for technical tasks
10
+ - **Self-Hosted GLM 4.6** - Your own local API server for complete control
11
+
12
+ ## Quick Setup
13
+
14
+ ### 1. Get Your API Key
15
+
16
+ **Option A: X.AI (Recommended)**
17
+ - Visit: https://console.x.ai/api-keys
18
+ - Create an API key (starts with `xai-`)
19
+ - Copy your key
20
+
21
+ **Option B: Z.AI (Code-Optimized)**
22
+ - Visit: https://z.ai/developer
23
+ - Get your Z.AI API key
24
+ - Copy your key
25
+
26
+ **Option C: Self-Hosted GLM 4.6 (Complete Control)**
27
+ - Set up your own GLM 4.6 API server (see [Self-Hosted Setup](#self-hosted-glm-46-configuration) below)
28
+ - Point AutomatosX to your local/private server
29
+ - Full data privacy and control
30
+
31
+ ### 2. Configure Grok CLI
32
+
33
+ The `.grok/settings.json` file was created by `ax setup`. Edit it:
34
+
35
+ ```json
36
+ {
37
+ "baseURL": "https://api.x.ai/v1",
38
+ "model": "grok-3-fast",
39
+ "apiKey": "xai-YOUR-KEY-HERE"
40
+ }
41
+ ```
42
+
43
+ **For Z.AI GLM 4.6** (alternative):
44
+ ```json
45
+ {
46
+ "baseURL": "https://api.z.ai/api/coding/paas/v4",
47
+ "model": "glm-4.6",
48
+ "apiKey": "YOUR-ZAI-KEY-HERE"
49
+ }
50
+ ```
51
+
52
+ ### 3. Enable in AutomatosX
53
+
54
+ Edit `automatosx.config.json`:
55
+
56
+ ```json
57
+ {
58
+ "providers": {
59
+ "grok": {
60
+ "enabled": true, // Change from false
61
+ "priority": 4,
62
+ ...
63
+ }
64
+ }
65
+ }
66
+ ```
67
+
68
+ ### 4. Verify Setup
69
+
70
+ ```bash
71
+ # Check Grok is recognized
72
+ ax providers list
73
+
74
+ # Test Grok provider
75
+ ax doctor grok
76
+
77
+ # Run a task with Grok
78
+ ax run backend "Create a hello world function" --provider grok
79
+ ```
80
+
81
+ ## Configuration Details
82
+
83
+ ### X.AI Grok Models
84
+
85
+ | Model | Description | Best For |
86
+ |-------|-------------|----------|
87
+ | `grok-3-fast` | Fast, efficient | General tasks, quick responses |
88
+ | `grok-beta` | Latest features | Complex reasoning, analysis |
89
+ | `grok-vision-beta` | Image understanding | Visual analysis |
90
+
91
+ ### Z.AI GLM Models
92
+
93
+ | Model | Description | Best For |
94
+ |-------|-------------|----------|
95
+ | `glm-4.6` | Code-optimized | Coding tasks, technical work |
96
+
97
+ ### Environment Variables
98
+
99
+ Alternatively, set API key via environment variable:
100
+
101
+ ```bash
102
+ # For X.AI
103
+ export GROK_API_KEY="xai-your-key-here"
104
+
105
+ # For Z.AI
106
+ export GROK_API_KEY="your-zai-key-here"
107
+ ```
108
+
109
+ Then in `.grok/settings.json`:
110
+ ```json
111
+ {
112
+ "apiKey": "${GROK_API_KEY}"
113
+ }
114
+ ```
115
+
116
+ ## Usage Examples
117
+
118
+ ### Basic Task Execution
119
+
120
+ ```bash
121
+ # Use Grok for backend development
122
+ ax run backend "Implement user authentication" --provider grok
123
+
124
+ # Use Grok for code review
125
+ ax run quality "Review this code for bugs" --provider grok
126
+
127
+ # Use Grok for documentation
128
+ ax run writer "Document the API endpoints" --provider grok
129
+ ```
130
+
131
+ ### Automatic Provider Selection
132
+
133
+ If Grok is enabled, AutomatosX will route tasks to it based on priority and availability:
134
+
135
+ ```bash
136
+ # AutomatosX chooses best provider (might use Grok)
137
+ ax run backend "Create REST API"
138
+ ```
139
+
140
+ ### Priority Override
141
+
142
+ Change Grok priority in `automatosx.config.json`:
143
+
144
+ ```json
145
+ {
146
+ "providers": {
147
+ "grok": {
148
+ "priority": 1 // Make Grok highest priority (1=highest, 4=lowest)
149
+ }
150
+ }
151
+ }
152
+ ```
153
+
154
+ ## Self-Hosted GLM 4.6 Configuration
155
+
156
+ **Use your own local coding system with AutomatosX for complete control!**
157
+
158
+ ### Benefits of Self-Hosted
159
+
160
+ - 🏠 **Complete Data Privacy** - All processing stays on your infrastructure
161
+ - 💰 **No Usage Costs** - Run unlimited tasks without API fees
162
+ - ⚡ **Lower Latency** - No network round trips to external servers
163
+ - 🔧 **Full Customization** - Fine-tune the model for your specific needs
164
+ - 🔒 **Enterprise Security** - Meet strict corporate data requirements
165
+ - 🌐 **Offline Operation** - Works without internet connectivity
166
+ - 📊 **Resource Control** - Optimize for your hardware
167
+
168
+ ### Quick Setup: Docker
169
+
170
+ The easiest way to run a self-hosted GLM 4.6 API server:
171
+
172
+ ```bash
173
+ # 1. Pull and run vLLM server with GLM 4.6
174
+ docker run -d \
175
+ --name glm-4-6-server \
176
+ --gpus all \
177
+ -p 8000:8000 \
178
+ -v ~/.cache/huggingface:/root/.cache/huggingface \
179
+ vllm/vllm-openai:latest \
180
+ --model THUDM/glm-4-6 \
181
+ --port 8000 \
182
+ --trust-remote-code
183
+
184
+ # 2. Wait for model to load (check logs)
185
+ docker logs -f glm-4-6-server
186
+
187
+ # 3. Test the server
188
+ curl http://localhost:8000/v1/models
189
+
190
+ # 4. Configure AutomatosX
191
+ # Edit .grok/settings.json:
192
+ {
193
+ "baseURL": "http://localhost:8000/v1",
194
+ "model": "THUDM/glm-4-6",
195
+ "apiKey": "optional-if-your-server-requires-it"
196
+ }
197
+
198
+ # 5. Enable and test
199
+ # Edit automatosx.config.json: "grok": { "enabled": true }
200
+ ax doctor grok
201
+ ax providers list
202
+ ```
203
+
204
+ ### Alternative Deployment Options
205
+
206
+ #### Option 1: vLLM (Recommended - Fastest)
207
+
208
+ ```bash
209
+ # Install vLLM
210
+ pip install vllm
211
+
212
+ # Start server
213
+ python -m vllm.entrypoints.openai.api_server \
214
+ --model THUDM/glm-4-6 \
215
+ --port 8000 \
216
+ --trust-remote-code
217
+ ```
218
+
219
+ **Pros**: Fastest inference, best GPU utilization
220
+ **Cons**: Requires CUDA GPU
221
+
222
+ #### Option 2: Text Generation Inference (HuggingFace)
223
+
224
+ ```bash
225
+ # Using Docker
226
+ docker run -d \
227
+ --gpus all \
228
+ -p 8000:80 \
229
+ -v $PWD/data:/data \
230
+ ghcr.io/huggingface/text-generation-inference:latest \
231
+ --model-id THUDM/glm-4-6 \
232
+ --port 80
233
+ ```
234
+
235
+ **Pros**: Production-ready, great scaling
236
+ **Cons**: More complex setup
237
+
238
+ #### Option 3: Ollama (Easiest - Good for Development)
239
+
240
+ ```bash
241
+ # Install Ollama
242
+ curl -fsSL https://ollama.ai/install.sh | sh
243
+
244
+ # Pull GLM model (if available)
245
+ ollama pull glm-4
246
+
247
+ # Run server
248
+ ollama serve
249
+
250
+ # Configure AutomatosX
251
+ # Edit .grok/settings.json:
252
+ {
253
+ "baseURL": "http://localhost:11434/v1",
254
+ "model": "glm-4",
255
+ "apiKey": "not-required"
256
+ }
257
+ ```
258
+
259
+ **Pros**: Simplest setup, works on CPU
260
+ **Cons**: Slower inference, may not have latest GLM 4.6
261
+
262
+ #### Option 4: Custom FastAPI Wrapper
263
+
264
+ ```python
265
+ # server.py
266
+ from fastapi import FastAPI
267
+ from transformers import AutoModelForCausalLM, AutoTokenizer
268
+ import uvicorn
269
+
270
+ app = FastAPI()
271
+ model = AutoModelForCausalLM.from_pretrained("THUDM/glm-4-6", trust_remote_code=True)
272
+ tokenizer = AutoTokenizer.from_pretrained("THUDM/glm-4-6", trust_remote_code=True)
273
+
274
+ @app.post("/v1/chat/completions")
275
+ async def chat_completions(request: dict):
276
+ messages = request["messages"]
277
+ # ... implement OpenAI-compatible API
278
+ return {"choices": [...]}
279
+
280
+ if __name__ == "__main__":
281
+ uvicorn.run(app, host="0.0.0.0", port=8000)
282
+ ```
283
+
284
+ **Pros**: Full control, custom features
285
+ **Cons**: Requires Python coding
286
+
287
+ ### Hardware Requirements
288
+
289
+ | Deployment | GPU | RAM | Disk | Performance |
290
+ |------------|-----|-----|------|-------------|
291
+ | **vLLM** | NVIDIA A100 (40GB) | 64GB | 100GB | Excellent |
292
+ | **vLLM** | NVIDIA RTX 4090 (24GB) | 32GB | 50GB | Very Good |
293
+ | **TGI** | NVIDIA V100 (16GB) | 32GB | 50GB | Good |
294
+ | **Ollama (CPU)** | None | 16GB | 20GB | Fair |
295
+ | **Ollama (GPU)** | NVIDIA RTX 3090 (24GB) | 16GB | 20GB | Good |
296
+
297
+ ### Network Configuration
298
+
299
+ If hosting on a separate server:
300
+
301
+ ```bash
302
+ # .grok/settings.json
303
+ {
304
+ "baseURL": "http://your-server-ip:8000/v1", // Internal network
305
+ "model": "THUDM/glm-4-6",
306
+ "apiKey": "your-optional-auth-token"
307
+ }
308
+
309
+ # Or with domain name
310
+ {
311
+ "baseURL": "https://glm.yourcompany.com/v1", // HTTPS for security
312
+ "model": "THUDM/glm-4-6",
313
+ "apiKey": "production-api-key"
314
+ }
315
+ ```
316
+
317
+ ### Testing Your Self-Hosted Server
318
+
319
+ ```bash
320
+ # 1. Test model endpoint
321
+ curl http://localhost:8000/v1/models
322
+
323
+ # 2. Test completion
324
+ curl http://localhost:8000/v1/chat/completions \
325
+ -H "Content-Type: application/json" \
326
+ -d '{
327
+ "model": "THUDM/glm-4-6",
328
+ "messages": [{"role": "user", "content": "Hello!"}]
329
+ }'
330
+
331
+ # 3. Test with AutomatosX
332
+ ax doctor grok
333
+ ax run backend "Write a hello function" --provider grok
334
+ ```
335
+
336
+ ### Production Considerations
337
+
338
+ **Security:**
339
+ - Add authentication (API keys, OAuth)
340
+ - Use HTTPS with valid certificates
341
+ - Implement rate limiting
342
+ - Set up firewall rules
343
+
344
+ **Monitoring:**
345
+ - Track GPU utilization
346
+ - Monitor response times
347
+ - Log all requests
348
+ - Set up alerts for failures
349
+
350
+ **Scaling:**
351
+ - Use load balancer for multiple instances
352
+ - Implement request queuing
353
+ - Add caching layer
354
+ - Consider K8s for auto-scaling
355
+
356
+ ### 📄 License Note for Self-Hosted/Commercial Use
357
+
358
+ **IMPORTANT**: AutomatosX is licensed under Apache 2.0 for **non-commercial use**.
359
+
360
+ For commercial deployments or to remove license restrictions:
361
+
362
+ - 💼 **Commercial License**: https://license.defai.digital/automatosx
363
+ - 📋 **Enterprise Terms**: Custom agreements for large organizations
364
+ - 🤝 **Volume Pricing**: Discounts for teams and multi-user deployments
365
+ - 📞 **Support**: Priority support included with commercial licenses
366
+
367
+ **What counts as commercial use?**
368
+ - Using AutomatosX in a business/company setting
369
+ - Generating revenue from AutomatosX-powered applications
370
+ - Self-hosted deployments in production environments
371
+ - Team/organization-wide deployments
372
+
373
+ **Educational/Research Use**: Free under Apache 2.0 license
374
+
375
+ ## Switching Between X.AI and Z.AI
376
+
377
+ ### To Switch to Z.AI GLM 4.6:
378
+
379
+ 1. Edit `.grok/settings.json`:
380
+ ```json
381
+ {
382
+ "baseURL": "https://api.z.ai/api/coding/paas/v4",
383
+ "model": "glm-4.6",
384
+ "apiKey": "your-zai-key"
385
+ }
386
+ ```
387
+
388
+ 2. Restart AutomatosX (or run `ax doctor grok`)
389
+
390
+ ### To Switch Back to X.AI:
391
+
392
+ 1. Edit `.grok/settings.json`:
393
+ ```json
394
+ {
395
+ "baseURL": "https://api.x.ai/v1",
396
+ "model": "grok-3-fast",
397
+ "apiKey": "xai-your-key"
398
+ }
399
+ ```
400
+
401
+ 2. Restart AutomatosX
402
+
403
+ ## Troubleshooting
404
+
405
+ ### Grok Not Showing in Provider List
406
+
407
+ ```bash
408
+ # Check if Grok is enabled
409
+ cat automatosx.config.json | grep -A 5 "grok"
410
+
411
+ # Enable Grok
412
+ # Edit automatosx.config.json and set "enabled": true
413
+ ```
414
+
415
+ ### API Key Errors
416
+
417
+ ```bash
418
+ # Verify API key is set
419
+ cat .grok/settings.json
420
+
421
+ # Or check environment variable
422
+ echo $GROK_API_KEY
423
+
424
+ # Test with curl (X.AI)
425
+ curl https://api.x.ai/v1/chat/completions \
426
+ -H "Authorization: Bearer xai-your-key" \
427
+ -H "Content-Type: application/json" \
428
+ -d '{"model":"grok-3-fast","messages":[{"role":"user","content":"Hello"}]}'
429
+ ```
430
+
431
+ ### Provider Health Check Failed
432
+
433
+ ```bash
434
+ # Run diagnostics
435
+ ax doctor grok
436
+
437
+ # Check logs
438
+ cat .automatosx/logs/*.log | grep grok
439
+ ```
440
+
441
+ ## Cost Optimization
442
+
443
+ ### X.AI Pricing (as of Nov 2024)
444
+ - Input: $5 per 1M tokens
445
+ - Output: $15 per 1M tokens
446
+
447
+ ### Tips
448
+ - Use `grok-3-fast` for cost efficiency
449
+ - Set appropriate token limits
450
+ - Monitor usage with `ax free-tier status` (if applicable)
451
+
452
+ ## Advanced Configuration
453
+
454
+ ### Custom Timeout
455
+
456
+ Edit `automatosx.config.json`:
457
+ ```json
458
+ {
459
+ "providers": {
460
+ "grok": {
461
+ "timeout": 180000 // 3 minutes (in milliseconds)
462
+ }
463
+ }
464
+ }
465
+ ```
466
+
467
+ ### Circuit Breaker Settings
468
+
469
+ ```json
470
+ {
471
+ "providers": {
472
+ "grok": {
473
+ "circuitBreaker": {
474
+ "enabled": true,
475
+ "failureThreshold": 3, // Open circuit after 3 failures
476
+ "recoveryTimeout": 60000 // Wait 60s before retry
477
+ }
478
+ }
479
+ }
480
+ }
481
+ ```
482
+
483
+ ## Integration with AI Assistants
484
+
485
+ ### Claude Code Integration
486
+
487
+ ```
488
+ # Natural language
489
+ "Ask ax agent backend to implement auth using Grok"
490
+ ```
491
+
492
+ ### Gemini CLI Integration
493
+
494
+ ```
495
+ # Natural language
496
+ "Use ax agent backend with Grok to create API"
497
+ ```
498
+
499
+ ## Support
500
+
501
+ - X.AI Documentation: https://docs.x.ai
502
+ - Z.AI Documentation: https://z.ai/docs
503
+ - AutomatosX Issues: https://github.com/defai-digital/automatosx/issues
504
+
505
+ ## Next Steps
506
+
507
+ 1. ✅ Get API key from X.AI or Z.AI
508
+ 2. ✅ Configure `.grok/settings.json`
509
+ 3. ✅ Enable in `automatosx.config.json`
510
+ 4. ✅ Test with `ax doctor grok`
511
+ 5. 🚀 Start using Grok with your agents!
@@ -0,0 +1,43 @@
1
+ {
2
+ "_comment": "Grok CLI Configuration - Choose your provider and model",
3
+ "_instructions": [
4
+ "1. Set GROK_API_KEY environment variable with your API key",
5
+ "2. Choose between X.AI (grok-3-fast) or Z.AI (glm-4.6) below",
6
+ "3. Uncomment your preferred configuration",
7
+ "4. Enable in automatosx.config.json: 'grok': { 'enabled': true }"
8
+ ],
9
+
10
+ "_option_1_x_ai_official": "=== X.AI Official Grok (Recommended) ===",
11
+ "baseURL": "https://api.x.ai/v1",
12
+ "model": "grok-3-fast",
13
+ "apiKey": "YOUR_XAI_API_KEY_HERE",
14
+
15
+ "_option_2_z_ai_glm": "=== Z.AI GLM 4.6 (Code-Optimized Alternative) ===",
16
+ "_comment_alternative": "Uncomment lines below and comment out X.AI config above to use GLM 4.6",
17
+ "_baseURL_alt": "https://api.z.ai/api/coding/paas/v4",
18
+ "_model_alt": "glm-4.6",
19
+ "_apiKey_alt": "YOUR_ZAI_API_KEY_HERE",
20
+
21
+ "_setup_instructions": {
22
+ "x_ai_setup": [
23
+ "1. Get API key from: https://console.x.ai/api-keys",
24
+ "2. Replace YOUR_XAI_API_KEY_HERE above with your key (starts with 'xai-')",
25
+ "3. Or use environment variable: export GROK_API_KEY='xai-your-key'"
26
+ ],
27
+ "z_ai_setup": [
28
+ "1. Get API key from: https://z.ai/developer",
29
+ "2. Uncomment _baseURL_alt, _model_alt, _apiKey_alt (remove underscore prefix)",
30
+ "3. Comment out X.AI config",
31
+ "4. Replace YOUR_ZAI_API_KEY_HERE with your Z.AI key"
32
+ ],
33
+ "enable_in_automatosx": [
34
+ "Edit automatosx.config.json:",
35
+ "Find 'grok' section and change 'enabled': false to 'enabled': true"
36
+ ],
37
+ "verify": [
38
+ "Run: ax doctor grok",
39
+ "Run: ax providers list",
40
+ "Test: ax run backend 'Hello Grok!' --provider grok"
41
+ ]
42
+ }
43
+ }