Learn how to use the APUS AI Lua library for simplified AI inference
@apus/ai
Lua library. It handles all the complex messaging and payment details for you, so you can call the AI in a single line of code.
#hackathon-credits
channel.aos
process ID to receive your free credits.aos
terminal, load the @apus/ai
library into your process. We recommend using a package manager like apm
. If you don’t have it, first run .load-blueprint apm
.
@apus/ai
Lua Library@apus/ai
library offers more control over the inference process through advanced options and callbacks.
aos
process.
ApusAI.infer(prompt, options, callback)
prompt
(string
): Required. The text prompt you want to send to the AI model.options
(table
): Optional. A table of parameters to customize the inference request.
session
(string
): An existing session ID to continue a previous conversation. If a session ID is not provided, a new one will be created for the first turn.reference
(string
): A custom unique ID for your request. If omitted, the library generates one automatically. This is useful for tracking your requests.temperature
, max_tokens
, etc.)callback(err, res)
(function
): Optional. A function that will be called with the result.
err
is present, it will be a table containing error details (e.g., { message = "Insufficient credits" }
).
res
will be a table containing the response:
string
: The unique reference
ID for the request, which can be used for tracking.ApusAI.setRouter(routerProcess)
routerProcess
(string
): The new AO Process ID to use as the router.