チュートリアル: Gemini Code Assist を使用して Apigee で API を設計、開発、テストする
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
このページの内容は Apigee と Apigee ハイブリッドに該当します。
概要
このチュートリアルでは、Gemini Code Assist の @Apigee ツールを使用して API 仕様を作成、編集するプロセスについて説明します。歯科医院の予約を管理する API を設計して作成するために、自然言語プロンプトを使用します。仕様が準備できたら、テストして Apigee API プロキシを作成することもできます。
Gemini Code Assist を使用した API 仕様の作成と編集の詳細については、API の設計と編集をご覧ください。
VS Code を開き、Gemini Code Assist のチャット アイコンをクリックします。チャット ウィンドウが表示されます。
ステップ 2: Apigee ハンドルを入力して Apigee ツールを使用する
チャット ウィンドウに「@Apigee」と入力します。Apigee プロンプトのリストが表示されます。[Create an API specification] を選択します。
ステップ 3: プロンプトを入力する
入力フィールドに次の説明を入力して送信し、プロンプトを完了します。
@Apigee Create an API specification for patients to schedule their own appointments with a dental
office. Include multiple dentists and a dental appointment type, which can be regular checkup or
other.
ステップ 4: 仕様を表示する
Gemini Code Assist が仕様を生成するまで待ちます。仕様が利用可能になると、API Hub と API エンドポイントから取得したエンタープライズ コンテキストの要約など、生成された仕様に関する情報がチャット ウィンドウに表示されます。Cloud Code の他のタブには、仕様コードと、エンドポイント、スキーマ、新しい API 仕様に関するその他の情報を含む Swagger インターフェースが表示されます。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-08-13 UTC。"],[[["\u003cp\u003eThis tutorial demonstrates how to use Gemini Code Assist in Cloud Code to design an API and create an Apigee API proxy from a generated API specification.\u003c/p\u003e\n"],["\u003cp\u003eYou'll learn how to use natural language prompts to create an API, view and modify the generated spec, and test it using a local mock server.\u003c/p\u003e\n"],["\u003cp\u003eThe tutorial covers the optional step of registering your final API to API hub for developer access.\u003c/p\u003e\n"],["\u003cp\u003eYou can also save the designed API, create an Apigee API proxy bundle from the API spec, and continue developing the proxy.\u003c/p\u003e\n"],["\u003cp\u003eThe necessary prerequisites include setting up Gemini for Google Cloud API, Apigee API Admin access, local development in Cloud Code, and familiarity with OpenAPI specifications.\u003c/p\u003e\n"]]],[],null,["# Tutorial: Use Gemini Code Assist to design, develop, and test APIs in Apigee\n\n*This page\napplies to **Apigee** and **Apigee hybrid**.*\n\nOverview\n--------\n\nThis tutorial guides you through the process of using the `@Apigee` tool in\nGemini Code Assist to\ncreate and edit an API spec. You'll use a natural language prompt to design and create an API for\nmanaging dental office appointments. Once the spec is ready, you can also test it and create an\nApigee API proxy from it.\n\nFor more information on creating and editing API specs using Gemini Code Assist, see\n[Design and edit APIs](/apigee/docs/api-platform/local-development/vscode/develop-design-edit-apis).\n\nBefore you begin\n----------------\n\nTo complete this tutorial, you'll need:\n\n- A Google Cloud project set up for local development in Google Cloud. See [Set up Apigee API Management in Cloud Code for VS Code](/apigee/docs/api-platform/local-development/setup). Make sure to set up Gemini Code Assist for your project. See [Use Gemini Code Assist with Apigee](/apigee/docs/api-platform/local-development/setup#gemini).\n- To make sure your user account has the required roles listed in [Required roles to use Gemini Code Assist in Apigee](/apigee/docs/api-platform/local-development/setup#required-roles-to-use-gemini-code-assist-in-apigee) for each task.\n- Familiarity with [OpenAPI specs](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md), so that you can review the generated spec.\n\nStep 1: Open Gemini Code Assist Chat\n------------------------------------\n\nOpen VS Code and click the Gemini Code Assist chat icon. You should see the chat window.\n\nStep 2: Enter the Apigee handle to use the\nApigee tool\n------------------------------------------------------\n\nType `@Apigee` in the chat window. You'll see a list of Apigee prompts.\nSelect **Create an API specification**.\n\nStep 3: Enter the prompt\n------------------------\n\nIn the input field, enter and submit this description to complete the prompt: \n\n\n`@Apigee Create an API specification for patients to schedule their own appointments with a dental\noffice. Include multiple dentists and a dental appointment type, which can be regular checkup or\nother.`\n| **Note:** Do not copy and paste over the `@Apigee` handle. Instead, complete the prompt by pasting in the text starting with `for patients to\n| schedule...`.\n\nStep 4: View the spec\n---------------------\n\nWait while Gemini Code Assist generates the spec. Once it's available, the chat window\nshows information about the generated spec, including a summary of enterprise context leveraged\nfrom your API hub and API endpoints. Other tabs in Cloud Code\nshow the spec code and the Swagger interface with the endoints, schema, and other information\nabout the new API spec.\n\nStep 5: Modify the spec\n-----------------------\n\nModify the spec to include multiple dental office locations. First, make sure that the\nYAML file containing the spec is in the currently active tab in your editor. Then, in the chat window,\nenter the\nApigee handle again and select the Apigee tool: `@Apigee`. Enter this\nprompt: \n\n`@Apigee Update the API specification for the dental scheduling API. Add multiple dental\noffice locations.`\n\nThe changes to the spec are shown, with diffs highlighted, in the editing tab. You can also\nmodify the spec by typing your updates directly in the editing tab and saving the file.\n\nStep 6: Publish your API to API hub\n-----------------------------------\n\nOnce your API is reviewed and final, make it available to developers by registering it\nwith API hub:\n\n1. Click **Publish to API hub**.\n2. Follow the prompts to publish/register the API. See [Register an API](/apigee/docs/apihub/manage-apis#register-an-api) for information on registering with API hub and the information you need to provide.\n\nStep 7: Test the API using a local mock server\n----------------------------------------------\n\nTest the API using the local\n[mock server](/apigee/docs/api-platform/local-development/vscode/develop-design-edit-apis#use-the-local-mock-server),\nwhich emulates responses for the API. The local mock server does not require publishing to\nAPI Hub.\n\nThe local mock server should already be selected in the **Servers** dropdown. \n\nOnce the local mock server is selected, open the **POST** path and click **Try it out**.\n\nProvide the \"city\", \"country\", and \"postalCode\" values in the request body for the\n`addresses` entity: \n\n```\n{\n \"city\": \"string\",\n \"country\": \"string\",\n \"postalCode\": \"string\",\n \"state\": \"string\",\n \"streetAddress\": \"string\"\n }\n```\n\nClick **Execute** to see a mock response from the API in the **Responses** section.\n\nStep 8: Create an API proxy bundle from this spec\n-------------------------------------------------\n\n(Optional) To create an Apigee\n[API proxy bundle](/apigee/docs/api-platform/fundamentals/understanding-apis-and-api-proxies#howdoyoucreateanapiproxy)\nfrom this spec, click the **Create API proxy bundle** button and enter a proxy name.\nAfter creation, you should see the new proxy under **apiproxies** in your Apigee\nworkspace. See\n[Developing API proxies](/apigee/docs/api-platform/local-development/vscode/develop-apiproxies)\nfor information on working with API proxies in Cloud Code. \n\nNext steps\n----------\n\n- Learn more about [designing and editing APIs using Cloud Code](/apigee/docs/api-platform/local-development/vscode/develop-design-edit-apis).\n- Learn more about Gemini Code Assist features you can use in Apigee. See [Use Gemini](/apigee/docs/api-platform/get-started/gemini-code-assist)."]]