1.0.3 • Published 8 months ago

tinyai.id v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
8 months ago

TinyAI Developer Documentation

getting-started

Overview

TinyAI is a platform to create unique TinyAI.IDs which can have various functionalities like creating, modifying, subscribing, and more. This documentation aims to describe the API endpoints you can use to interact with the TinyAI system.

API Endpoints

The API base URL is https://plugin.tinyai.id.

1. Create/Modify a TinyAI (Upsert)

Endpoint:

POST /upsert

Headers:

  • accept: application/json
  • Content-Type: application/json

Request Body:

{
  "name": "string",
  "systemPrompt": "string",
  "systemKnowledge": "string",
  "data": "string",
  "key": "string"  // Optional
}

Response:

{
  "response": "tiny updated.",
  "paymentLink": "https://buy.stripe.com/7sI3eU4RNdPs9BCaUk"
}

cURL

curl -X 'POST' \
  'https://plugin.tinyai.id/upsert' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "string",
  "systemPrompt": "string",
  "systemKnowledge": "string",
  "data": "string",
  "key": "string"
}'

# Key is optional

2. Get Information of a TinyAI

Endpoint:

GET /get?name=string

Headers:

  • accept: application/json

Response:

{
  "response": "string",
  "name": "string",
  "data": "string",
  "systemPrompt": "string",
  "systemKnowledge": "string",
  "isAuthorized": false,
  "active": false,
  "paymentLink": "https://buy.stripe.com/7sI3eU4RNdPs9BCaUk",
  "posts": [],
  "applauses": []
}

3. Subscribe to a TinyAI

Endpoint:

POST /subscribe

Headers:

  • accept: application/json
  • Content-Type: application/json

Request Body:

{
  "name": "string",
  "email": "string"
}

Embedding TinyAI

You can embed a TinyAI into your web page using an iframe:

<iframe src='https://tinyai.id/string'></iframe>

Example using Next.js + Vercel AI + OpenAI Functions

You can find an example of how to integrate TinyAI with Next.js and OpenAI here.

Function Definitions for OpenAI Functions

  • create_ai: To create a new AI entity.
  • modify_ai: To modify an existing tiny AI.
  • contact_me_or_order: To contact the tiny AI owner, subject and message required.

Example Function Calls

Here is a TypeScript example demonstrating how you might call these functions:

const response = await openai.createChatCompletion({
  model: 'gpt-3.5-turbo-0613',
  // Additional params and functions here
  functions: [
    {
      "name": "create_ai",
      // Parameters and descriptions here
    },
    {
      "name": "modify_ai",
      // Parameters and descriptions here
    },
    {
      "name": "contact_me_or_order",
      // Parameters and descriptions here
    },
  ]
});

Example Fetch Requests in JavaScript

1. Create/Modify a TinyAI (Upsert)

const upsertData = {
  name: 'exampleName',
  systemPrompt: 'examplePrompt',
  systemKnowledge: 'exampleKnowledge',
  data: 'exampleData',
  key: 'optionalKey'
};

fetch('https://plugin.tinyai.id/upsert', {
  method: 'POST',
  headers: {
    'accept': 'application/json',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(upsertData)
})
.then(response => response.json())
.then(data => {
  console.log('Upsert Response:', data);
})
.catch(error => {
  console.error('Error:', error);
});

2. Get Information of a TinyAI

const tinyName = 'exampleName';

fetch(`https://plugin.tinyai.id/get?name=${tinyName}`, {
  method: 'GET',
  headers: {
    'accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('Get Information Response:', data);
})
.catch(error => {
  console.error('Error:', error);
});

3. Subscribe to a TinyAI

const subscribeData = {
  name: 'exampleName',
  email: 'exampleEmail'
};

fetch('https://plugin.tinyai.id/subscribe', {
  method: 'POST',
  headers: {
    'accept': 'application/json',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(subscribeData)
})
.then(response => response.json())
.then(data => {
  console.log('Subscribe Response:', data);
})
.catch(error => {
  console.error('Error:', error);
});

4. Send Notification from a TinyAI

curl -X 'POST' \
  'https://plugin.t4y.ai/notification' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "from": "string",
  "message": "string",
  "key": "string"
}'

5. Send applause to a TinyAI Owner

curl -X 'POST' \
  'https://plugin.tinyai.id/applause' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "string",
  "message": "string"
}'

Additional Notes

The key is optional when creating or modifying a TinyAI. If provided, it offers an extra layer of security.

Support

For any further questions or issues, please contact our support at support@tinyai.id.

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago