# codeExecution and function calling

**URL:** <https://discuss.ai.google.dev/t/codeexecution-and-function-calling/58663>\
**Category:** Gemini API\
**Tags:** gemini-flash, models\
**Created:** [January 2, 2025, 9:01pm UTC](https://discuss.ai.google.dev/t/codeexecution-and-function-calling/58663 "2025-01-02T21:01:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Kotowski](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/john_kotowski/32/36330_2.png) [@John\_Kotowski](https://discuss.ai.google.dev/u/John_Kotowski)\
**Post date:** [January 2, 2025, 9:01pm UTC](https://discuss.ai.google.dev/t/codeexecution-and-function-calling/58663/1 "2025-01-02T21:01:32Z")

</div>

Can I do both codeExecution and function calling at the same time?

This fails, but works when I do one at a time…

const generativeModel = genAI.getGenerativeModel({  
// Use a model that supports function calling, like a Gemini 1.5 model  
model: “gemini-1.5-flash”,

```
    // Specify the function declaration.
    tools: {
        functionDeclarations: [getCompaniesFunctionDeclaration],
        codeExecution: {},
    },
});

```

---

<div class="post-metadata">

**Author:** ![GUNAND\_MAYANGLAMBAM](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/gunand_mayanglambam/32/4964_2.png) [@GUNAND\_MAYANGLAMBAM](https://discuss.ai.google.dev/u/GUNAND_MAYANGLAMBAM)\
**Post date:** [January 3, 2025, 12:39pm UTC](https://discuss.ai.google.dev/t/codeexecution-and-function-calling/58663/3 "2025-01-03T12:39:57Z")

</div>

Hi @John_Kotowski , Welcome to the forum.

You are right. Either `codeExecution`, `functionDeclarations`, or `googleSearchRetrieval` needs to be passed one at a time, otherwise, you will get an `INVALID_ARGUMENT` error. The same applies in AI Studio as well, you can enable only one tool at a time.

**Note** : Multi-tool usage is only enabled through the live API at the moment.

Thanks.
