Full API Reference (For Advanced Users)
This section provides a detailed reference for interacting directly with the APUS AI Router Process. This is for advanced users who choose not to use the@apus/ai library. All interactions are standard AO messages.
Purchasing Credits with $APUS
Environment: This operation is performed on the AO Legacy Network.
aos your_process
To purchase Credits, you perform a standard Transfer to the $APUS token process, with the Recipient tag pointing to our Router Process.
- Target:
mqBYxpDsolZmJyBdTK8TJp_ftOuIUXVYcSQ8MYZdJg0(APUS Token Process ID) - Action:
Transfer
| Tag | Type | Required | Description |
|---|---|---|---|
Action | string | Yes | Must be "Transfer". |
Recipient | string | Yes | The AI-Infer Router Process ID: TED2PpCVx0KbkQtzEYBo0TRAO-HPJlpCMmUzch9ZL2g |
| `. | |||
Quantity | string | Yes | The amount of $APUS tokens to transfer. The credits you receive will be based on the current exchange rate. |
X-Reason | string | Yes | Must be Buy-Credits to indicate the purpose of the transfer. |
AI Inference Request
To initiate an AI inference, send a message directly to our Router Process.- Target: TED2PpCVx0KbkQtzEYBo0TRAO-HPJlpCMmUzch9ZL2g ` (AI-Infer Router Process ID)
- Action:
Infer
| Tag | Type | Required | Description |
|---|---|---|---|
Action | string | Yes | Must be "Infer". |
Data | string | Yes | The text prompt to send to the AI model. |
X-Prompt | string | No | [Deprecated] The text prompt to send to the AI model. |
X-Reference | string | No, but recommended! | A unique identifier for your request. If omitted, the message’s own ID will be used. It’s highly recommended for tracking responses. |
X-Session | string | No | An existing session ID to continue a conversation. If omitted, a new session is created. |
X-Options | json | No | A JSON string containing runtime parameters to customize the inference. See the table below for available options. |
X-Options JSON Parameters:
These parameters allow you to control the behavior of the Gemma3-27B model for each request.
| Parameter | Type | Default | Range | Description |
|---|---|---|---|---|
temperature | float | 0.7 | 0.0 - 2.0 | Controls randomness. Lower values are more deterministic, higher values are more creative. |
top_p | float | 0.9 | 0.0 - 1.0 | Nucleus sampling. The model considers only the tokens with the highest probability mass. |
max_tokens | integer | 2048 | 1 - 8192 | The maximum number of tokens to generate in the response. |
AI Inference Response
To get the response of your AI inference, handle message send by our Router Process. Example Lua Handler:| Tag | Type | Description |
|---|---|---|
Action | string | "Infer-Response" |
Data | json | Response of AI Inference in json format. |
Data.attestation | string | GPU attestation report. |
Data.result | string | AI Inference result. |
X-Session | string | The session id you passed in. |
X-Reference | string | The reference id you passed in, you not provided, generated automatically. |
| Tag | Type | Description |
|---|---|---|
Action | string | "Infer-Response" |
Code | string | Error code. |
X-Reference | string | Error message. |
Patch API (Read-Only State via patch@1.0)
Brief Intro: Patch API is introduced by HyperBEAM for improves performance for web frontends and data services by replacing the need forOur Router Process uses HyperBEAM’sdryruncalls, which were a known bottleneck onlegacynet. Prerequisites: Please read https://cookbook_ao.arweave.net/guides/migrating-to-hyperbeam/exposing-process-state.html to learn how to migrate to HyperBEAM.
patch@1.0 device to expose its internal state for efficient, read-only access over HTTP. This is the best way to monitor your tasks and credits without sending messages.
- Base URL:
http://72.46.85.207:8734/{Router_Process_ID}~process@1.0/now/cache/ - Router Process ID: TED2PpCVx0KbkQtzEYBo0TRAO-HPJlpCMmUzch9ZL2g `
- /credits/: Get the current credit balance for a specific process.
- Example:
.../now/cache/credits/UIpgvCAjEajkAwH7qAAun0ybS3awepNO_kXa70cTZoU
- Example:
- /tasks/: Get the status and details of a specific inference task. The
task_referenceis{client_process_id}-{user_reference}.-
Example:
.../now/cache/tasks/UIpgvCAjEajkAwH7qAAun0ybS3awepNO_kXa70cTZoU-1721644800 -
Response Structure (
taskobject):
-
Example:
- /taskStats: Get real-time statistics for the entire service.
- Example:
.../now/cache/taskStats - Response Structure:
{ "total_tasks": 150, "pending": 10, "processing": 5, "successed": 130, "failed": 5 }
- Example: