Eternal AI
  • The AI layer for the new internet
  • eternals
    • What are Eternals?
    • Specification
    • Proof-of-Compute
  • The new internet, AI-powered
    • Bitcoin, AI-powered
      • Eternals on Bitcoin
      • BitAI Virtual Machine
      • Run a BitAI node
    • Ethereum, AI-powered
    • Solana, AI-powered
  • smart contracts, ai-powered
    • How to use onchain LLM
    • Onchain AI composability - AI Powered Wallet
    • Onchain AI Composability - AI Powered Gaming With Chess
  • neurons
    • What are Neurons?
    • Neuron Device
    • Virtual Neurons
      • Solo Neuron
      • Neuron as a Service
      • Pooled Neuron
  • AI CHAINS
    • What are AI chains?
    • Bittensor and existing concepts
    • Base layer: Bitcoin vs Bittensor
    • AI chains: Bitcoin L2s vs Subnets
    • Apps: Smart contracts vs APIs
  • EAI
    • Utilities
    • Tokenomics
  • fully onchain ai models
    • Architecture
    • Deploy your first fully onchain AI
      • Set up your development environment
      • Create a self-custody wallet
      • Train an AI model in Keras
      • Transform the Keras model to Eternal
      • Send, receive, and trade Eternals
    • Progress
    • Misc
      • Transforming an AI Model into an Eternal
      • Standardized data formats
      • Specification
        • Layers
        • Models
  • Decentralized Inference API
    • API
      • API Key
      • Completions
      • Chat completion
      • Create a dagent
      • Get deposit address
      • Get dagent info
      • Agent Completion
    • Onchain Models
    • Tutorials
      • Build unstoppable Eliza agents
      • Build unstoppable Rig agents
      • Build unstoppable ZerePy agents
      • Decentralized ChatGPT
      • Don't Trust, Verify
      • Adjust your dagent personality
      • Launch on Twitter
      • Chain of thought
      • Build a dagent as a service with EternalAI API
    • Open Source
      • Architecture
      • Installation
Powered by GitBook
On this page
  • Prerequisites
  • Step 1
  • Step 2
  • Step 3
  • Step 4
  • Step 5
  • Step 6
  • Step 7
  • Step 8
  • Step 9
  1. Decentralized Inference API
  2. Tutorials

Build unstoppable ZerePy agents

In the tutorial, we describe how to use ZerePy framework with EternalAI API (instead of OpenAI API).

Prerequisites

  • Python 3.10 or higher

  • Poetry 1.5 or higher

Step 1

Clone the repository.

https://github.com/blorm-network/ZerePy

Step 2

Go to the zerepy directory and install dependencies.

cd zerepy && poetry install --no-root

This will create a virtual environment and install all required dependencies.

Step 3

Activate the virtual environment.

poetry shell

Step 4

Run the application.

poetry run python main.py

You will see the following output in your terminal.

--------------------------------------------------------------------
👋 Welcome to the ZerePy CLI!
Type 'help' for a list of commands.
--------------------------------------------------------------------

✅ Successfully loaded agent: ExampleAgent

Start the agent loop with the command 'start' or use one of the action commands.

AVAILABLE CONNECTIONS:
- twitter: ❌ Not Configured
- openai: ❌ Not Configured
- anthropic: ❌ Not Configured
ZerePy-CLI (ExampleAgent) >

Step 5

In the previous step, the ExampleAgentis loaded by default, we will need to load eternalai-example agent for using with EternalAI API.

First, list all available agents.

ZerePy-CLI (ExampleAgent) > agents

You will see the following agents in your terminal.

Available Agents:
- eternalai-example
- example

Next, load the eternalai-example agent.

ZerePy-CLI (ExampleAgent) > load-agent eternalai-example

✅ Successfully loaded agent: EternalAI

Step 6

Configure EternalAI connection.

ZerePy-CLI (EternalAI) > configure-connection eternalai

Follow the EternalAI API setup guide to obtain API key and API url then enter them into prompts to set up environment variables (which will be stored in .env file).

🤖 EternalAI API SETUP

📝 To get your EternalAI API credentials:
1. Go to https://eternalai.org/api
2. Generate an API Key
3. Use API url as https://api.eternalai.org/v1/

Enter your EternalAI API key:

Enter your EternalAI API url:

Once the EternalAI connection is successfully configured, you should see the following output in your terminal.

HTTP Request: GET https://api.eternalai.org/v1/models "HTTP/1.1 200 OK"

✅ EternalAI API configuration successfully saved!
Your API key has been stored in the .env file.

✅ SUCCESSFULLY CONFIGURED CONNECTION: eternalai

Step 7

Configure Twitter connection.

ZerePy-CLI (EternalAI) > configure-connection twitter

Follow the Twitter authentication setup guide to obtain API Key (consumer key) and API Key Secret (consumer secret) then enter them into prompts to sett up environment variables (which will be stored in .env file).

Starting Twitter authentication setup

🐦 TWITTER AUTHENTICATION SETUP

📝 To get your Twitter API credentials:
1. Go to https://developer.twitter.com/en/portal/dashboard
2. Create a new project and app if you haven't already
3. In your app settings, enable OAuth 1.0a with read and write permissions
4. Get your API Key (consumer key) and API Key Secret (consumer secret)
--------------------------------------------------------------------

Please enter your Twitter API credentials:
Enter your API Key (consumer key):
Enter your API Key Secret (consumer secret):
Starting OAuth authentication process...

1. Please visit this URL to authorize the application:
2. After authorizing, Twitter will give you a PIN code.
3. Please enter the PIN code here: 

✅ Twitter authentication successfully set up!
Your API keys, secrets, and user ID have been stored in the .env file.

✅ SUCCESSFULLY CONFIGURED CONNECTION: twitter

Step 8

Add TWITTER_USERNAME environment variable to the .env file. (You need to exit the current process prior to adding)

TWITTER_USERNAME="your-twitter-username"

Step 9

Rerun the application.

poetry shell

poetry run python main.py
 
ZerePy-CLI (ExampleAgent) > load-agent eternalai-example

ZerePy-CLI (EternalAI) > start

Your agent should read the timeline and reply to a post as shown below.

HTTP Request: GET https://api.eternalai.org/v1/models "HTTP/1.1 200 OK"

🚀 Starting agent loop...
Press Ctrl+C at any time to stop the loop.
--------------------------------------------------------------------
Starting loop in 5 seconds...
5...
4...
3...
2...
1...

👀 READING TIMELINE

💬 GENERATING REPLY to: Merry Christmas and may you have a wonderful New Y...
HTTP Request: GET https://api.eternalai.org/v1/models "HTTP/1.1 200 OK"
model unsloth/Llama-3.3-70B-Instruct-bnb-4bit
HTTP Request: POST https://api.eternalai.org/v1/chat/completions "HTTP/1.1 200 OK"

🚀 Posting reply: '"Wishing you a holiday season filled with joy, love and all your favorite things, and a New Year that's bright and beautiful!"'
Reply posted successfully
✅ Reply posted successfully!

⏳ Waiting 900 seconds before next loop...

Onchain transactions for the prompt request and response:

Last updated 5 months ago

Prompt request:

Response:

https://basescan.org/tx/0x087ae3ece5b19c312d16beaea52dccffab8f3ebc34542d036fe193f54c2ba8c3
https://basescan.org/tx/0x3153addd700bd5a8b76328502ac923744b21f6f5f22bfd38f580185adc805210