Gemini error
# support
s
i am getting when trying to use gemini model for assistant. Please help. { "id": "log-27", "level": 50, "time": 1768129020356, "timestamp": 1768129020356000000, "severityText": "ERROR", "severityNumber": 17, "body": "Model sequence failed - all attempts exhausted", "attributes": { "category": "model", "callId": "019bacb3-67d6-755e-ad5f-8e805a7273c6", "orgId": "da6f2fb0-f8d5-4625-b9a2-a1c03df6dfa2", "provider": "google", "model": "gemini-2.5-flash", "error": { "message": "[GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:streamGenerateContent?alt=sse: [400 Bad Request] * GenerateContentRequest.tools[0].function_declarations[0].parameters.properties[knowledgeBaseNames].items: mi...", "error": { "status": 400, "statusText": "Bad Request" } }, "metrics": { "totalCost": 0, "totalPromptTokens": 0, "totalCompletionTokens": 0, "totalPromptCacheHitTokens": 0 } } }
c
Hi there, Thank you for your message. Our team is currently out of the office. We operate Monday through Friday, from 9:00 AM to 8:00 PM Pacific Standard Time (PST). We’ll get back to you as soon as possible during our normal business hours. If your message is urgent, please mark it accordingly or include “URGENT” in the subject line, and we’ll do our best to respond promptly. Warm regards, Vapi Customer Support Team
Hi saketh_1201, Thanks — that error means the Gemini call failed validation with Google. The relevant part: [GoogleGenerativeAI Error] 400 Bad Request for gemini-2.5-flash, complaining about GenerateContentRequest.tools[].function_declarations[].parameters.properties[knowledgeBaseNames] (truncated in the log). Likely causes and next steps: • A tool in your assistant has a function declaration whose JSON Schema for property
knowledgeBaseNames
is invalid for the Gemini API (e.g., incorrect type, items schema, or missing required fields). • Inspect any tool you added that references knowledgeBaseNames (or a knowledge base tool). Validate its function_declarations JSON Schema against Google’s GenerateContentRequest expectations (arrays vs string, item schema, enums, etc.). • If you can, share the tool JSON (function_declarations) or paste the callId: 019bacb3-67d6-755e-ad5f-8e805a7273c6 and I’ll review the tool payload and point to the exact field to fix. Reference: Gemini model support and credential info in our changelog — see the Gemini docs here: https://docs.vapi.ai/providers/model/gemini
s
payload = { "type": "query", "messages": [ { "type": "request-start", "content": "Let me check your loan details. Please hold for just a moment.", }, { "type": "request-failed", "content": "I am sorry, I am not able to answer your question. Please ask me something else or ask me after some time." }, { "type": "request-response-delayed", "content": "This is taking a bit longer than expected. Please bear with me" } ], "knowledgeBases": [ { "name": "Loan terms and conditions", "provider": "google", "description": "This collection outlines the operational and legal guidelines for loan recovery.", "fileIds": fileIds, "model": "gemini-2.5-flash" } ] } This is my query tool payload
c
Hi, Thanks for sending your query tool payload. Your query tool payload looks well-structured overall, but there are a few important points to address: Payload Structure Analysis Your configuration follows the correct format for a query tool: Correct structure: type: "query" with knowledgeBases array **Proper messages**: All three message types configured **Knowledge base setup**: Google provider with file IDs **Good description**: Clear description of loan recovery content
Missing Required Field You're missing the function field, which is required for query tools :
Copy code
{  "type": "query",  "function": {    "name": "loan_details_search"  // Add this required field  },  "messages": [    // your existing messages  ],  "knowledgeBases": [    // your existing knowledge base config  ]}
Model Compatibility Check Important: Verify that "gemini-2.5-flash" is available for Google knowledge bases. The documentation shows examples using "gemini-1.5-flash". You may need to use:
Copy code
"model": "gemini-1.5-flash"  // Verify this model is supported
Complete Corrected Payload
Copy code
{  "type": "query",  "function": {    "name": "loan_details_search",    "description": "Search loan terms and conditions for customer inquiries"  },  "messages": [    {      "type": "request-start",      "content": "Let me check your loan details. Please hold for just a moment."    },    {      "type": "request-failed",       "content": "I am sorry, I am not able to answer your question. Please ask me something else or ask me after some time."    },    {      "type": "request-response-delayed",      "content": "This is taking a bit longer than expected. Please bear with me"    }  ],  "knowledgeBases": [    {      "name": "Loan terms and conditions",      "provider": "google",       "description": "This collection outlines the operational and legal guidelines for loan recovery.",      "fileIds": fileIds,      "model": "gemini-1.5-flash"  // Verify model availability    }  ]}
Next Steps Add the function field with a descriptive name Verify the Gemini model is supported for Google knowledge bases Test the tool creation to ensure it works properly Update your assistant's system prompt to reference the tool by its function name (loan_details_search)
s
{ "id": "log-31", "level": 50, "time": 1768484706215, "timestamp": 1768484706215000000, "severityText": "ERROR", "severityNumber": 17, "body": "Model sequence failed - all attempts exhausted", "attributes": { "category": "model", "callId": "019bc1e6-d1f4-7eec-be56-6f9b6c742248", "orgId": "da6f2fb0-f8d5-4625-b9a2-a1c03df6dfa2", "provider": "google", "model": "gemini-1.5-pro", "error": { "message": "[GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro:streamGenerateContent?alt=sse: [400 Bad Request] * GenerateContentRequest.tools[0].function_declarations[0].parameters.properties[knowledgeBaseNames].items: miss...", "error": { "status": 400, "statusText": "Bad Request" } }, "metrics": { "totalCost": 0, "totalPromptTokens": 0, "totalCompletionTokens": 0, "totalPromptCacheHitTokens": 0 } } } { "id": "log-30", "level": 50, "time": 1768484706189, "timestamp": 1768484706188000000, "severityText": "ERROR", "severityNumber": 17, "body": "Model sequence failed - all attempts exhausted", "attributes": { "category": "model", "callId": "019bc1e6-d1f4-7eec-be56-6f9b6c742248", "orgId": "da6f2fb0-f8d5-4625-b9a2-a1c03df6dfa2", "provider": "google", "model": "gemini-1.5-pro", "error": { "message": "[GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro:streamGenerateContent?alt=sse: [400 Bad Request] * GenerateContentRequest.tools[0].function_declarations[0].parameters.properties[knowledgeBaseNames].items: miss...", "error": { "status": 400, "statusText": "Bad Request" } }, "metrics": { "totalCost": 0, "totalPromptTokens": 0, "totalCompletionTokens": 0, "totalPromptCacheHitTokens": 0 } } }
for gemini 2.5 flash i got this error: { "id": "log-24", "level": 50, "time": 1768484440652, "timestamp": 1768484440652000000, "severityText": "ERROR", "severityNumber": 17, "body": "Model sequence failed - all attempts exhausted", "attributes": { "category": "model", "callId": "019bc1e2-c182-7882-8bce-9c3a148d7b94", "orgId": "da6f2fb0-f8d5-4625-b9a2-a1c03df6dfa2", "provider": "google", "model": "gemini-2.5-flash", "error": { "message": "[GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:streamGenerateContent?alt=sse: [400 Bad Request] * GenerateContentRequest.tools[0].function_declarations[0].parameters.properties[knowledgeBaseNames].items: mi...", "error": { "status": 400, "statusText": "Bad Request" } }, "metrics": { "totalCost": 0, "totalPromptTokens": 0, "totalCompletionTokens": 0, "totalPromptCacheHitTokens": 0 } } }
@Vapi @User Please let me know if I should try something else and share those logs
c
Hi @saketh_1201 I reviewed the call Id you provided in the initial message (
019bacb3-67d6-755e-ad5f-8e805a7273c6
). There was the following error log when calling google's endpoint.
Copy code
🔵 10:57:00:260 Couldn't Complete Completion Request (#1, provider: google, model: gemini-2.5-flash, region: undefined, credential: true) Error: {
  "status": 400,
  "statusText": "Bad Request",
  "message": "[GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:streamGenerateContent?alt=sse: [400 Bad Request] * GenerateContentRequest.tools[0].function_declarations[0].parameters.properties[knowledgeBaseNames].items: missing field.\n",
  "stack": "Error: [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:streamGenerateContent?alt=sse: [400 Bad Request] * GenerateContentRequest.tools[0].function_declarations[0].parameters.properties[knowledgeBaseNames].items: missing field.\n\n    at handleResponseNotOk (/app/node_modules/@google/generative-ai/dist/index.js:434:11)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async makeRequest (/app/node_modules/@google/generative-ai/dist/index.js:403:9)\n    at async generateContentStream (/app/node_modules/@google/generative-ai/dist/index.js:862:22)\n    at async GoogleRequest.request (/app/dist/libs/core/src/components/liveCallPipeline/streams/completions/requests/googleRequest.js:83:22)"
}
After some investigation regarding this issue. it seems like a known issue from google's side, I will make sure to report it to the team so that they can look into it. Till then, as a workaround, could you try using another LLM provider like ChatGPT? Please let me know whether the issue still persists even after switching to another LLM.