Google API directions doesn't work at all with GPT assistant

74 views Asked by At

I'm a low experience user so be patient with me please. I'm trying to create a GPT assistant to help me in my work and I need it to have access to Google Direction API to calculate distance between point A and B (I work in a logistic company).

So I've created my code (using a GPT Action Assistant) to access to the API:

info:
  title: Google Maps Directions API Custom Wrapper (With API Key)
  description: API to retrieve driving directions using Google Maps Platform.
  version: 1.0.0
servers:
  - url: https://maps.googleapis.com/maps/api/directions
    description: Google Maps Directions API server
paths:
  /json:
    get:
      operationId: getDirectionsFromIncubatoioToDestination
      summary: Get driving directions from Forlì to a specified destination.
      parameters:
        - name: destination
          in: query
          required: true
          description: Destination address.
          schema:
            type: string
        - name: origin
          in: query
          required: true
          description: Fixed origin address (Forlì).
          schema:
            type: string
            default: Forlì
        - name: key
          in: query
          required: true
          description: Your Google Maps Platform API key.
          schema:
            type: string
            default: YOUR_ACTUAL_API_KEY
      responses:
        "200":
          description: Successful response with directions.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  routes:
                    type: array
                    items:
                      type: object
                      properties:
                        summary:
                          type: string
                        legs:
                          type: array
                          items:
                            type: object
                            properties:
                              distance:
                                type: object
                                properties:
                                  text:
                                    type: string
                                  value:
                                    type: integer
                              duration:
                                type: object
                                properties:
                                  text:
                                    type: string
                                  value:
                                    type: integer
                              end_address:
                                type: string
                              start_address:
                                type: string
                              steps:
                                type: array
                                items:
                                  type: object

After that I went to Google Cloud and create my project. In the dashboard I've went to API and Libraries, clicked on DirectionAPI and enabled it.

The first weird part occurs after that. When I go back to my API and Services view in the console I find the DirectionAPI DISABLED and if I click to Enable it, it enables but in the notification bell it says it's disabled (no idea why!????) I create my APIKey and go back to GPT.

I paste my key into the authentication area of the GPT Builder and if I test it I get this error:

{
  "domain": "maps.googleapis.com",
  "method": "get",
  "path": "/json",
  "operation": "getDirectionsFromIncubatoioToDestination",
  "operation_hash": "eec1196d2cb02d763554336f2992883cda86a118",
  "is_consequential": false,
  "params": {
    "destination": "VIA DELLA SEGA,6 - FONTIGO DI SERNAGAGLIA DELLA BATTAGLIA (TV)",
    "origin": "Incubatoio Faentino Forlì",
    "key": "YOUR_API_KEY"
  }
}
[debug] Response received
{
  "response_data": {
    "error_message": "The provided API key is invalid. ",
    "routes": [],
    "status": "REQUEST_DENIED"
  },
  "status_code": 200,
  "action_id": "g-b95e704cd746d14f88df8964141c60edf3412748"
}

I've tried some help from Gemini but was pointless, tried some help with GPT itself but everything tells me back to check my API key and to see if the service is enabled.

But here the service is enabled: But here the service is enabled

While here in italian it's says that the service is disabled While here it's says in Italian that's disabled

I have no idea what to do next. Thank you for every help provided.

Edit: Sorry I forgot to add that I've replaced YOUR_ACTUAL_API_KEY with my APIkey Aizaxxxx...

1

There are 1 answers

1
JimmyP On

If the box says 'ENABLE' is it disabled, if the box says 'DISABLE' it is enabled.

Try clicking the box until it says 'DISABLE'

ENABLE is imperative

ENABLED is a state.

Try the above.