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