---
title: LLaMA 3 API Usage Guide
slug: llama-3-api-usage-guide
docTags: 
createdAt: 2025-01-07T10:18:52.171Z
---

## 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

:::BlockQuote
import \{ AI, AIOptions } from 'aonweb';
:::

### 2. Initialize AI Instance

:::BlockQuote
const ai\_options = new AIOptions(\{
&#x20;   appId: 'your\_app\_id\_here',
&#x20;   dev\_mode: true
});

const aonweb = new AI(ai\_options);
:::

### 3. Prepare Input Data Example

:::BlockQuote
const data = \{
&#x20;  input:\{
&#x20;       "top\_p": 1,
&#x20;       "prompt": "Plan a day of sightseeing for me in San Francisco.",
&#x20;       "temperature": 0.75,
&#x20;       "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.",
&#x20;       "max\_new\_tokens": 800,
&#x20;       "repetition\_penalty": 1
&#x20;   }
};
:::

### 4. Call the AI Model

:::BlockQuote
const price = 8; // Cost of the AI call
try \{
&#x20;   const response = await aonweb.prediction("/predictions/ai/lllama3:0.0.8", data, price);
&#x20;   // Handle response
&#x20;   console.log("IDM-VTON Response:", response);
} catch (error) \{
&#x20;   // Error handling
&#x20;    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.
