Gemini Developer API は、Gemini を活用したアプリケーションの構築、本番環境への移行、スケーリングを迅速に行うための手段です。特定のエンタープライズ コントロールが必要な場合を除き、ほとんどのデベロッパーは Gemini デベロッパー API を使用する必要があります。
Vertex AI は、Google Cloud Platform を基盤とする生成 AI アプリケーションの構築とデプロイのための、エンタープライズ対応の機能とサービスの包括的なエコシステムを提供します。
最近、これらのサービス間の移行を簡素化しました。Gemini Developer API と Vertex AI Gemini API の両方に、統合された Google Gen AI SDK を介してアクセスできるようになりました。
コードの比較
このページでは、テキスト生成用の Gemini Developer API と Vertex AI クイックスタートのコードを並べて比較しています。
Python
google-genai ライブラリを介して、Gemini Developer API と Vertex AI サービスの両方にアクセスできます。google-genai のインストール手順については、ライブラリのページをご覧ください。
Gemini Developer API
fromgoogleimportgenaiclient=genai.Client()response=client.models.generate_content(model="gemini-2.0-flash",contents="Explain how AI works in a few words")print(response.text)
Vertex AI Gemini API
fromgoogleimportgenaiclient=genai.Client(vertexai=True,project='your-project-id',location='us-central1')response=client.models.generate_content(model="gemini-2.0-flash",contents="Explain how AI works in a few words")print(response.text)
JavaScript と TypeScript
@google/genai ライブラリを介して、Gemini Developer API と Vertex AI サービスの両方にアクセスできます。@google/genai のインストール手順については、ライブラリのページをご覧ください。
Gemini Developer API
import{GoogleGenAI}from"@google/genai";constai=newGoogleGenAI({});asyncfunctionmain(){constresponse=awaitai.models.generateContent({model:"gemini-2.0-flash",contents:"Explain how AI works in a few words",});console.log(response.text);}main();
Vertex AI Gemini API
import{GoogleGenAI}from'@google/genai';constai=newGoogleGenAI({vertexai:true,project:'your_project',location:'your_location',});asyncfunctionmain(){constresponse=awaitai.models.generateContent({model:"gemini-2.0-flash",contents:"Explain how AI works in a few words",});console.log(response.text);}main();
Go
google.golang.org/genai ライブラリを介して、Gemini Developer API と Vertex AI サービスの両方にアクセスできます。google.golang.org/genai のインストール手順については、ライブラリのページをご覧ください。
Gemini Developer API
import("context""encoding/json""fmt""log""google.golang.org/genai")// Your Google API keyconstapiKey="your-api-key"funcmain(){ctx:=context.Background()client,err:=genai.NewClient(ctx,nil)iferr!=nil{log.Fatal(err)}// Call the GenerateContent method.result,err:=client.Models.GenerateContent(ctx,"gemini-2.0-flash",genai.Text("Tell me about New York?"),nil)}
Vertex AI Gemini API
import("context""encoding/json""fmt""log""google.golang.org/genai")// Your GCP projectconstproject="your-project"// A GCP location like "us-central1"constlocation="some-gcp-location"funcmain(){ctx:=context.Background()client,err:=genai.NewClient(ctx,&genai.ClientConfig{Project:project,Location:location,Backend:genai.BackendVertexAI,})// Call the GenerateContent method.result,err:=client.Models.GenerateContent(ctx,"gemini-2.0-flash",genai.Text("Tell me about New York?"),nil)}
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-08-22 UTC。"],[],[],null,["# Gemini Developer API v.s. Vertex AI\n\nWhen developing generative AI solutions with Gemini, Google offers two API products:\nthe [Gemini Developer API](/gemini-api/docs) and the [Vertex AI Gemini API](https://cloud.google.com/vertex-ai/generative-ai/docs/overview).\n\nThe Gemini Developer API provides the fastest path to build, productionize, and\nscale Gemini powered applications. Most developers should use the Gemini Developer\nAPI unless there is a need for specific enterprise controls.\n\nVertex AI offers a comprehensive ecosystem of enterprise ready features and services\nfor building and deploying generative AI applications backed by the Google Cloud Platform.\n\nWe've recently simplified migrating between these services. Both the Gemini\nDeveloper API and the Vertex AI Gemini API are now accessible through the unified\n[Google Gen AI SDK](/gemini-api/docs/libraries).\n\nCode comparison\n---------------\n\nThis page has side-by-side code comparisons between Gemini Developer API and\nVertex AI quickstarts for text generation.\n\n### Python\n\nYou can access both the Gemini Developer API and Vertex AI services through\nthe `google-genai` library. See the [libraries](/gemini-api/docs/libraries) page\nfor instructions on how to install `google-genai`. \n\n### Gemini Developer API\n\n from google import genai\n\n client = genai.Client()\n\n response = client.models.generate_content(\n model=\"gemini-2.0-flash\", contents=\"Explain how AI works in a few words\"\n )\n print(response.text)\n\n### Vertex AI Gemini API\n\n from google import genai\n\n client = genai.Client(\n vertexai=True, project='your-project-id', location='us-central1'\n )\n\n response = client.models.generate_content(\n model=\"gemini-2.0-flash\", contents=\"Explain how AI works in a few words\"\n )\n print(response.text)\n\n### JavaScript and TypeScript\n\nYou can access both Gemini Developer API and Vertex AI services through `@google/genai`\nlibrary. See [libraries](/gemini-api/docs/libraries) page for instructions on how\nto install `@google/genai`. \n\n### Gemini Developer API\n\n import { GoogleGenAI } from \"@google/genai\";\n\n const ai = new GoogleGenAI({});\n\n async function main() {\n const response = await ai.models.generateContent({\n model: \"gemini-2.0-flash\",\n contents: \"Explain how AI works in a few words\",\n });\n console.log(response.text);\n }\n\n main();\n\n### Vertex AI Gemini API\n\n import { GoogleGenAI } from '@google/genai';\n const ai = new GoogleGenAI({\n vertexai: true,\n project: 'your_project',\n location: 'your_location',\n });\n\n async function main() {\n const response = await ai.models.generateContent({\n model: \"gemini-2.0-flash\",\n contents: \"Explain how AI works in a few words\",\n });\n console.log(response.text);\n }\n\n main();\n\n### Go\n\nYou can access both Gemini Developer API and Vertex AI services through `google.golang.org/genai`\nlibrary. See [libraries](/gemini-api/docs/libraries) page for instructions on how\nto install `google.golang.org/genai`. \n\n### Gemini Developer API\n\n import (\n \"context\"\n \"encoding/json\"\n \"fmt\"\n \"log\"\n \"google.golang.org/genai\"\n )\n\n // Your Google API key\n const apiKey = \"your-api-key\"\n\n func main() {\n ctx := context.Background()\n client, err := genai.NewClient(ctx, nil)\n if err != nil {\n log.Fatal(err)\n }\n\n // Call the GenerateContent method.\n result, err := client.Models.GenerateContent(ctx, \"gemini-2.0-flash\", genai.Text(\"Tell me about New York?\"), nil)\n\n }\n\n### Vertex AI Gemini API\n\n import (\n \"context\"\n \"encoding/json\"\n \"fmt\"\n \"log\"\n \"google.golang.org/genai\"\n )\n\n // Your GCP project\n const project = \"your-project\"\n\n // A GCP location like \"us-central1\"\n const location = \"some-gcp-location\"\n\n func main() {\n ctx := context.Background()\n client, err := genai.NewClient(ctx, &genai.ClientConfig\n {\n Project: project,\n Location: location,\n Backend: genai.BackendVertexAI,\n })\n\n // Call the GenerateContent method.\n result, err := client.Models.GenerateContent(ctx, \"gemini-2.0-flash\", genai.Text(\"Tell me about New York?\"), nil)\n\n }\n\n### Other use cases and platforms\n\nRefer to use case specific guides on [Gemini Developer API Documentation](/gemini-api/docs)\nand [Vertex AI documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/overview)\nfor other platforms and use cases.\n\nMigration considerations\n------------------------\n\nWhen you migrate:\n\n- You'll need to use Google Cloud service accounts to authenticate. See the [Vertex AI documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/overview)\n for more information.\n\n- You can use your existing Google Cloud project\n (the same one you used to generate your API key) or you can\n [create a new Google Cloud project](https://cloud.google.com/resource-manager/docs/creating-managing-projects).\n\n- Supported regions may differ between the Gemini Developer API and the\n Vertex AI Gemini API. See the list of\n [supported regions for generative AI on Google Cloud](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/locations-genai).\n\n- Any models you created in Google AI Studio need to be retrained in Vertex AI.\n\nIf you no longer need to use your Gemini API key for the Gemini Developer API,\nthen follow security best practices and delete it.\n\nTo delete an API key:\n\n1. Open the\n [Google Cloud API Credentials](https://console.cloud.google.com/apis/credentials)\n page.\n\n2. Find the API key you want to delete and click the **Actions** icon.\n\n3. Select **Delete API key**.\n\n4. In the **Delete credential** modal, select **Delete**.\n\n Deleting an API key takes a few minutes to propagate. After\n propagation completes, any traffic using the deleted API key is rejected.\n\n| **Important:** If you have deleted a key that is still used in production and need to recover it, see [gcloud beta services api-keys undelete](https://cloud.google.com/sdk/gcloud/reference/beta/services/api-keys/undelete).\n\nNext steps\n----------\n\n- See the [Generative AI on Vertex AI overview](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/overview) to learn more about generative AI solutions on Vertex AI."]]