這次 Vertex AI in express mode,連信用卡資訊都不用填,只需要 Google 帳號就可以使用 Vertex AI in express mode。
不過要注意幾個方案的些微差異:
Vertex AI express mode: 90 天使用, 基本的 GenAI services, Data sources 只有 Google Drive. 沒有 SLA
Vertex AI express mode with billing: 使用時間無限制, 增加部份的 Vertex AI and Google Cloud services, Data sources: Google Drive, Web, Youtute
Vertex AI: 全功能
還有 Available models, rate limits 也會不太一樣。
來看一下怎麼申請吧!
點選這個網址: https://cloud.google.com/generative-ai-studio?hl=en . `Try it free` on Vertex AI Studio (前提是你的 Google 帳號還沒有 Google cloud project or billing account)
記得,記得選網頁最下方這個,
其他按鈕都會轉到要你填 Billing account
免費版本快速體驗版本的 Vertex AI 打開了!改用 API key 方式,先點右上方的 Get Code,點一下 Show Key
結果
Code snippet
from google import genai from google.genai import types import base64 import os def generate(): client = genai.Client( vertexai=True, api_key=os.environ.get("GOOGLE_CLOUD_API_KEY"), ) # model = "gemini-2.0-flash-001" model = "gemini-1.5-pro-002" contents = [ types.Content( role="user", parts=[ types.Part.from_text(text="""Write a poem for Gemini 2.0""") ] ) ] generate_content_config = types.GenerateContentConfig( temperature = 1, top_p = 0.95, max_output_tokens = 8192, response_modalities = ["TEXT"], safety_settings = [types.SafetySetting( category="HARM_CATEGORY_HATE_SPEECH", threshold="OFF" ),types.SafetySetting( category="HARM_CATEGORY_DANGEROUS_CONTENT", threshold="OFF" ),types.SafetySetting( category="HARM_CATEGORY_SEXUALLY_EXPLICIT", threshold="OFF" ),types.SafetySetting( category="HARM_CATEGORY_HARASSMENT", threshold="OFF" )], ) for chunk in client.models.generate_content_stream( model = model, contents = contents, config = generate_content_config, ): print(chunk.text, end="") generate()