Include api key in header instead of in the URL (#4240)
This commit is contained in:
parent
40c4070846
commit
7b49560265
|
@ -28,7 +28,7 @@ export async function getEffectiveModel(
|
||||||
|
|
||||||
const modelToTest = DEFAULT_GEMINI_MODEL;
|
const modelToTest = DEFAULT_GEMINI_MODEL;
|
||||||
const fallbackModel = DEFAULT_GEMINI_FLASH_MODEL;
|
const fallbackModel = DEFAULT_GEMINI_FLASH_MODEL;
|
||||||
const endpoint = `https://generativelanguage.googleapis.com/v1beta/models/${modelToTest}:generateContent?key=${apiKey}`;
|
const endpoint = `https://generativelanguage.googleapis.com/v1beta/models/${modelToTest}:generateContent`;
|
||||||
const body = JSON.stringify({
|
const body = JSON.stringify({
|
||||||
contents: [{ parts: [{ text: 'test' }] }],
|
contents: [{ parts: [{ text: 'test' }] }],
|
||||||
generationConfig: {
|
generationConfig: {
|
||||||
|
@ -45,7 +45,10 @@ export async function getEffectiveModel(
|
||||||
try {
|
try {
|
||||||
const response = await fetch(endpoint, {
|
const response = await fetch(endpoint, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'x-goog-api-key': apiKey,
|
||||||
|
},
|
||||||
body,
|
body,
|
||||||
signal: controller.signal,
|
signal: controller.signal,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue