Autonomous AI Agents can programmatically access Venice.ai’s APIs without any human interaction using this endpoint.

Agents can:

  1. Buy VVV on a Decentralized Exchange (DEX)
  2. Stake that VVV through direct smart contract interaction
  3. Call this API to obtain a validation token.
  4. Sign the token with the wallet holding VVV.
  5. Call this API to create an API key.

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()