Skip to content

Commit 5bc305a

Browse files
author
jack
committed
Fix xAI API URL construction by ensuring base URL ends with slash
1 parent 4eec0f2 commit 5bc305a

2 files changed

Lines changed: 39 additions & 2 deletions

File tree

.goose/memory/project improvement ideas.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,35 @@ User had `GOOSE_LEAD_MODEL: claude-opus-4-20250514` in config which was triggeri
4545

4646
**Status:** Fixed and committed (commit 30dbcba3e4)
4747

48+
# ["xai", "grok", "complete", "implementation"]
49+
COMPLETE: Successfully added xAI provider support for Grok models
50+
51+
**Status:** Fully implemented and tested
52+
53+
**Final Implementation Details:**
54+
1. Created XaiProvider in `crates/goose/src/providers/xai.rs`
55+
2. Fixed API endpoint URL: `https://api.x.ai/v1` + `chat/completions`
56+
3. Added all Grok models with 131K token context limit
57+
4. Added xAI to GUI provider registry
58+
5. Fixed context display (was showing 0/32000, now shows 0/131072)
59+
60+
**Commits:**
61+
- ff54e6d576: Initial xAI provider implementation
62+
- 30dbcba3e4: Fixed API endpoint URL
63+
- 4eec0f2b87: Added Grok model context limits
64+
65+
**Known Issue:**
66+
User has lead/worker configuration in their ~/.config/goose/config.yaml that needs to be cleaned up. The following entries should be removed:
67+
- GOOSE_LEAD_MODEL
68+
- GOOSE_LEAD_PROVIDER
69+
- GOOSE_LEAD_TURNS
70+
- GOOSE_WORKER_* entries
71+
- GOOSE_MULTI_AGENT_* entries
72+
73+
**How to Use:**
74+
1. Set XAI_API_KEY environment variable or in config
75+
2. Use --provider xai --model grok-3 (or configure in config.yaml)
76+
3. Models available: grok-3, grok-3-mini, grok-3-fast, grok-2-vision-1212, etc.
77+
78+
**Branch:** feature/add-grok-models
79+

crates/goose/src/providers/xai.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,13 @@ impl XaiProvider {
7373
}
7474

7575
async fn post(&self, payload: Value) -> anyhow::Result<Value, ProviderError> {
76-
let base_url = Url::parse(&self.host)
77-
.map_err(|e| ProviderError::RequestFailed(format!("Invalid base URL: {e}")))?;
76+
// Ensure the host ends with a slash for proper URL joining
77+
let host = if self.host.ends_with('/') {
78+
self.host.clone()
79+
} else {
80+
format!("{}/", self.host)
81+
};
82+
let base_url = Url::parse(&host).map_err(|e| ProviderError::RequestFailed(format!("Invalid base URL: {e}")))?;
7883
let url = base_url.join("chat/completions").map_err(|e| {
7984
ProviderError::RequestFailed(format!("Failed to construct endpoint URL: {e}"))
8085
})?;

0 commit comments

Comments
 (0)