{"record":{"id":"7e9b5609f5c226be","repo":"nikivdev/code","slug":"ai-server-model-not-set-and-v1-models-failed-with","errorCode":null,"errorMessage":"AI_SERVER_MODEL not set and /v1/models failed with status {}. Set it with: f env set --personal AI_SERVER_MODEL=<model>","messagePattern":"AI_SERVER_MODEL not set and /v1/models failed with status (.+?)\\. Set it with: f env set --personal AI_SERVER_MODEL=<model>","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ai_server.rs","lineNumber":233,"sourceCode":"}\n\nfn fetch_default_model(base_url: &str, token: Option<&str>) -> Result<String> {\n    let client = Client::builder()\n        .timeout(Duration::from_secs(5))\n        .build()\n        .context(\"failed to create HTTP client\")?;\n    let url = format!(\"{}/v1/models\", base_url);\n    let mut req = client.get(&url);\n    if let Some(token) = token {\n        req = req.bearer_auth(token);\n    }\n\n    let resp = req\n        .send()\n        .with_context(|| format!(\"failed to query models at {}\", base_url))?;\n\n    if !resp.status().is_success() {\n        bail!(\n            \"AI_SERVER_MODEL not set and /v1/models failed with status {}. Set it with: f env set --personal AI_SERVER_MODEL=<model>\",\n            resp.status()\n        );\n    }\n\n    let text_body = resp.text().context(\"failed to read models response\")?;\n    let parsed: ModelsResponse =\n        serde_json::from_str(&text_body).context(\"failed to parse models response\")?;\n\n    let model = parsed\n        .data\n        .into_iter()\n        .find(|m| !m.id.trim().is_empty())\n        .map(|m| m.id)\n        .unwrap_or_default();\n\n    if model.trim().is_empty() {\n        bail!(","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/ai_server.rs#L215-L251","documentation":"Error \"AI_SERVER_MODEL not set and /v1/models failed with status {}. Set it with: f env set --personal AI_SERVER_MODEL=<model>\" thrown in nikivdev/code.","triggerScenarios":"Thrown at src/ai_server.rs:233 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}