Skip to main content

Google AI Studio (Gemini)

Google AI Studio Integration

Google AI Studio supports external function calling. For detailed configuration instructions, visit the official documentation.

To integrate Timbr:

Function Declarations

Define Timbr tools as function declarations in your AI Studio project:

const timbrTools = [
{
name: "query_data",
description: "Execute a natural language query against Timbr semantic layer",
parameters: {
type: "object",
properties: {
prompt: {
type: "string",
description: "Natural language query"
},
agent_name: {
type: "string",
description: "Target agent name"
},
ontology: {
type: "string",
description: "Target ontology name"
},
max_limit: {
type: "integer",
description: "Maximum rows to return"
}
},
required: ["prompt"]
}
},
{
name: "ask_question",
description: "Ask a question and get a natural language answer",
parameters: {
type: "object",
properties: {
prompt: {
type: "string",
description: "Natural language question"
},
agent_name: {
type: "string",
description: "Target agent name"
},
ontology: {
type: "string",
description: "Target ontology name"
}
},
required: ["prompt"]
}
}
];

Function Implementation

Implement the function handler to call Timbr API:

async function handleTimbrFunction(functionCall) {
const { name, args } = functionCall;

const headers = {
'Content-Type': 'application/json',
'x-api-key': process.env.TIMBR_API_KEY
};

// Set either agent or ontology header
if (args.agent_name) {
headers['x-agent'] = args.agent_name;
} else if (args.ontology) {
headers['x-ontology'] = args.ontology;
}

const response = await fetch('https://<your-timbr-server>/timbr/api/mcp/', {
method: 'POST',
headers: headers,
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'tools/call',
params: {
name: name,
arguments: args
}
})
});

return await response.json();
}