Error [AI_APICallError]: Function calling is not enabled for tunedModels/

I generated an API key in my Google cloud project for Gemini API and I’m perfectly able to use it with my Vercel AI SDK for Gemini pro and flash, but I’m not able to use for my tuned model in Google Studio.

So I tuned a model in my Google AI studio and gave access to the new tuned model API access

API keys for the following projects can use this tuned model. Cloud project. Gemini API

But when trying to call it, the exact way I’m using the key for Gemini pro and flash, I get the following error: Error [AI_APICallError]: Function calling is not enabled for tunedModels/roryb-jgtp
at (.next/server/app/(chat)/api/chat/route.js:28:4…

cause: undefined,
url: ‘https://generativelanguage.googleapis.com/v1beta/tunedModels/roryb-jgtp:streamGenerateContent?alt=sse’,
requestBodyValues: [Object],
statusCode: 400,
responseHeaders: [Object],
responseBody: ‘{\n’ +
’ “error”: {\n’ +
’ “code”: 400,\n’ +
’ “message”: “Function calling is not enabled for tunedModels/roryb-jgtp”,\n’ +
’ “status”: “INVALID_ARGUMENT”\n’ +
’ }\n’ +
‘}\n’,
isRetryable: false,
data: [Object]
}

Welcome to the forum.

I believe the reason is - Function calling inside fine tune model? - #3 by Susarla_Sai_Manoj

@Adelina_Martiniuc,

Function calling is not enabled for tuned models. If you would like to use function calling along with a tuned model, you could use multi agent architecture where one agent/API call is to your tuned model and output of this model could be chained to an other agent/API call to a model that has a function calling.

Your tuned model could be function more like on orchestrator agent while other model can work like a worker agent.