Development Guide
Last updated
Last updated
AI Oracle is a pull-based oracle. This means users will get one response (an AI inference result) from one request (one prompt) on-demand. Our new batch mint feature enables one request to return multiple AI inference results in one response.
Initiate Request: The user contract sends an inference request to AI Oracle by calling the requestCallback
function.
opML Request: AI Oracle creates an opML request based on the user contract request.
Event Emission: AI Oracle emits a requestCallback
event collected by the opML node.
ML Inference: The opML node performs the AI model computation.
Result Submission: The opML node uploads the result on-chain.
Callback Execution: The result is dispatched to the user's smart contract via a callback function.
Challenge Window: Begins after the result is submitted on-chain (step 5 above).
Verification: opML validators or any network participant can check the results and challenge the output if it is incorrect.
Result Update: If a challenge is successful, the incorrect result is updated on-chain.
Finality: After the challenge period, the result is finalized onchain and made immutable.
To connect your smart contract with AI Oracle:
Inherit AIOracleCallbackReceiver
in your contract and bind with a specific AI Oracle address:
Write your callback function to handle the inference result from AI Oracle. Note that only the AI Oracle can call this function:
When you want to initiate an AI inference request, call AI Oracle as follows:
Usage of AI Oracle requires a fee for each request. You can request the current fee by:
Call to read estimateFee
in AI Oracle or your integrated contract with the specific model ID
You’ll receive back the estimated fee in wei
Call to write and request the AI inference on your contract, filling in the estimated fee in ether
Source code of AI Oracle: https://github.com/ora-io/OAO
For supported models and deployment addresses, see Reference page.
For example integrations and ideas to build, see awesome-ora.
Check out video tutorial on interacting and building with AI oracle.