Crypto.com AI Agent SDK
  • Getting Started
    • Introduction
    • Quick Start Guide: Simulation Entry Point
  • Core Concepts Overview
    • Plugins
    • Tools
    • Blockchain Functions
      • Wallet Management
      • Token Interaction
      • Transaction Queries
      • Block Information
      • Contract Operations
      • CronosID Operations
      • Defi Operations
      • Crypto.com Exchange
    • Built-in Telegram Feature
    • Advanced Usage: Custom Instructions
    • Dynamic AI Model Manager
  • Crypto.com On-Chain Developer Platform
    • Developer Platform API Methods
  • On-Chain Functions and Examples
    • AI Agent Chatbot
    • "Magic Link" Signer
  • Resources for Developers
Powered by GitBook
On this page
  • Introduction
  • Features
  • Installation
  • Usage
  • API

Was this helpful?

  1. Outdated Contents

Crypto.com AI Agent Client

Last updated 2 months ago

Was this helpful?

Introduction

The Crypto.com AI Agent Client is a library designed to facilitate easy and efficient interactions with the Crypto.com AI Agent Service API. This client library provides methods to send queries and fetch responses from the Crypto.com AI Agent Service seamlessly, currently the library supports:

  • TypeScript/JavaScript

  • Python

The implementation of the AI Agent Client is open source and can be found in this . Developers can also refer to Self-Hosting AI-Agent-Server example to host it independently.

Features

Currently in beta: Expect frequent updates and potential changes in future releases.

  • Simple and intuitive API for interacting with the Crypto.com AI Agent.

  • Supports sending queries and receiving AI-generated responses.

  • Configurable client instances tailored to your specific endpoint and security needs.

  • Support networks: Cronos zkEVM and Cronos EVM mainnet and testnet.

Installation

To install the package, run the following command in your project directory:

npm install @crypto.com/ai-agent-client

To install the package, run the following command:

pip install crypto-com-ai-agent-client

Usage

Here’s how you can use the Crypto.com AI Agent Client in your project:

Configuring the Client

import { createClient } from "@crypto.com/ai-agent-client";
import { QueryOptions } from "@crypto.com/ai-agent-client/dist/integrations/cdc-ai-agent.interfaces";

const OPEN_AI_API_KEY = "OPEN-AI-API-KEY";
const CHAIN_ID = 240; // 25 for Cronos EVM Mainnet, 338 for Cronos EVM Testnet, 388 for Cronos ZkEVM Mainnet, 240 for Cronos ZkEVM Testnet

const EXPLORER_KEY = "ZKEVM-TESTNET-API-KEY";

// Function to send a query and log the response
async function sendQuery(query: string) {
  // Create client params
  const queryOptions: QueryOptions = {
    openAI: {
      apiKey: OPEN_AI_API_KEY,
      model: "gpt-4-turbo",
    },
    chainId: CHAIN_ID,
    explorerKeys: {
      cronosMainnetKey: "YOUR-CRONOS-EVM-MAINNET-EXPLORER-KEY",
      cronosTestnetKey: "YOUR-CRONOS-EVM-TESTNET-EXPLORER-KEY",
      cronosZkEvmKey: "YOUR-CRONOS-zkEVM-MAINNET-EXPLORER-KEY",
      cronosZkEvmTestnetKey: EXPLORER_KEY,
    },
    context: [],
    // signerAppUrl: 'https://my-signer-app', // Refer to: https://github.com/crypto-com/cdc-ai-agent-signer-app
    // customRPC: 'https://rpc.vvs.finance,
  };
}
from crypto_com_ai_agent_client import create_client

client = create_client({
    'openAI': {
        'apiKey': 'YOUR_OPEN_AI_API_KEY',
        'model': 'gpt-4o'  # Optional, defaults to 'gpt-4-turbo'
    },
    'chainId': 240,  # 25 for Cronos EVM Mainnet, 338 for Cronos EVM Testnet, 388 for Cronos ZkEVM Mainnet, 240 for Cronos ZkEVM Testnet
    'explorerKeys': {
        'cronosMainnetKey': 'CRONOS_MAINNET_API_KEY',
        'cronosTestnetKey': 'CRONOS_TESTNET_API_KEY',
        'cronosZkEvmKey': 'CRONOS_ZKEVM_API_KEY',
        'cronosZkEvmTestnetKey': 'CRONOS_ZKEVM_TESTNET_API_KEY'
    },
    'context': [],  # Optional
    'signerAppUrl': '',  # Optional, for example - https://my-signer-app
    'customRPC': ''  # Optional, if not provided, the default RPC for the chainId will be used
})

Here are the key details for:

Cronos zkEVM

Cronos EVM

Sending a Query

const sendQuery = async (query) => {
  try {
    const response = await client.agent.generateQuery(query);
    console.log('Crypto.com AI Agent Response:', response);
  } catch (error) {
    console.error('Error sending query:', error);
  }
};
def send_query(query):
    try:
        response = client.agent.generate_query(query)
        print('Crypto.com AI Agent Response:', response)
    except Exception as e:
        print(f"Error sending query: {str(e)}")

send_query("What is the latest block?")

API

Client Methods

  • generate_query(query): Generates a query that is send to the Crypto.com AI Agent Service and returns a response.

npm page
Github
Pypi page
Github
Github repository
Network config
Explorer
API Key
Network config
Explorer
API Key