Crypto.com AI Agent Client

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:

The implementation of the AI Agent Client is open source and can be found in this Github repository. 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

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,
  };

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);
  }
};

API

Client Methods

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

Last updated