/aiapi.cache

A caching & convenience proxy over openai chat api

Primary LanguageTypeScript

https://aiapi.cash

AI API 💵

This is an API to help developers use OpenAI with caching.

Proxy/Post Mode

Proxy mode mirrors the OpenAI chat API and adds caching.

curl -s -X POST --json '{
    "model": "gpt-3.5-turbo",
    "messages": [ { "role": "system", "content": "who is the leader of Cambodia. just output the name" } ]
}'   "https://aiapi.cash/"

Response:

{
  "id": "12345",
  "object": "chat.completion",
  "created": "00000000",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hun Sen"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0
  }
}

GET Mode

Proxy mode is any get request to this api This mode attempts to use the file extension to determine mime type, we generate three versions and try to parse out the valid file format

Example 1: package.json

https://aiapi.cash/node package myexampleproject with express, zod, express-session, typescript.json

Example 3: html file

https://aiapi.cash/american presidents from 1820 to 1900 as table include name (with link to wikipedia), birthplace, years served and political party.html

Example 3: Typescript code

https://aiapi.cash/output zod types to parse reddits subreddit api.ts