The Gemini Developer API provides the fastest path to build, productionize, and
scale Gemini powered applications. Most developers should use the Gemini Developer
API unless there is a need for specific enterprise controls.
Vertex AI offers a comprehensive ecosystem of enterprise ready features and services
for building and deploying generative AI applications backed by the Google Cloud Platform.
We've recently simplified migrating between these services. Both the Gemini
Developer API and the Vertex AI Gemini API are now accessible through the unified
Google Gen AI SDK.
Code comparison
This page has side-by-side code comparisons between Gemini Developer API and
Vertex AI quickstarts for text generation.
Python
You can access both the Gemini Developer API and Vertex AI services through
the google-genai library. See the libraries page
for instructions on how to install 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 and TypeScript
You can access both Gemini Developer API and Vertex AI services through @google/genai
library. See libraries page for instructions on how
to install @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
You can access both Gemini Developer API and Vertex AI services through google.golang.org/genai
library. See libraries page for instructions on how
to install 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)}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-21 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."]]