### Install ChainGPT AI News SDK
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/ai-crypto-news-api-and-sdk-and-rss/quickstart-guide
Installs the ChainGPT AI News SDK using npm or yarn package managers.
```bash
# npm
npm install --save @chaingpt/ainews
# yarn
yarn add @chaingpt/ainews
```
--------------------------------
### Install ChainGPT Smart Contract Generator SDK
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/smart-contracts-generator-api-and-sdk/quickstart-guide
Installs the ChainGPT Smart Contract Generator SDK using npm or yarn package managers for Node.js projects.
```bash
npm install --save @chaingpt/smartcontractgenerator
# or
yarn add @chaingpt/smartcontractgenerator
```
--------------------------------
### ChainGPT JavaScript SDK: Installation
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/web3-ai-chatbot-and-llm-api-and-sdk/quickstart-guide
Instructions for installing the ChainGPT JavaScript SDK using npm or yarn. This is the first step to integrating the chatbot into Node.js or web applications.
```bash
npm install @chaingpt/generalchat
# or
yarn add @chaingpt/generalchat
```
--------------------------------
### Install ChainGPT Node.js SDK
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/smart-contracts-auditor-api-and-sdk/quickstart-guide
Installs the official ChainGPT Node.js SDK for the Smart Contract Auditor using npm or yarn. This SDK simplifies interaction with the Auditor API and handles streaming.
```bash
npm install --save @chaingpt/smartcontractauditor
# or
yarn add @chaingpt/smartcontractauditor
```
--------------------------------
### Generate First Article
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/ai-crypto-news-api-and-sdk-and-rss/quickstart-guide
Shows how to generate your first crypto news article using either the REST API or the SDK, with an example of limiting results.
```bash
# REST (minimal)
curl https://api.chaingpt.org/news \
-H "Authorization: Bearer $CHGPT_API_KEY" \
-G --data-urlencode "limit=1"
```
```ts
// SDK (equivalent)
const { data } = await ainews.getNews({ limit: 1 });
console.log(data[0].title);
```
--------------------------------
### Consume via RSS
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/ai-crypto-news-api-and-sdk-and-rss/quickstart-guide
Provides example XML structure for news items obtained via RSS feeds, detailing common fields like title, description, link, and publication date.
```xml
https://app.chaingpt.org/news/16546/critical-security-vulnerability-in-china-esp32-chip-raises-concerns-for-bitcoin-wallets
16546Thu, 17 Apr 2025 20:00:00 GMT
```
--------------------------------
### ChainGPT REST API: Real-time Streaming Example
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/web3-ai-chatbot-and-llm-api-and-sdk/quickstart-guide
Shows how to enable real-time streaming of responses from the ChainGPT Chat API using the `-N` flag with cURL. This allows for displaying partial responses as they are generated.
```bash
curl -N -X POST https://api.chaingpt.org/chat/stream \
-H "Authorization: Bearer $CHAINGPT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model":"general_assistant",
"question":"Give me the latest ETH stats.",
"chatHistory":"off"
}'
```
--------------------------------
### ChainGPT REST API: Single-Shot Response Example
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/web3-ai-chatbot-and-llm-api-and-sdk/quickstart-guide
Demonstrates how to make a single request to the ChainGPT Chat API and receive a complete JSON response. This is useful for non-streaming applications where the full answer is needed at once.
```bash
curl -X POST https://api.chaingpt.org/chat/stream \
-H "Authorization: Bearer $CHAINGPT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model":"general_assistant",
"question":"Hello, ChainGPT! Who are you?",
"chatHistory":"off"
}'
```
--------------------------------
### ChainGPT REST API: Conversation Memory Example
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/web3-ai-chatbot-and-llm-api-and-sdk/quickstart-guide
Demonstrates enabling conversation memory by setting `chatHistory:"on"` and providing an `sdkUniqueId`. This allows the AI to maintain context across multiple interactions.
```bash
curl -X POST https://api.chaingpt.org/chat/stream \
-H "Authorization: Bearer $CHAINGPT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model":"general_assistant",
"question":"Remember my token ABC and what it does.",
"chatHistory":"on",
"sdkUniqueId":"user42"
}'
```
--------------------------------
### ChainGPT JavaScript SDK: Initialization
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/web3-ai-chatbot-and-llm-api-and-sdk/quickstart-guide
Shows how to import and initialize the `GeneralChat` class from the ChainGPT JavaScript SDK. It requires providing your API key during instantiation.
```js
import { GeneralChat } from "@chaingpt/generalchat";
const chat = new GeneralChat({ apiKey: process.env.CHAINGPT_API_KEY });
```
--------------------------------
### Error Handling with SDK
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/ai-crypto-news-api-and-sdk-and-rss/quickstart-guide
Illustrates how to catch and handle specific errors thrown by the ChainGPT AI News SDK, such as AINewsError.
```ts
import { Errors } from '@chaingpt/ainews';
try {
await ainews.getNews({});
} catch (err) {
if (err instanceof Errors.AINewsError) {
console.error(err.message);
}
}
```
--------------------------------
### Initialize ChainGPT Smart Contract Generator SDK
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/smart-contracts-generator-api-and-sdk/quickstart-guide
Initializes the SmartContractGenerator client with an API key, typically loaded from environment variables for security.
```javascript
import { SmartContractGenerator } from "@chaingpt/smartcontractgenerator";
const smartcontractgenerator = new SmartContractGenerator({
apiKey: process.env.CHAINGPT_API_KEY // Your ChainGPT API Key (use env var for security)
});
```
--------------------------------
### SDK Exception Handling
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/smart-contracts-auditor-api-and-sdk/quickstart-guide
Guidance on handling exceptions when using the ChainGPT Smart Contract Auditor SDK, particularly the `SmartContractAuditorError`.
```APIDOC
Exception Type: SmartContractAuditorError
Message Format: "Request failed with status code "
Purpose: Catches API-related errors, including network issues, authentication problems, and invalid requests.
Debugging: Log the exception message to identify the root cause (e.g., auth, missing parameters).
Initialization: Ensure 'apiKey' is correctly provided during SDK setup.
```
--------------------------------
### ChainGPT REST API: Custom Context & Tone Example
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/web3-ai-chatbot-and-llm-api-and-sdk/quickstart-guide
Illustrates how to inject custom context and define the AI's tone for responses. This involves setting `useCustomContext:true` and providing details within the `contextInjection` object.
```json
{
"question":"Explain our project.",
"useCustomContext":true,
"contextInjection":{
"companyName":"ABCÂ Crypto",
"companyDescription":"A DeFi yield platform",
"aiTone":"PRE_SET_TONE",
"selectedTone":"FRIENDLY"
}
}
```
--------------------------------
### ChainGPT Smart Contract Generator API
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/smart-contracts-generator-api-and-sdk/quickstart-guide
Documentation for the ChainGPT Smart Contract Generator HTTP API. Covers endpoint, authentication (Bearer token), request headers, and JSON body parameters for generating smart contracts. Includes prerequisites and an example request.
```APIDOC
ChainGPT Smart Contract Generator API:
Endpoint:
POST https://api.chaingpt.org/chat/stream
Authentication:
Uses Bearer token authentication.
Include an HTTP header: `Authorization: Bearer YOUR_API_KEY`.
Request Headers:
- `Authorization`: Bearer YOUR_API_KEY (required) - Your secret API key.
- `Content-Type`: application/json (required) - Specifies the request body format.
Request Body Parameters (JSON):
- `model` (string, required): The model name to use. Must be "smart_contract_generator".
- `question` (string, required): The user's prompt or question for contract generation. Example: "Write a Solidity smart contract for a simple counter."
- `chatHistory` (string, optional): Controls conversation memory. Set to "on" to enable chat history, "off" for a single-turn query.
- `sdkUniqueId` (string, optional): A unique user or session identifier, used when `chatHistory` is "on" to maintain continuity.
Prerequisites:
- ChainGPT Account with Credits.
- API Key generated from the ChainGPT WebApp.
- Environment capable of making HTTP requests (e.g., curl, Postman, Node.js, Python).
Credit System:
- 1 credit per API request.
- Additional 1 credit if `chatHistory` is enabled.
- API calls fail if credits are insufficient.
```
```bash
curl -X POST "https://api.chaingpt.org/chat/stream" \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{"model": "smart_contract_generator", "question": "Generate a smart contract for a sum of two numbers."}'
```
--------------------------------
### Authenticate ChainGPT AI News
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/ai-crypto-news-api-and-sdk-and-rss/quickstart-guide
Demonstrates authentication methods for accessing the ChainGPT AI News API, both via REST and the SDK.
```bash
# REST API Authentication
curl https://api.chaingpt.org/news \
-H "Authorization: Bearer $CHGPT_API_KEY"
```
```ts
// SDK Authentication
import { AINews } from '@chaingpt/ainews';
const ainews = new AINews({ apiKey: process.env.CHGPT_API_KEY! });
```
--------------------------------
### Streaming Response Handling (Node.js)
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/smart-contracts-auditor-api-and-sdk/quickstart-guide
Notes on handling streaming API responses, particularly in Node.js environments, to ensure data is received correctly.
```APIDOC
Streaming Endpoint Behavior:
Requirement: Handle responses as streams (e.g., Server-Sent Events, chunked responses).
Node.js/Axios: The provided Axios example is confirmed to work in Node.js for streaming.
Other Environments: Use HTTP clients capable of stream processing.
Testing: Use cURL with the '-N' option for unbuffered output to observe streaming text.
```
--------------------------------
### Install AgenticOS and Bun Runtime (Bash)
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/agenticos-framework-web3-ai-agent-on-x-open-source
This snippet details the steps to clone the AgenticOS repository, install the Bun runtime if not already present, and install project dependencies using Bun. It's essential for setting up the project environment.
```bash
# Clone the AgenticOS repository
git clone https://github.com/ChainGPT-org/AgenticOS.git
cd AgenticOS
# Install the Bun runtime (if not already installed)
curl -fsSL https://bun.sh/install | bash
# Install project dependencies using Bun
bun install
```
--------------------------------
### Example ERC-20 Token Contract with Burn Function
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/smart-contracts-generator-api-and-sdk/api-reference
A sample Solidity smart contract generated by the AI, demonstrating an ERC-20 token with minting and burning functionalities.
```Solidity
pragma solidity ^0.8.0;
contract MyToken {
string public name = "MyToken";
string public symbol = "MTK";
uint8 public decimals = 18;
uint256 public totalSupply;
address public owner;
mapping(address => uint256) balances;
constructor() {
owner = msg.sender;
}
function mint(address to, uint256 amount) public {
require(msg.sender == owner, "Only owner can mint");
totalSupply += amount;
balances[to] += amount;
}
function burn(uint256 amount) public {
require(balances[msg.sender] >= amount, "Insufficient balance");
totalSupply -= amount;
balances[msg.sender] -= amount;
}
function balanceOf(address account) public view returns (uint256) {
return balances[account];
}
}
```
--------------------------------
### ChainGPT JavaScript SDK: Blob Response
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/web3-ai-chatbot-and-llm-api-and-sdk/quickstart-guide
Demonstrates how to use the `createChatBlob()` method of the JavaScript SDK to get a single, complete response from the ChainGPT chatbot. This method handles buffering the API response internally.
```js
const res = await chat.createChatBlob({
question: "Hi, what is ChainGPT?",
chatHistory: "off"
});
console.log(res.data.bot);
```
--------------------------------
### ChainGPT Pad IDO Participation Guide
Source: https://docs.chaingpt.org/overview/faq
Steps for users to participate in Initial DEX Offerings (IDOs) on the ChainGPT Pad platform. This includes registration, KYC, staking, and claiming tokens.
```APIDOC
ChainGPT Pad IDO Participation:
1. Register on ChainGPT Pad:
- Visit https://pad.chaingpt.org
- Connect a Web3 wallet (e.g., MetaMask, Trust Wallet).
2. Complete KYC Verification:
- Undergo Know Your Customer (KYC) process.
- Provide personal identification documents and information.
3. Stake $CGPT Tokens:
- Stake $CGPT tokens to qualify for tier levels.
- Higher staking increases tier points, improving allocation chances.
- Tiers offer benefits like guaranteed allocation and early access.
4. Gain Tier Points:
- Accumulate tier points based on staked tokens.
- Higher tier points grant better access and allocation in IDOs.
5. Participate in IDO Rounds:
- Review specific project details (price, allocation limits, timelines).
- Participate within the defined sale window.
6. Claim Your Tokens:
- After the IDO concludes, claim allocated tokens.
- Tokens will be available in your connected wallet.
```
--------------------------------
### Initialize ChainGPT SDK and create chat blob
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/web3-ai-chatbot-and-llm-api-and-sdk/sdk-reference
This example demonstrates initializing the ChainGPT SDK with an API key and making a basic request to the `createChatBlob` method. It retrieves a chatbot response for a given question, with an option to enable chat history.
```javascript
import { GeneralChat } from '@chaingpt/generalchat';
const generalchat = new GeneralChat({
apiKey: 'YOUR_CHAINGPT_API_KEY', // replace with your actual API key
});
async function main() {
const response = await generalchat.createChatBlob({
question: 'Explain quantum computing in simple terms',
chatHistory: "off" // set to "on" to enable saving chat history (optional)
});
console.log(response.data.bot);
}
main();
```
```javascript
import { GeneralChat } from '@chaingpt/generalchat';
const generalchat = new GeneralChat({
apiKey: 'YOUR_CHAINGPT_API_KEY',
});
```
--------------------------------
### Initialize SmartContractAuditor SDK
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/smart-contracts-auditor-api-and-sdk/quickstart-guide
Demonstrates how to import and initialize the SmartContractAuditor class with an API key. This creates an authenticated client instance for subsequent operations. It's recommended to load API keys from environment variables in production.
```typescript
import { SmartContractAuditor } from "@chaingpt/smartcontractauditor";
const smartcontractauditor = new SmartContractAuditor({
apiKey: ""
});
```
--------------------------------
### Retrieve Chat History via API
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/smart-contracts-generator-api-and-sdk/quickstart-guide
Shows how to fetch past chat entries from the ChainGPT API. The `GET /chat/chatHistory` endpoint supports pagination and sorting parameters like `limit`, `offset`, `sortBy`, and `sortOrder`.
```javascript
// Assuming API_URL is set to https://api.chaingpt.org/chat/chatHistory for this request
const historyClient = axios.create({
baseURL: 'https://api.chaingpt.org/chat/chatHistory',
headers: { Authorization: `Bearer ${API_KEY}` }
});
const historyResponse = await historyClient.get('/', {
limit: 10,
offset: 0,
sortBy: 'createdAt',
sortOrder: 'desc'
});
console.log(historyResponse.data.data.rows);
```
--------------------------------
### Fetch Chat History (JavaScript SDK)
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/smart-contracts-generator-api-and-sdk/api-reference
Retrieves past chat conversations using the Smart Contract Generator SDK's client. This function makes a GET request to the history endpoint with specified parameters for pagination and sorting.
```javascript
async function fetchData() {
try {
const response = await apiclient.get("/", {
limit: 10,
offset: 0,
sortBy: "createdAt",
sortOrder: "desc",
});
console.log("Response data:", response.data.data.rows);
} catch (error) {
console.error("Error fetching data:", error);
}
}
// Execute the function to fetch data
fetchData();
```
--------------------------------
### ChainGPT AI News API Reference
Source: https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/ai-crypto-news-api-and-sdk-and-rss/quickstart-guide
Provides an overview of the ChainGPT AI News REST API, including base URL, authentication, request limits, and error handling conventions.
```APIDOC
Base URL: https://api.chaingpt.org/news
Authentication:
- Use Bearer token in the Authorization header: `Authorization: Bearer $CHGPT_API_KEY`
Rate Limits:
- 200 requests per minute per key.
- Bursting above the rate limit will result in throttling.
Error Handling:
- REST API returns standard HTTP status codes.
- Non-2xx responses include a JSON object with a `message` field detailing the error.
Optional Filters (for GET requests):
- `limit`: Number of records to return (e.g., `limit=10`).
- `offset`: For pagination (e.g., `offset=20`).
- `categoryId`: Filter by category ID.
- `subCategoryId`: Filter by sub-category ID.
- `tokenId`: Filter by token ID.
- `fetchAfter`: Filter articles published after a specific date/time.
- `searchQuery`: Perform a text search within articles.
- `sortBy`: Sort order, options: `createdAt` or `publishedAt`.
```