Mintplex-Labs/anything-llm · error · Error
Gemini: ${this.model} does not support tool calling.
Error message
Gemini: ${this.model} does not support tool calling. What it means
GeminiProvider.stream() refuses to run when supportsToolCalling is false (gemini.js:247-248). The getter (gemini.js:68-71) returns true only when the model id starts with the literal string "gemini"; tool-call streaming on the v1beta/openai endpoint against any other model yields a 400/503, so the provider guards up front with a model-specific message.
Source
Thrown at server/utils/agents/aibitat/providers/gemini.js:248
// ignore
}
}
}
#formatFunctions(functions) {
return functions.map((func) => ({
type: "function",
function: {
name: this.prefixToolCall(func.name, "add"),
description: func.description,
parameters: func.parameters,
},
}));
}
async stream(messages, functions = [], eventHandler = null) {
if (!this.supportsToolCalling)
throw new Error(`Gemini: ${this.model} does not support tool calling.`);
this.providerLog("Gemini.stream - will process this chat completion.");
this.resetUsage();
try {
const msgUUID = v4();
/** @type {OpenAI.OpenAI.Chat.ChatCompletion} */
const response = await this.client.chat.completions.create({
model: this.model,
messages: this.#formatMessages(messages),
stream: true,
stream_options: { include_usage: true },
...(Array.isArray(functions) && functions?.length > 0
? {
tools: this.#formatFunctions(functions),
tool_choice: "auto",
// AIbitat runs one tool per turn; parallel calls cause a 400
// on the next request due to a tool call/result count mismatch.
parallel_tool_calls: false,View on GitHub (pinned to 526360e320)
Solutions
- Set the model to a current gemini-* id (e.g. gemini-2.0-flash or gemini-2.5-pro) so supportsToolCalling returns true.
- If you must use a non-gemini model, disable agent tools / native tool calling so stream() is not invoked with functions.
- Cross-check the id against Google's published Gemini model list.
- Verify the model id persisted in workspace settings matches a starts-with("gemini") name.
Example fix
// before
const p = new GeminiProvider({ model: "text-bison-001" });
await p.stream(msgs, funcs);
// after
const p = new GeminiProvider({ model: "gemini-2.0-flash" });
await p.stream(msgs, funcs); Defensive patterns
Strategy: validation
Validate before calling
// Validate the model supports tool calling before calling stream().
function geminiSupportsTools(model) {
return typeof model === "string" && model.startsWith("gemini");
}
if (functions?.length > 0 && !geminiSupportsTools(provider.model)) {
throw new Error(`Refusing to stream: model ${provider.model} cannot use tools.`);
} Type guard
// Narrow to a tool-capable Gemini model id.
/** @param {string} model
* @returns {boolean} */
function isToolCapableGeminiModel(model) {
return typeof model === "string" && model.startsWith("gemini");
} Try / catch
try {
await provider.stream(messages, functions, handler);
} catch (e) {
if (/does not support tool calling/.test(e.message)) {
// fall back to a non-tool flow or switch model instead of retrying
return await provider.stream(messages, [], handler);
}
throw e;
} Prevention
- Always set the model id explicitly from a vetted allow-list of gemini-* names.
- Gate tool flows behind a starts-with('gemini') check in your provider factory.
- Validate persisted model ids on settings save, not only at call time.
When it happens
Trigger: Constructing GeminiProvider with a non-gemini model id (e.g. a legacy "text-bison", an embedding model, a typo, or a copied value from another provider) and then calling stream() while agent tools are attached.
Common situations: Model name typo in the picker, an outdated model id left in the DB, or selecting a Gemini-family alias whose id does not begin with "gemini".
Related errors
- No Gemini API key was set.
- LMStudio must have a valid model set.
- OMLX must have a valid model set.
- SambaNova chat: No results!
- Gemini API key must be provided to use agents.
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/6cd55570be9cb1e7.
Report an issue: GitHub.