API Agent Guide

API Agent Guide

For this guide, we will make an agent that works against the OpenAPI spec for https://jsonplaceholder.typicode.com/guide/.

You can download the OpenAPI spec here: https://arnu515.github.io/jsonplaceholder-api-docs/

Steps

  1. Go to https://apitoagent.com/
  2. Upload the JSON OpenAPI spec
  3. Download the zip / unzip
  4. Open it in an editor of your choice

Setting Up

  1. Add your OpenAI key to the .env file
  2. Run pnpm install, yarn install, or npm install
  3. Edit the index.ts file and add your API URL (https://jsonplaceholder.typicode.com)

import { createApiClient, getGraphAndRun } from './core';

import dotenv from 'dotenv';
dotenv.config();

const client = createApiClient("https://jsonplaceholder.typicode.com", {
  axiosConfig: {

  }
});

(async () => {
   const out = await getGraphAndRun(client, 'list posts');
})();

        

Running the Script

Run ts-node src/index.ts

Explore the Core

When you are done, head over to src/core.ts to see how the magic happens. :) Happy building!