https://bard.google.com/updates
https://bard.google.com/extensions
Pricing
https://cloud.google.com/vertex-ai/pricing#generative_ai_models
Генерация текста /Text generation
Поддержка генеративного ИИ в Vertex AI взимает плату за каждые 1000 символов ввода (подсказки) и за каждые 1000 символов вывода (ответа). Символы подсчитываются по кодовым точкам UTF-8, а пробелы исключаются из подсчета. На этапе предварительного просмотра расходы предоставляются со скидкой 100 %. Запросы прогнозирования, которые приводят к отфильтрованным ответам, взимаются только за входные данные. В конце каждого платежного цикла доли одного цента (0,01 доллара США) округляются до одного цента.
Vertex AI API
https://cloud.google.com/vertex-ai/docs/reference/rest
Куча
//
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import { JWT } from "google-auth-library"; const API_ENDPOINT = "us-central1-aiplatform.googleapis.com"; const URL = `https://${API_ENDPOINT}/v1/projects/${process.env.GOOGLE_KEY}/locations/us-central1/publishers/google/models/chat-bison@001:predict`; const getIdToken = async () => { const client = new JWT({ keyFile: "./google.json", scopes: ["https://www.googleapis.com/auth/cloud-platform"], }); const idToken = await client.authorize(); return idToken.access_token; }; export const getTextPalm = async (prompt, temperature) => { const headers = { Authorization: `Bearer ` + (await getIdToken()), "Content-Type": "application/json", }; const data = { instances: [ { context: "", examples: [], messages: [ { author: "user", content: prompt, }, ], }, ], parameters: { temperature: temperature || 0.5, maxOutputTokens: 1024, topP: 0.8, topK: 40, }, }; const response = await fetch(URL, { method: "POST", headers, body: JSON.stringify(data), }); if (!response.ok) { console.error(response.statusText); throw new Error("Request failed " + response.statusText); } const result = await response.json(); return result.predictions[0].candidates[0].content; }; |
//