PurAI is SHUT DOWN. This website is purely for archival purposes. No such services exist anymore.
Packages
Methods

purai.py Methods

Testing

test()

Test the API by recieving a test message. The AI will respond and tell a funny joke if it is online.

Returns

  • (dict or str): If in development mode (dev=True), returns the full JSON response or an error message. Otherwise, returns the AI's response or an error message.

Generate

generate(prompt, provider="openai", beta=False)

Generate individual text based on a prompt.

API Reference

  • prompt Required (str): The text prompt for the AI.
  • provider Optional (str): The provider for text generation (default is "openai").
  • beta Optional (bool): Whether to use the beta version (default is False).

Code sample

main.py
import purai
 
ai = purai.PurAI(token, dev = False)
 
print(ai.generate("hi!"))

Chat

chat(messages, provider="openai", beta=False)

Engage in a chat conversation with AI.

API Reference

  • messages Required (list): List of message objects for the conversation. (Same formatting as with OpenAI's package!)
  • provider Optional (str): The provider for chat completion (default is "openai").
  • beta Optional (bool): Whether to use the beta version (default is False).

Code sample

main.py
import purai
 
ai = purai.PurAI(token, dev = False)
 
messages = { "role": "user", "content": "Hello! How are you?" }
 
print(ai.chat(messages))

Document Analysis

document_analysis(document_url: str, prompt: str, beta=False)

Analyze documents or images with AI.

API Reference

  • document_url Required (str): The URL of the document or image to analyze.
  • prompt Required (str): A prompt for the analysis.
  • beta Optional (bool): Whether to use the beta version (default is False).

Code sample

main.py
import purai
 
ai = purai.PurAI(token, dev = False)
 
print(ai.document_analysis(document_url = "https://online.visual-paradigm.com/repository/images/4367fbb4-b023-4e4f-b910-8db451358a3b/recipe-cards-design/simple-pancake-recipe-card.png", prompt = "What's the first step?"))

Contend Moderation

moderations(prompt, beta=False)

Perform content moderation on text and analyze its safety.

API Reference

  • prompt Required (str): The text to be moderated.
  • beta Optional (bool): Whether to use the beta version (default is False).

Code sample

main.py
import purai
 
ai = purai.PurAI(token, dev = False)
 
print(ai.moderations(prompt = "Hello, there idiot!"))

Image Generation

image(prompt, provider="openai", beta=False)

Generate images based on a text prompt.

API Reference

  • prompt Required (str): The text prompt for image generation.
  • provider Optional (str): The provider for image generation (default is "openai").
  • beta Optional (bool): Whether to use the beta version (default is False).

Code sample

main.py
import purai
 
ai = purai.PurAI(token, dev = False)
 
print(ai.image("A yellow duck walking around the street with a bird as a pet"))

Audio Transcription

transcribe(file_url, beta=False)

Transcribe an audio file from its URL.

API Reference

  • file_url Required (str): The URL of the audio file.
  • beta Optional (bool): Whether to use the beta version (default is False).

Code sample

main.py
import purai
 
ai = purai.PurAI(token, dev = False)
 
print(ai.transcribe("https://some.audio/file.mp3"))

Audio Translation

translate(file_url, beta=False)

Translate an audio file from its URL.

API Reference

  • file_url Required (str): The URL of the audio file.
  • beta Optional (bool): Whether to use the beta version (default is False).

Code sample

main.py
import purai
 
ai = purai.PurAI(token, dev = False)
 
print(ai.translate("https://file.audio/some.mp3"))

Custom

custom(owner, endpoint, body, subdomain)

Use a premade API endpoint within the PurAI project that isn't listed here (usually for beta stuff).

API Reference

  • owner Required (str): The owner/provider of the custom endpoint.
  • endpoint Required (str): The custom endpoint to call.
  • body Required (dict): The request body as a dictionary.
  • subdomain Required (str): The subdomain to use for the custom request.

Code sample

This example is demonstrating the fact that, when the roleplay endpoint was in beta, you were still able to access it using this package even though it isn't one of the methods above. The endpoint and subdomain args in the example below (/v1/characters/someId/chat/completions & rp, respectively) were the indication where, within the ai.purlabs.xyz domain, you would to access the roleplay API (https://rp.ai.purlabs.xyz//v1/characters/someId/chat/completions).
main.py
import purai
 
ai = purai.PurAI(token, dev = False)
 
body = {
  "model": "gpt-3.5-turbo",
  "messages": [
    {
      "role": "user",
      "content": "Hello! How are you?"
    }
  ]
}
 
print(ai.custom("openai", "/v1/characters/someId/chat/completions", body, "rp"))