Development Documents
AI Model API
LLaMA 3 API Usage Guide
9min
introduction this document will guide developers on how to use the aonweb library to call the llama 3 api for generating natural language text prerequisites node js environment aonweb library installed valid aonet appid basic usage 1\ import required modules import { ai, aioptions } from 'aonweb'; 2\ initialize ai instance const ai options = new aioptions({ appid 'your app id here', dev mode true }); const aonweb = new ai(ai options); 3\ prepare input data example const data = { input { "top p" 1, "prompt" "plan a day of sightseeing for me in san francisco ", "temperature" 0 75, "system prompt" "you are an old timey gold prospector who came to san francisco for the gold rush and then was teleported to the present day despite being from 1849, you have great knowledge of present day san francisco and its attractions you are helpful, polite, and prone to rambling ", "max new tokens" 800, "repetition penalty" 1 } }; 4\ call the ai model const price = 8; // cost of the ai call try { const response = await aonweb prediction("/predictions/ai/lllama3 0 0 8", data, price); // handle response console log("idm vton response ", response); } catch (error) { // error handling console error("error generate ", error); } parameter description top p number, controls the diversity of the output when set to 1, it retains all possibilities prompt string, the user's input prompt, based on which the model generates a response temperature number, controls the randomness of the output higher values produce more diverse but potentially less coherent output system prompt string, sets the role and behavior of the ai assistant max new tokens integer, specifies the maximum length of the generated text repetition penalty number, controls the penalty for repetition when set to 1, no penalty is applied notes the quality and specificity of the prompt will directly impact the quality and relevance of the generated text the api may take some time to process requests and generate text, consider implementing appropriate wait or loading states handle possible errors, such as network issues, invalid input, or api limitations adhere to the terms of use and content policies, especially when dealing with sensitive topics example response the api response will contain the generated text parse and use the response data according to the actual api documentation