Autonomous AI Agents can programmatically access Venice.ai’s APIs without any human interaction using the “api_keys” endpoint. AI Agents are now able to manage their own wallets on the BASE blockchain, allowing them to programmatically acquire and stake VVV token to earn a daily VCU inference allocation. Venice’s new API endpoint allows them to automate further by generating their own API key.

To autonomously generate an API key within an agent, you must:

1

Acquire VVV

The agent will need VVV token to complete this process. This can be achieved by sending tokens directly to the agent wallet, or having the agent swap on a Decentralized Exchange (DEX), like Aerodrome or Uniswap.

2

Stake VVV with Venice

Once funded, the agent will need to stake the VVV tokens within the Venice Staking Smart Contract. To accomplish this you first must approve VVV tokens for staking, then execute a “stake” transaction.

When the transaction is complete, you will see the VVV tokens exit the wallet and sVVV tokens returned to your wallet. This indicates a successful stake.

3

Obtain Validation Token

To generate an API key, you need to first obtain your validation token. You can get this by calling this API endpoint https://api.venice.ai/api/v1/api_keys/generate_web3_key . The API response will provide you with a “token”.

Here is an example request:

curl --request GET \
  --url https://api.venice.ai/api/v1/api_keys/generate_web3_key
4

Sign for Wallet Validation

Sign the token with the wallet holding VVV to complete the association between the wallet and token.

5

Generate API Key

Now you can call this same API endpoint https://api.venice.ai/api/v1/api_keys/generate_web3_key to create your API key.

You will need the following information to proceed, which is described further within the “Generating API Key Guide”:

  • API Key Type: Inference or Admin

  • ConsumptionLimit: To be used if you want to limit the API key usage

  • Signature: The signed token from step 4

  • Token: The unsigned token from step 3

  • Address: The agent’s wallet address

  • Description: String to describe your API Key

  • ExpiresAt: Option to set an expiration date for the API key (empty for no expiration)

Here is an example request:

curl --request POST \
  --url https://api.venice.ai/api/v1/api_keys/generate_web3_key \
  --header 'Authorization: Bearer ' \
  --header 'Content-Type: application/json' \
  --data '{
  "description": "Web3 API Key",
  "apiKeyType": "INFERENCE",
  "signature": "<signed token>",
  "token": "<unsigned token>",
  "address": "<wallet address>",
  "consumptionLimit": {
    "vcu": 1
  }
}'

Example code to interact with this API can be found below:

import { ethers } from "ethers";

// NOTE: This is an example. To successfully generate a key, your address must be holding
// and staking VVV.
const wallet = ethers.Wallet.createRandom()
const address = wallet.address
console.log("Created address:", address)

// Request a JWT from Venice's API
const response = await fetch('https://api.venice.ai/api/v1/api_keys/generate_web3_key')
const token = (await response.json()).data.token
console.log("Validation Token:", token)

// Sign the token with your wallet and pass that back to the API to generate an API key
const signature = await wallet.signMessage(token)
const postResponse = await fetch('https://api.venice.ai/api/v1/api_keys/generate_web3_key', {
  method: 'POST',
  body: JSON.stringify({
    address,
    signature,
    token,
    apiKeyType: 'ADMIN'
  })
})

await postResponse.json()