Initializing the class
ai = purai.PurAI(token, dev = True)
API Reference
Initialize the PurAI class with a token and an optional development mode flag.
tokenRequired (str): The API token for authentication!devOptional (bool): If set toTrue, the package will return the full JSON response from the request. IfFalse(default), it will return important information or an error. More info here.
Code sample
main.py
import purai
ai = purai.PurAI(token, dev = False)
ai.test()Dev mode
With dev mode enabled, the reseponse is the full JSON from the API (the same you would get from just sending a post request). With it disabled, only the actual response that you most likely want will be returned.
response.json
{
"id":"chatcmpl-89kNMZO60vCNlG8aKxNF8CjuM1NwF",
"object":"chat.completion",
"created":1697333912,
"model":"gpt-3.5-turbo-16k-0613",
"choices":[
{
"index":0,
"message":{
"role":"assistant",
"content":"Why did the computer laugh when the request returned a 200?\n\nBecause it finally got the punchline: \"The server said, \\'I\\'m good, thanks for asking!\\'.\""
},
"finish_reason":"stop"
}
],
"usage":{
"completion_tokens":36,
"prompt_tokens":19,
"total_tokens":55
},
"provider":"NagaAI",
"cache":[...]
}