SPB Git

Repository Public

migrate-to-cloud.md 6.7 KB 198 lines markdown

1When developing generative AI solutions with Gemini, Google offers two API products:2the [Gemini Developer API](https://ai.google.dev/gemini-api/docs) and the [Gemini Enterprise Agent Platform API](https://cloud.google.com/gemini-enterprise-agent-platform/overview).34The Gemini Developer API provides the fastest path to build, productionize, and5scale Gemini powered applications. Most developers should use the Gemini Developer6API unless there is a need for specific enterprise controls.78Gemini Enterprise Agent Platform offers a comprehensive ecosystem of enterprise ready features and services9for building and deploying generative AI applications backed by the Google Cloud Platform.1011We've recently simplified migrating between these services. Both the Gemini12Developer API and the Gemini Enterprise Agent Platform API are now accessible through the unified13[Google Gen AI SDK](https://ai.google.dev/gemini-api/docs/libraries).1415## Code comparison1617This page has side-by-side code comparisons between Gemini Developer API and18Gemini Enterprise Agent Platform quickstarts for text generation.1920### Python2122You can access both the Gemini Developer API and Gemini Enterprise Agent Platform services through23the `google-genai` library. See the [libraries](https://ai.google.dev/gemini-api/docs/libraries) page24for instructions on how to install `google-genai`.2526### Gemini Developer API2728    from google import genai2930    client = genai.Client()3132    response = client.models.generate_content(33        model="gemini-3.8-flash", contents="Explain how AI works in a few words"34    )35    print(response.text)3637### Gemini Enterprise Agent Platform API3839    from google import genai4041    client = genai.Client(42        vertexai=True, project='your-project-id', location='us-central1'43    )4445    response = client.models.generate_content(46        model="gemini-3.8-flash", contents="Explain how AI works in a few words"47    )48    print(response.text)4950### JavaScript and TypeScript5152You can access both Gemini Developer API and Gemini Enterprise Agent Platform services through `@google/genai`53library. See [libraries](https://ai.google.dev/gemini-api/docs/libraries) page for instructions on how54to install `@google/genai`.5556### Gemini Developer API5758    import { GoogleGenAI } from "@google/genai";5960    const ai = new GoogleGenAI({});6162    async function main() {63      const response = await ai.models.generateContent({64        model: "gemini-3.8-flash",65        contents: "Explain how AI works in a few words",66      });67      console.log(response.text);68    }6970    main();7172### Gemini Enterprise Agent Platform API7374    import { GoogleGenAI } from '@google/genai';75    const ai = new GoogleGenAI({76      vertexai: true,77      project: 'your_project',78      location: 'your_location',79    });8081    async function main() {82      const response = await ai.models.generateContent({83        model: "gemini-3.8-flash",84        contents: "Explain how AI works in a few words",85      });86      console.log(response.text);87    }8889    main();9091### Go9293You can access both Gemini Developer API and Gemini Enterprise Agent Platform services through `google.golang.org/genai`94library. See [libraries](https://ai.google.dev/gemini-api/docs/libraries) page for instructions on how95to install `google.golang.org/genai`.9697### Gemini Developer API9899    import (100      "context"101      "encoding/json"102      "fmt"103      "log"104      "google.golang.org/genai"105    )106107    // Your Google API key108    const apiKey = "your-api-key"109110    func main() {111      ctx := context.Background()112      client, err := genai.NewClient(ctx, nil)113      if err != nil {114          log.Fatal(err)115      }116117      // Call the GenerateContent method.118      result, err := client.Models.GenerateContent(ctx, "gemini-3.8-flash", genai.Text("Tell me about New York?"), nil)119120    }121122### Gemini Enterprise Agent Platform API123124    import (125      "context"126      "encoding/json"127      "fmt"128      "log"129      "google.golang.org/genai"130    )131132    // Your GCP project133    const project = "your-project"134135    // A GCP location like "us-central1"136    const location = "some-gcp-location"137138    func main() {139      ctx := context.Background()140      client, err := genai.NewClient(ctx, &genai.ClientConfig141      {142            Project:  project,143          Location: location,144          Backend:  genai.BackendVertexAI,145      })146147      // Call the GenerateContent method.148      result, err := client.Models.GenerateContent(ctx, "gemini-3.8-flash", genai.Text("Tell me about New York?"), nil)149150    }151152### Other use cases and platforms153154Refer to use case specific guides on [Gemini Developer API Documentation](https://ai.google.dev/gemini-api/docs)155and [Gemini Enterprise Agent Platform documentation](https://cloud.google.com/gemini-enterprise-agent-platform/generative-ai/docs/overview)156for other platforms and use cases.157158## Migration considerations159160When you migrate:161162- You'll need to use Google Cloud service accounts to authenticate. See the [Gemini Enterprise Agent Platform documentation](https://cloud.google.com/gemini-enterprise-agent-platform/generative-ai/docs/overview)163  for more information.164165- You can use your existing Google Cloud project166  (the same one you used to generate your API key) or you can167  [create a new Google Cloud project](https://cloud.google.com/resource-manager/docs/creating-managing-projects).168169- Supported regions may differ between the Gemini Developer API and the170  Gemini Enterprise Agent Platform API. See the list of171  [supported regions for generative AI on Google Cloud](https://cloud.google.com/gemini-enterprise-agent-platform/generative-ai/docs/learn/locations-genai).172173- Any models you created in Google AI Studio need to be retrained in Gemini Enterprise Agent Platform.174175If you no longer need to use your Gemini API key for the Gemini Developer API,176then follow security best practices and delete it.177178To delete an API key:1791801. Open the181   [Google Cloud API Credentials](https://console.cloud.google.com/apis/credentials)182   page.1831842. Find the API key you want to delete and click the **Actions** icon.1851863. Select **Delete API key**.1871884. In the **Delete credential** modal, select **Delete**.189190   Deleting an API key takes a few minutes to propagate. After191   propagation completes, any traffic using the deleted API key is rejected.192193> [!IMPORTANT]194> **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).195196## Next steps197198- See the [Generative AI on Gemini Enterprise Agent Platform overview](https://docs.cloud.google.com/gemini-enterprise-agent-platform/overview) to learn more about generative AI solutions on Gemini Enterprise Agent Platform.
Files main
Menu

Theme