Hello guys seem to have an issue with calling my tuned model below is my code
const fs = require('fs').promises;
const path = require('path');
const { GoogleAuth } = require('google-auth-library');
const axios = require('axios');
async function run() {
// Load the service account key JSON file
const keyFile = await fs.readFile(path.join(__dirname, 'secret.json'), 'utf8');
const keys = JSON.parse(keyFile);
// Initialize GoogleAuth for OAuth 2.0
const auth = new GoogleAuth({
credentials: keys,
scopes: ['https://www.googleapis.com/auth/generative-language']
});
const client = await auth.getClient();
// Get the access token
const accessToken = await client.getAccessToken();
const generationConfig = {
temperature: 0.9,
topP: 1,
maxOutputTokens: 8192,
};
const requestBody = {
contents: [{
role: 'user',
parts: [{ text: 'input: ' }, { text: 'output: ' }]
}],
generationConfig,
};
try {
const response = await axios.post(
'https://generativelanguage.googleapis.com/v1beta/tunedModels/copy-of-plan-house-model-a5iltlw1z6df:generateContent',
requestBody, {
headers: {
'Authorization': `Bearer ${accessToken.token}`,
'Content-Type': 'application/json',
}
}
);
console.log('Generated content:', response.data.candidates[0].content.parts[0].text);
} catch (error) {
console.error('Error generating content:', error.response ? error.response.data : error.message);
}
}
run();
i get error
Error generating content: {
error: {
code: 403,
message: ‘You do not have permission to access tuned model tunedModels/copy-of-plan-house-model-a5iltlw1z6df.’,
status: ‘PERMISSION_DENIED’
}
}