開啟 VS Code,然後按一下 Gemini Code Assist 對話圖示。你應該會看到聊天視窗。
步驟 2:輸入 Apigee 控制代碼,使用 Apigee 工具
在即時通訊視窗中輸入 @Apigee。畫面上會顯示 Apigee 提示清單。
選取「建立 API 規格」。
步驟 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 中心和 API 端點擷取的企業脈絡摘要。Cloud Code 中的其他分頁會顯示規格程式碼和 Swagger 介面,其中包含端點、結構定義,以及新 API 規格的其他資訊。
[[["容易理解","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-09-05 (世界標準時間)。"],[[["\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)."]]