Repository Public
1# Getting started with GPT Actions23> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.45## Weather.gov example67The NSW (National Weather Service) maintains a [public API](https://www.weather.gov/documentation/services-web-api) that users can query to receive a weather forecast for any lat-long point. To retrieve a forecast, there’s 2 steps:891. A user provides a lat-long to the api.weather.gov/points API and receives back a WFO (weather forecast office), grid-X, and grid-Y coordinates102. Those 3 elements feed into the api.weather.gov/forecast API to retrieve a forecast for that coordinate1112For the purpose of this exercise, let’s build a Custom GPT where a user writes a city, landmark, or lat-long coordinates, and the Custom GPT answers questions about a weather forecast in that location.1314## Step 1: Write and test Open API schema (using Actions GPT)1516A GPT Action requires an [Open API schema](https://swagger.io/specification/) to describe the parameters of the API call, which is a standard for describing APIs.1718OpenAI released a public [Actions GPT](https://chatgpt.com/g/g-TYEliDU6A-actionsgpt) to help developers write this schema. For example, go to the Actions GPT and ask: _“Go to https://www.weather.gov/documentation/services-web-api and read the documentation on that page. Build an Open API Schema for the /points/\{latitude},\{longitude} and /gridpoints/\{office}/\{gridX},\{gridY}/forecast” API calls”_1920<img21 className="images-example-image" src="https://cdn.openai.com/API/images/guides/actions_action_gpt.png"22 alt="The above Actions GPT request"23/>24252627Below is the full Open API Schema that the Actions GPT Returned:2829```yaml30openapi: 3.1.031info:32 title: NWS Weather API33 description: Access to weather data including forecasts, alerts, and observations.34 version: 1.0.035servers:36 - url: https://api.weather.gov37 description: Main API Server38paths:39 /points/{latitude},{longitude}:40 get:41 operationId: getPointData42 summary: Get forecast grid endpoints for a specific location43 parameters:44 - name: latitude45 in: path46 required: true47 schema:48 type: number49 format: float50 description: Latitude of the point51 - name: longitude52 in: path53 required: true54 schema:55 type: number56 format: float57 description: Longitude of the point58 responses:59 "200":60 description: Successfully retrieved grid endpoints61 content:62 application/json:63 schema:64 type: object65 properties:66 properties:67 type: object68 properties:69 forecast:70 type: string71 format: uri72 forecastHourly:73 type: string74 format: uri75 forecastGridData:76 type: string77 format: uri7879 /gridpoints/{office}/{gridX},{gridY}/forecast:80 get:81 operationId: getGridpointForecast82 summary: Get forecast for a given grid point83 parameters:84 - name: office85 in: path86 required: true87 schema:88 type: string89 description: Weather Forecast Office ID90 - name: gridX91 in: path92 required: true93 schema:94 type: integer95 description: X coordinate of the grid96 - name: gridY97 in: path98 required: true99 schema:100 type: integer101 description: Y coordinate of the grid102 responses:103 "200":104 description: Successfully retrieved gridpoint forecast105 content:106 application/json:107 schema:108 type: object109 properties:110 properties:111 type: object112 properties:113 periods:114 type: array115 items:116 type: object117 properties:118 number:119 type: integer120 name:121 type: string122 startTime:123 type: string124 format: date-time125 endTime:126 type: string127 format: date-time128 temperature:129 type: integer130 temperatureUnit:131 type: string132 windSpeed:133 type: string134 windDirection:135 type: string136 icon:137 type: string138 format: uri139 shortForecast:140 type: string141 detailedForecast:142 type: string143```144145146147ChatGPT uses the **info** at the top (including the description in particular) to determine if this action is relevant for the user query.148149```yaml150info:151 title: NWS Weather API152 description: Access to weather data including forecasts, alerts, and observations.153 version: 1.0.0154```155156Then the **parameters** below further define each part of the schema. For example, we're informing ChatGPT that the _office_ parameter refers to the Weather Forecast Office (WFO).157158```yaml159/gridpoints/{office}/{gridX},{gridY}/forecast:160 get:161 operationId: getGridpointForecast162 summary: Get forecast for a given grid point163 parameters:164 - name: office165 in: path166 required: true167 schema:168 type: string169 description: Weather Forecast Office ID170```171172**Key:** Pay special attention to the **schema names** and **descriptions** that you use in this Open API schema. ChatGPT uses those names and descriptions to understand (a) which API action should be called and (b) which parameter should be used. If a field is restricted to only certain values, you can also provide an "enum" with descriptive category names.173174While you can just try the Open API schema directly in a GPT Action, debugging directly in ChatGPT can be a challenge. We recommend using a 3rd party service, like [Postman](https://www.postman.com/), to test that your API call is working properly. Postman is free to sign up, verbose in its error-handling, and comprehensive in its authentication options. It even gives you the option of importing Open API schemas directly (see below).175176<img177 className="images-example-image" src="https://cdn.openai.com/API/images/guides/actions_import.png"178 alt="Choosing to import your API with Postman"179/>180181## Step 2: Identify authentication requirements182183This Weather 3rd party service does not require authentication, so you can skip that step for this Custom GPT. For other GPT Actions that do require authentication, there are 2 options: API Key or OAuth. Asking ChatGPT can help you get started for most common applications. For example, if I needed to use OAuth to authenticate to Google Cloud, I can provide a screenshot and ask for details: _“I’m building a connection to Google Cloud via OAuth. Please provide instructions for how to fill out each of these boxes.”_184185<img186 className="images-example-image" src="https://cdn.openai.com/API/images/guides/actions_oauth_panel.png"187 alt="The above ChatGPT request"188/>189190Often, ChatGPT provides the correct directions on all 5 elements. Once you have those basics ready, try testing and debugging the authentication in Postman or another similar service. If you encounter an error, provide the error to ChatGPT, and it can usually help you debug from there.191192## Step 3: Create the GPT Action and test193194Now is the time to create your Custom GPT. If you've never created a Custom GPT before, start at our [Creating a GPT guide](https://help.openai.com/en/articles/8554397-creating-a-gpt).1951961. Provide a name, description, and image to describe your Custom GPT1972. Go to the Action section and paste in your Open API schema. Take a note of the Action names and json parameters when writing your instructions.1983. Add in your authentication settings1994. Go back to the main page and add in instructions200201202203There are many ways to write successful instructions: the most important thing is that the instructions enable the model to reflect the user's preferences.204205Typically, there are three sections:2062071. _Context_ to explain to the model what the GPT Action(s) is doing2082. _Instructions_ on the sequence of steps – this is where you reference the Action name and any parameters the API call needs to pay attention to2093. _Additional Notes_ if there’s anything to keep in mind210211Here’s an example of the instructions for the Weather GPT. Notice how the instructions refer to the API action name and json parameters from the Open API schema.212213```214**Context**: A user needs information related to a weather forecast of a specific location.215216**Instructions**:2171. The user will provide a lat-long point or a general location or landmark (e.g. New York City, the White House). If the user does not provide one, ask for the relevant location2182. If the user provides a general location or landmark, convert that into a lat-long coordinate. If required, browse the web to look up the lat-long point.2193. Run the "getPointData" API action and retrieve back the gridId, gridX, and gridY parameters.2204. Apply those variables as the office, gridX, and gridY variables in the "getGridpointForecast" API action to retrieve back a forecast2215. Use that forecast to answer the user's question222223**Additional Notes**:224- Assume the user uses US weather units (e.g. Fahrenheit) unless otherwise specified225- If the user says "Let's get started" or "What do I do?", explain the purpose of this Custom GPT226```227228229230### Test the GPT Action231232Next to each action, you'll see a **Test** button. Click on that for each action. In the test, you can see the detailed input and output of each API call.233234<img235 className="images-example-image" src="https://cdn.openai.com/API/images/guides/actions_available_action.png"236 alt="Available actions"237/>238239If your API call is working in a 3rd party tool like Postman and not in ChatGPT, there are a few possible culprits:240241- The parameters in ChatGPT are wrong or missing242- An authentication issue in ChatGPT243- Your instructions are incomplete or unclear244- The descriptions in the Open API schema are unclear245246<img247 className="images-example-image" src="https://cdn.openai.com/API/images/guides/actions_test_action.png"248 alt="A preview response from testing the weather API call"249/>250251## Step 4: Set up callback URL in the 3rd party app252253If your GPT Action uses OAuth Authentication, you’ll need to set up the callback URL in your 3rd party application. Once you set up a GPT Action with OAuth, ChatGPT provides you with a callback URL (this will update any time you update one of the OAuth parameters). Copy that callback URL and add it to the appropriate place in your application.254255<img256 className="images-example-image" src="https://cdn.openai.com/API/images/guides/actions_bq_callback.png"257 alt="Setting up a callback URL"258/>259260## Step 5: Evaluate the Custom GPT261262Even though you tested the GPT Action in the step above, you still need to evaluate if the Instructions and GPT Action function in the way users expect. Try to come up with at least 5-10 representative questions (the more, the better) of an **“evaluation set”** of questions to ask your Custom GPT.263264**Key:** Test that the Custom GPT handles each one of your questions as you expect.265266An example question: _“What should I pack for a trip to the White House this weekend?”_ tests the Custom GPT’s ability to: (1) convert a landmark to a lat-long, (2) run both GPT Actions, and (3) answer the user’s question.267268<img269 className="images-example-image" src="https://cdn.openai.com/API/images/guides/actions_prompt_2_actions.png"270 alt="The response to the above ChatGPT request, including weather data"271/>272<img273 className="images-example-image" src="https://cdn.openai.com/API/images/guides/actions_output.png"274 alt="A continuation of the response above"275/>276277## Common Debugging Steps278279_Challenge:_ The GPT Action is calling the wrong API call (or not calling it at all)280281- _Solution:_ Make sure the descriptions of the Actions are clear - and refer to the Action names in your Custom GPT Instructions282283_Challenge:_ The GPT Action is calling the right API call but not using the parameters correctly284285- _Solution:_ Add or modify the descriptions of the parameters in the GPT Action286287_Challenge:_ The Custom GPT is not working but I am not getting a clear error288289- _Solution:_ Make sure to test the Action - there are more robust logs in the test window. If that is still unclear, use Postman or another 3rd party service to better diagnose.290291_Challenge:_ The Custom GPT is giving an authentication error292293- _Solution:_ Make sure your callback URL is set up correctly. Try testing the exact same authentication settings in Postman or another 3rd party service294295_Challenge:_ The Custom GPT cannot handle more difficult / ambiguous questions296297- _Solution:_ Try to prompt engineer your instructions in the Custom GPT. See examples in our [prompt engineering guide](https://developers.openai.com/api/docs/guides/prompt-engineering)298299This concludes the guide to building a Custom GPT. Good luck building and leveraging the [OpenAI developer forum](https://community.openai.com/) if you have additional questions.