tonhowtf/omniget · error
Grok
Error message
Grok: {} What it means
While parsing the NDJSON stream from add_response.json, if a result chunk contains an "error" field and no assistant text has accumulated yet, ask_x aborts with `Grok: <error>`. This is Grok itself (via the X session) reporting a failure — e.g. the model rejected the request — before producing any output.
Solutions
- Read the embedded Grok error text after the `Grok: ` prefix — it states the server-side reason.
- If it indicates an unknown/invalid model, change x_model in grok.json (or pass req.model) to a currently valid option id.
- Rephrase the prompt if it was refused by content filtering.
- Retry later if it is a transient X/Grok service error.
- Fall back to the xai backend with an xai_key for a stable API.
Example fix
// before "grokModelOptionId": "grok-2-old-id" // -> chunk error: model not found // after "grokModelOptionId": "grok-3" // current valid option id
Defensive patterns
Strategy: try-catch
Validate before calling
// validate model id before sending
if !model_option_ids_known_good().contains(&cfg.x_model) { return Err("x_model option id unknown"); } Type guard
fn chunk_error(v: &serde_json::Value) -> Option<&str> {
v.get("result").and_then(|r| r.get("error")).and_then(|e| e.as_str())
} Try / catch
match grok::ask(req).await {
Ok(a) => use_answer(a),
Err(e) if e.to_string().starts_with("Grok: ") => {
let reason = e.to_string().trim_start_matches("Grok: ");
switch_model_or_backend(req, reason)
}
Err(e) => log_error(e),
} Prevention
- Keep x_model set to a model id currently offered on x.com/i/grok
- Avoid prompts likely to trip Grok's content filters
- Treat the embedded Grok error string as authoritative for the cause
- Keep an xai_key configured as a stable fallback backend
When it happens
Trigger: A streamed result chunk carries r.error (as a string) while text is empty: invalid grokModelOptionId, Grok refusing the prompt (content policy), conversation state errors, or X-side Grok service errors delivered mid-stream.
Common situations: Configured x_model id no longer offered by X; prompt flagged by Grok's safety filters; X Grok backend outage; sending a system prompt or features the selected model does not support.
Related errors
- X: HTTP
- Grok: nao consegui abrir uma conversa
- Grok nao respondeu (modelo ` ` pode nao existir mais…
- /
- YouTube não retornou URL
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/f4db32f0c7b1cad3.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/x/grok.rs:374
for key in ["cited_web_results", "webResults", "citedWebResults"] {
for w in r.get(key).and_then(|a| a.as_array()).into_iter().flatten() {
if let Some(url) = w.get("url").and_then(|u| u.as_str()) {
if !citations.iter().any(|c| c.url == url) {
citations.push(Citation {
url: url.to_string(),
title: w
.get("title")
.and_then(|t| t.as_str())
.unwrap_or("")
.to_string(),
});
}
}
}
}
if let Some(err) = r.get("error").and_then(|e| e.as_str()) {
if text.is_empty() {
return Err(anyhow!("Grok: {}", err));
}
}
}
if text.trim().is_empty() {
return Err(anyhow!(
"Grok nao respondeu (modelo `{}` pode nao existir mais; troque nas opcoes)",
model
));
}
Ok(GrokAnswer {
text,
citations,
model,
backend: "x".into(),
input_tokens: 0,
output_tokens: 0,
})
}View on GitHub (pinned to 8600b91f42)