According to https://ai.google.dev/gemini-api/docs/interactions/tool-combination#limitations (and several other documentation pages), function calls and other tools should be able to be combined when using the interactions API. However, when I try this, whether with code_execution or some other tool like url_context, I get the error Request contains an invalid argument.
Full error (click to expand)
/home/user/world-agent-interaction/node_modules/@google/genai/src/interactions/core/error.ts:66
return new BadRequestError(status, error, message, headers);
^
BadRequestError: 400 {"error":{"message":"Request contains an invalid argument.","code":"invalid_request"}}
at APIError.generate (/home/user/world-agent-interaction/node_modules/@googlegoogle/genai/src/interactions/core/error.ts:66:14)
at GeminiNextGenAPIClient.makeStatusError (/home/user/world-agent-interaction/node_mo@googleules/@google/genai/src/interactions/client.ts:378:28)
at GeminiNextGenAPIClient.makeRequest (/home/user/world-agent-interaction/n@googlede_modules/@google/genai/src/interactions/client.ts:610:24)
at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
at async Agent.test (/home/user/world-agent-interaction/src/interaction.ts:213:9)
at async (/home/user/world-agent-interaction/src/main.ts:5:1) {
status: 400,
headers: Headers {},
error: {
error: {
message: 'Request contains an invalid argument.',
code: 'invalid_request'
}
}
}
Minimal example (typescript/javascript SDK):
import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI({});
await ai.interactions.create({
model: 'gemini-3.1-flash-lite',
input: 'say "hello, world"',
tools: [
{ type: 'code_execution' },
{
type: 'function',
name: 'foo',
description: 'returns 1',
parameters: {
type: 'number',
},
},
],
});
Just combining native tools (e.g. code execution with URL context) doesn’t trigger the error.
I’ve tried this with gemini 3.1 flash lite, and gemini 3 flash preview. I am using the latest version of the typescript sdk (v2.8.0).
Is there anything I need to do to make this work, or is this a bug?
Thank you for any help you can provide.