Skip to content

Commit 6f8f9cf

Browse files
authored
feat: add model parameter support for CLI (#29)
1 parent 855f308 commit 6f8f9cf

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,21 @@ Or specify a working directory:
9898
grok -d /path/to/project
9999
```
100100

101+
### Model Selection
102+
103+
You can specify which AI model to use with the `--model` parameter:
104+
105+
```bash
106+
# Use Grok models
107+
grok --model grok-4-latest
108+
grok --model grok-3-latest
109+
grok --model grok-3-fast
110+
111+
# Use other models (with appropriate API endpoint)
112+
grok --model gemini-2.5-pro --base-url https://api-endpoint.com/v1
113+
grok --model claude-sonnet-4-20250514 --base-url https://api-endpoint.com/v1
114+
```
115+
101116
### Custom Instructions
102117

103118
You can provide custom instructions to tailor Grok's behavior to your project by creating a `.grok/GROK.md` file in your project directory:

src/agent/grok-agent.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ export class GrokAgent extends EventEmitter {
3636
private tokenCounter: TokenCounter;
3737
private abortController: AbortController | null = null;
3838

39-
constructor(apiKey: string, baseURL?: string) {
39+
constructor(apiKey: string, baseURL?: string, model?: string) {
4040
super();
41-
this.grokClient = new GrokClient(apiKey, undefined, baseURL);
41+
this.grokClient = new GrokClient(apiKey, model, baseURL);
4242
this.textEditor = new TextEditorTool();
4343
this.bash = new BashTool();
4444
this.todoTool = new TodoTool();

src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ program
6868
.option("-d, --directory <dir>", "set working directory", process.cwd())
6969
.option("-k, --api-key <key>", "Grok API key (or set GROK_API_KEY env var)")
7070
.option("-u, --base-url <url>", "Grok API base URL (or set GROK_BASE_URL env var)")
71+
.option("-m, --model <model>", "AI model to use (e.g., gemini-2.5-pro, grok-4-latest)")
7172
.action((options) => {
7273
if (options.directory) {
7374
try {
@@ -85,7 +86,8 @@ program
8586
// Get API key from options, environment, or user settings
8687
const apiKey = options.apiKey || loadApiKey();
8788
const baseURL = options.baseUrl || loadBaseURL();
88-
const agent = apiKey ? new GrokAgent(apiKey, baseURL) : undefined;
89+
const model = options.model;
90+
const agent = apiKey ? new GrokAgent(apiKey, baseURL, model) : undefined;
8991

9092
console.log("🤖 Starting Grok CLI Conversational Assistant...\n");
9193

0 commit comments

Comments
 (0)