Skip to content

RobertHH-IS/Vercel-GPTs-APIs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vercel-GPTs-APIs

A template for Vercel APIs to utilize with GPTs

Vercel API Template for OpenAI GPT Models

This repository contains a template for setting up a Vercel API using Python to interact with OpenAI's GPT models. The template provides a basic structure to build, deploy, and run a scalable API for integrating GPT-powered features into your applications.

Features

  • Python-based API setup.
  • Integration with OpenAI GPT models.
  • Scalable architecture suitable for Vercel deployment.

Account Setup

Before you can utilize this Vercel API template with OpenAI's GPT models, you need to set up accounts on GitHub, Vercel, and have a ChatGPT Plus account with OpenAI.

Creating a GitHub Account

  1. Go to GitHub.
  2. Click on 'Sign up'.
  3. Fill in the registration form with your details.
  4. Verify your email address to complete the account setup.

Creating a Vercel Account

  1. Visit Vercel's website.
  2. Click 'Sign Up'.
  3. You can sign up using your GitHub account or with an email address.
  4. Follow the on-screen instructions to complete the setup.

Getting ChatGPT Plus Account with OpenAI

  1. Go to OpenAI's website.
  2. Sign up for an account if you don't already have one.
  3. Upgrade to ChatGPT Plus for access to the GPT API.
  4. Once you have the Plus account, navigate to the API section and generate an API key.

Installation and Setup

After setting up your accounts, follow these steps to install Visual Studio Code, download the repository, and prepare your API.

Install Visual Studio Code (VS Code)

  1. Go to the Visual Studio Code website.
  2. Download the version appropriate for your operating system (Windows, MacOS, Linux).
  3. Follow the installation instructions for your operating system.

Download the Repository to Your Local Drive

  1. Navigate to the GitHub repository in your web browser.
  2. Click on the 'Code' button and then choose 'Download ZIP'.
  3. Once downloaded, extract the ZIP file to your desired location on your local drive.

Open the Project in VS Code

  1. Right-click on the project directory (the folder where you extracted the repository).
  2. Select 'Open with VS Code'.

Prepare the API Template

  1. In VS Code, open the api directory in the project.
  2. Locate and open the main.py file.

Utilize ChatGPT for API Development

  1. Copy the contents of main.py.
  2. Consult ChatGPT, providing the copied code, and describe the specific API functionality you wish to develop.
    • For example, "Here's a Python template for a Vercel API. I want to create an API that does X, Y, and Z. Can you help modify this template?"

Updating Your GitHub Repository

After developing and testing your API, the next step is to update your GitHub repository with your latest code. GitHub Desktop provides a user-friendly interface to manage your repositories. Here are the steps to initialize your project as a Git repository, commit your changes, and push them to GitHub using GitHub Desktop.

Install GitHub Desktop

  1. Go to the GitHub Desktop website.
  2. Download the version appropriate for your operating system (Windows or MacOS).
  3. Follow the installation instructions for your operating system.

Creating a New Repository in GitHub Desktop

  1. Open GitHub Desktop.
  2. Click on 'File', then select 'New Repository'.
  3. Fill in the details for your new repository, such as 'Name', 'Local Path', and 'Description'.
  4. Make sure to select 'Initialize this repository with a README'.
  5. Click 'Create Repository' to create your new repository.

Copying the Template Repository into Your New Repository

  1. Open the folder where you extracted the Vercel API template.
  2. Copy all the files and folders from this template directory.
  3. Navigate to the local directory of the new repository you created in GitHub Desktop.
  4. Paste all the copied files from the template into this directory.

Committing and Pushing Changes with GitHub Desktop

  1. Open GitHub Desktop; it should automatically detect the changes in your repository.
  2. In the left-hand sidebar, you'll see a list of changed files. Review these to ensure they are the correct changes you want to commit.
  3. At the bottom, provide a summary of the changes in the 'Summary' field and optionally a more detailed description in the 'Description' field.
  4. Click 'Commit to main' to stage your changes.
  5. Once committed, click 'Publish repository' or 'Push origin' to push your changes to the remote GitHub repository.

Linking to Vercel

  1. Go to Vercel's website and log in to your account.
  2. On the Vercel dashboard, click on 'New Project'.
  3. Vercel will prompt you to import a project from GitHub. Click 'Import' next to the repository you want to deploy.
  4. If you're linking to Vercel for the first time, you may need to install the Vercel for GitHub integration and authorize Vercel to access your GitHub account.

Configuring Your Project on Vercel

  1. After selecting your repository, you'll be taken to the 'Import Project' page.
  2. Here, you can configure your project settings. For most Python-based APIs, the default settings should work fine.
  3. Set the 'Framework Preset' to 'Other' or the specific framework if it's listed.
  4. You can also configure environment variables if your project requires them under the 'Environment Variables' section.

Deploying Your Project

  1. Once you've configured your project settings, click on the 'Deploy' button at the bottom of the page.
  2. Vercel will then begin the deployment process. You can monitor the progress in the 'Deployments' tab of your Vercel dashboard.
  3. When the deployment is complete, Vercel will provide a URL where your deployed project is accessible.

Creating an OpenAPI Schema for Your API

After deploying your API on Vercel, the next step is to create an OpenAPI schema. This schema will help in defining the endpoints, parameters, and responses of your API in a standardized format. Here's how you can create an OpenAPI schema for the Stock Data API.

Step 1: Define the OpenAPI Schema

  1. Start by defining the basic structure of your OpenAPI schema as follows:

    {
      "openapi": "3.1.0",
      "info": {
        "title": "Stock Data API",
        "description": "Retrieves open, high, low, and close prices of a specified stock symbol.",
        "version": "v1.0.0"
      },
      "servers": [
        {
          "url": "https://vercel-api-stock-ticker.vercel.app/"
        }
      ],
      "paths": {
        "/{symbol}": {
          "get": {
            "description": "Get stock data for a specific symbol",
            "operationId": "GetStockData",
            "parameters": [
              {
                "name": "symbol",
                "in": "path",
                "description": "The stock symbol to retrieve data for (e.g., 'AAPL' for Apple Inc.)",
                "required": true,
                "schema": {
                  "type": "string"
                }
              }
            ],
            "responses": {
              "200": {
                "description": "Successful response",
                "content": {
                  "application/json": {
                    "schema": {
                      "$ref": "#/components/schemas/StockData"
                    }
                  }
                }
              },
              "404": {
                "description": "Data not found for the given symbol"
              }
            },
            "deprecated": false
          }
        }
      },
      "components": {
        "schemas": {
          "StockData": {
            "type": "object",
            "properties": {
              "symbol": {
                "type": "string",
                "description": "Stock symbol"
              },
              "open": {
                "type": "number",
                "format": "float",
                "description": "Opening price"
              },
              "high": {
                "type": "number",
                "format": "float",
                "description": "Highest price during the day"
              },
              "low": {
                "type": "number",
                "format": "float",
                "description": "Lowest price during the day"
              },
              "close": {
                "type": "number",
                "format": "float",
                "description": "Closing price"
              }
            }
          }
        }
      }
    }
    
    Replace the content of the schema.txt file in your project with the above JSON schema.

####Step 2: Using ChatGPT to Create a New GPT with the Schema Go back to the ChatGPT interface. Click on 'Explore' in ChatGPT. Choose 'Create new GPT'. Click on 'Add Action'. Paste the entire OpenAPI schema into the input box.

Now your API is ready!

About

A template for Vercel APIs to utilize with GPTs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages