ChatGPT Plugin Example: Live Weather
This is a simple ChatGPT plugin example that uses
Autocode's built-in Weather API
to produce a live weather plugin.

How does it work?
Autocode automatically generates a /.well-known/ai-plugin.json
file for you
based on the contents of the "plugin"
field of stdlib.json
, which can be
edited from within the Autocode editor. In this case;
"plugin": {
"name": "My Weather Plugin",
"description": "Retrieves current weather forecast for a location"
}
Turns into;
{
"schema_version": "v1",
"name_for_human": "My Weather Plugin",
"name_for_model": "My_Weather_Plugin",
"description_for_human": "Retrieves current weather forecast for a location",
"description_for_model": "Retrieves current weather forecast for a location",
"auth": {
"type": "none"
},
"api": {
"type": "openapi",
"url": "https://dev--weather-plugin--openai.api.stdlib.com/.well-known/openapi.yaml"
},
"logo_url": "https://dev--weather-plugin--openai.api.stdlib.com/logo.png",
"contact_email": "noreply@dev--weather-plugin--openai.api.stdlib.com",
"legal_info_url": "https://dev--weather-plugin--openai.api.stdlib.com/tos.txt"
}
Additionally, all API endpoints built in your Autocode project get OpenAPI
schemas automatically generated at /.well-known/openapi.yaml
. For this project,
the endpoint:
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
/**
* Retrieve current weather forecast for a location
* @param {float} latitude Latitude of the location
* @param {float} longitude Longitude of the location
* @returns {object}
*/
module.exports = async (latitude, longitude) => {
let result = await lib.weather.forecast['@0.0.1'].current({
latitude: latitude,
longitude: longitude,
units: `imperial`
});
return result;
};
Generates a spec of:
openapi: "3.1.0"
info:
version: "dev"
title: "My Weather Plugin"
description: "Retrieves current weather forecast for a location"
servers:
- url: "https://dev--weather-plugin--openai.api.stdlib.com"
description: "Autocode Standard Library"
paths:
/:
post:
description: "Retrieve current weather forecast for a location"
operationId: "openai_weather_plugin"
requestBody:
content:
application/json:
schema:
type: "object"
properties:
latitude:
type: "number"
description: "Latitude of the location"
longitude:
type: "number"
description: "Longitude of the location"
required:
- "latitude"
- "longitude"
responses:
200:
content:
application/json:
schema:
type: "object"
properties: {}
Connecting to ChatGPT
Connecting to ChatGPT is easy. Just go to the plugin store,
select "Develop your own plugin", and paste the link to your Autocode project.
Good luck!
Thank You!
We hope you found this guide useful. If you have questions or comments, feel free
to let us know by joining our community Discord server.
Happy hacking!