Welcome to Portkey Forum

Home
Members
Heisenberg
H
Heisenberg
Offline, last seen 2 days ago
Joined February 11, 2025
Title: "fn.function is not a function" error when using function calling with Gemini in Portkey
Description:
When trying to use function calling with Gemini model (virtualKey: "google") in Portkey, the following error occurs: fn.function is not a function. This happens when executing the runTools method. While function calling works correctly with other models (GPT-4, Mistral), it fails specifically with Gemini.
Steps to reproduce:

Configure Portkey with Gemini virtual key:

javascriptCopyconst portkey = new Portkey({
apiKey: process.env.PORTKEY_API_KEY,
virtualKey: "google",
traceID: "some-trace-id",
config: { cache: { mode: "semantic", max_age: 60000 } }
});

Define a tool:

javascriptCopyconst tools = [{
type: 'function',
function: {
name: 'cm6zksl7v00002v9f8asxnvpq',
description: "Get a random cat image",
parameters: {
type: "object",
properties: {
style: {
type: "string",
enum: ["cute", "funny", "sleepy"],
description: "Cat image style"
}
},
required: []
}
}
}];

Error occurs when running:

javascriptCopyconst runner = await portkey.beta.chat.completions.runTools({
messages: [...],
model: "gemini-model-name",
tools,
tool_choice: "auto",
stream: true,
temperature: 0,
user: "agentId"
});
Expected behavior: Portkey should properly execute the function calling with Gemini model as it does with other models.
17 comments
H
V
s