Die Gemini Developer API bietet die schnellste Möglichkeit, auf Gemini basierende Anwendungen zu entwickeln, in die Produktion zu bringen und zu skalieren. Die meisten Entwickler sollten die Gemini Developer API verwenden, sofern keine speziellen Unternehmensfunktionen erforderlich sind.
Vertex AI bietet ein umfassendes Ökosystem von Funktionen und Diensten für Unternehmen, mit denen generative KI-Anwendungen auf der Google Cloud Platform erstellt und bereitgestellt werden können.
Wir haben die Migration zwischen diesen Diensten vor Kurzem vereinfacht. Sowohl die Gemini Developer API als auch die Vertex AI Gemini API sind jetzt über das einheitliche Google Gen AI SDK zugänglich.
Codevergleich
Auf dieser Seite finden Sie nebeneinander gestellte Codevergleiche zwischen der Gemini Developer API und Vertex AI-Schnellstarts für die Textgenerierung.
Python
Sie können sowohl auf die Gemini Developer API als auch auf Vertex AI-Dienste über die google-genai-Bibliothek zugreifen. Eine Anleitung zur Installation von google-genai finden Sie auf der Seite Bibliotheken.
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 und TypeScript
Sie können sowohl auf die Gemini Developer API als auch auf Vertex AI-Dienste über die @google/genai-Bibliothek zugreifen. Eine Anleitung zur Installation von @google/genai finden Sie auf der Seite Bibliotheken.
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();
Ok
Sie können sowohl auf die Gemini Developer API als auch auf Vertex AI-Dienste über die google.golang.org/genai-Bibliothek zugreifen. Eine Anleitung zur Installation von google.golang.org/genai finden Sie auf der Seite Bibliotheken.
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)}
Alle Modelle, die Sie in Google AI Studio erstellt haben, müssen in Vertex AI neu trainiert werden.
Wenn Sie Ihren Gemini API-Schlüssel für die Gemini Developer API nicht mehr benötigen, folgen Sie den Best Practices für die Sicherheit und löschen Sie ihn.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 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."]]