LogoLogo
ChainGPT Home
  • Overview
    • Introduction
    • Mission & Vision
    • Learn The Concepts
      • Large Language Models (LLMs)
      • Text to Image Models (TTIMs)
      • Natural Language Processing (NLP)
      • Machine Learning (ML)
      • Fine-Tuning
      • Generative Model
      • Pretrained Language Model
      • Transformer Architecture
      • Tokenization
      • Contextual Awareness
      • APIs & SDKs
      • Artificial Intelligence Virtual Machine (AIVM)
      • GPU Computing Power
      • AI Data Marketplace
    • Road Map
      • 🔛2025: Q1-Q2
      • 🔜2025-2026 AIVM Blockchain Initiative
      • ✔️2024: Q3-Q4
      • ✔️2024: Q1-Q2
      • ✔️2023: Q3-Q4
      • ✔️2023: Q1-Q2
      • ✔️2022: Q3-Q4
    • FAQ
  • AI Tools & Applications
    • AIVM Blockchain Whitepaper
    • AI NFT Generator
    • Web3 AI Chatbot
    • AI Smart-Contract Generator
    • AI Smart-Contract Auditor
    • AI Crypto News
    • ChainGPT AI Agent on X
    • Nova AI News Agent on X
    • CryptoGuard Extension: Your Web3 Shield
      • Web3 Safety Toolkit
      • Crypto Wallet Security 101
      • Recognizing and Avoiding Scams in Web3
    • AI Trading Assistant
    • AI Cross-Chain Swap
    • Pricing & Membership Plans
  • Dev Docs (B2B, SaaS, API & SDK)
    • Introduction to ChainGPT's Developer Tools
    • SaaS & Whitelabel Solutions
    • Grant Program & Co-Marketing
      • Application
      • FAQ
    • Use Cases & Examples
    • Case Studies
    • Global QuickStart Guide
    • Web3 AI Chatbot & LLM (API & SDK)
      • QuickStart Guide
      • API Reference
      • SDK Reference
      • Unique Capabilities
    • AI NFT Generator (API & SDK)
      • QuickStart Guide
      • API Reference
      • SDK Reference
      • Pricing & Credits
    • Smart-Contracts Generator (API & SDK)
      • QuickStart Guide
      • API Reference
      • SDK Reference
    • Smart-Contracts Auditor (API & SDK)
      • QuickStart Guide
      • API Reference
      • SDK Reference
    • AI Crypto News (API & SDK & RSS)
      • QuickStart Guide
      • API Reference
      • SDK Reference
      • RSS Reference
    • AgenticOS Framework: Web3 AI Agent on X (Open-Source)
  • API Pricing Page
  • API Dashboard & Playground
  • Purchase API Credits
  • Bug Bounty
  • Our Ecosystem
    • CGPT Utility Token
      • Tokenomics
      • Tier System & Benefits
      • Burn Mechanism
      • CGPTc (Credits)
      • CGPTsp (Staking Points)
      • CGPTvp (Voting Power)
      • Staking Dashboard
      • Supply Dashboard
      • Burn Mechanism Dashboard
    • DAO Governance
    • ChainGPT Labs
      • Incubation Case Study: DexCheck
      • Incubation Case Study: Solidus AI Tech
      • Incubation Case Study: GT Protocol
    • ChainGPT Pad
      • Introduction & Overview
      • Tier System
        • Staking
      • KYC Onboarding Guide
      • Register Interest
      • IDO Rounds Explained
      • Leadership Team
      • Flexible Refund Policy
        • Claim & Refund Guide
      • Solana IDO Participation - Guide
      • KOLs Program (Ambassadors)
      • Delegate Staking Functionality
      • One Wallet Connect - Unified Wallet Integration Guide
      • FAQ
      • ChainGPT Pad Giveaways and Launchdrops: Technical Overview
    • DegenPad
      • Introduction to DegenPad
      • Tier System
        • Staking
      • IDO Rounds Explained
      • Flexible Refund Policy
      • DegenPad FAQs
      • Understanding Low FDV Projects on DegenPad
      • Airdrops and Giveaways
      • Delegate Staking Functionality
    • Smart-Contracts
  • Misc
    • Ecosystem Partners
    • B2B Offerings
      • Launchpad Whitelabel
      • AI Web3 Chatbot: Features and Use Cases
    • Work For ChainGPT
      • Product Manager
      • Head of Strategy
      • DevRel - Developer Relations
    • Social Links
      • Twitter: ChainGPT AI
      • Twitter: ChainGPT Pad
      • Twitter: ChainGPT Labs
      • Discord
      • Facebook
      • Instagram
      • Youtube
      • LinkedIn
      • Telegram Chat
      • Telegram News Channel
      • CMC Community
      • Blog
    • ChainGPT AI Brand Kit
    • ChainGPT Pad Brand Kit
    • Legal Docs
      • Privacy Policy
      • Terms of Service
      • Cookies Policy
      • Disclaimer
Powered by GitBook
LogoLogo

ChainGPT.org

On this page
  • ChainGPT Web3 AI Chatbot & LLM – QuickStart Guide (Tech‑Team‑Verified)
  • 1. Prerequisites ✔︎
  • 2. Integration Options
  • 3. QuickStart via REST API
  • 4. QuickStart via JavaScript SDK
  • 5. Error Codes — Quick Reference
  • 6. Best Practices

Was this helpful?

Export as PDF
  1. Dev Docs (B2B, SaaS, API & SDK)
  2. Web3 AI Chatbot & LLM (API & SDK)

QuickStart Guide

ChainGPT Web3 AI Chatbot & LLM – QuickStart Guide (Tech‑Team‑Verified)

This short guide shows you how to call ChainGPT’s Web3 LLM in under five minutes—either with plain HTTPS or the official JavaScript SDK. Everything here mirrors the internal Tech‑Team reference, not the older public docs.


1. Prerequisites ✔︎

What you need
Notes

ChainGPT account + API key

Create a key in AI Hub → API Dashboard and copy it once.

Credits

Each request = 0.5 credits.Turning chatHistory on adds +0.5 credits per call

HTTP client

cURL, Postman, fetch, axios, etc.

(If using SDK) Node ≥ 14

Install from npm.

Secure key storage

Put the key in an env var, secret manager, or server config—never ship it to the browser.

Tip export CHAINGPT_API_KEY="sk‑***" so the examples just work.


2. Integration Options

Option
When to choose
How it works

REST API

Any language / server

POST https://api.chaingpt.org/chat/stream (single endpoint for blob and streaming)

JavaScript SDK

Node or a build‑step web app

npm install @chaingpt/generalchat → call createChatBlob() or createChatStream()


3. QuickStart via REST API

3.1 Authentication & Endpoint

Authorization: Bearer $CHAINGPT_API_KEY
Content-Type: application/json
POST https://api.chaingpt.org/chat/stream

There is no separate /chat endpoint—all chat traffic goes to /chat/stream.

3.2 Single‑Shot (JSON “blob”) response

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"
      }'

If you don’t treat the response as a stream, cURL (or your HTTP client) waits until the LLM finishes, then returns one JSON:

{ "status":true,
  "data": { "bot": "Hello! I’m ChainGPT, a Web3‑savvy AI assistant…" } }

3.3 Streaming in real time

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"
      }'

-N turns off buffering so you see partial chunks instantly. Concatenate chunks on arrival until the connection closes.

3.4 Conversation Memory (chat history)

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"
      }'

Subsequent calls with the same sdkUniqueId and chatHistory:"on" include the prior Q&A so the bot answers in context.

Cost impact: chatHistory:"on" consumes +0.5 credits per request.

3.5 Custom Context & Tone

{
  "question":"Explain our project.",
  "useCustomContext":true,
  "contextInjection":{
     "companyName":"ABC Crypto",
     "companyDescription":"A DeFi yield platform",
     "aiTone":"PRE_SET_TONE",
     "selectedTone":"FRIENDLY"
  }
}

Set useCustomContext:true; include only the fields you need. Omit contextInjection to fall back to the default context configured in AI Hub.


4. QuickStart via JavaScript SDK

4.1 Install & init

npm install @chaingpt/generalchat

# or 
yarn add @chaingpt/generalchat
import { GeneralChat } from "@chaingpt/generalchat";
const chat = new GeneralChat({ apiKey: process.env.CHAINGPT_API_KEY });

4.2 Blob response

const res = await chat.createChatBlob({
  question: "Hi, what is ChainGPT?",
  chatHistory: "off"
});
console.log(res.data.bot);

createChatBlob() buffers the /chat/stream response for you.

4.3 Streaming response

const stream = await chat.createChatStream({
  question: "Summarise the last BTC block.",
  chatHistory: "off"
});
for await (const chunk of stream) process.stdout.write(chunk);

4.4 Chat history & context

await chat.createChatBlob({
  question: "Track ABC token price.",
  chatHistory: "on",
  sdkUniqueId: "user42",
  useCustomContext: true
});

SDK parameters match the REST fields 1‑for‑1.


5. Error Codes — Quick Reference

Code
Meaning
Fix

401

Missing / bad API key

Check Authorization header.

402 / 403

Out of credits

Top‑up in AI Hub.

400

Bad JSON / missing field

Verify model and question.

5xx

Server error

Retry after brief delay.


6. Best Practices

  • Hide the key. Never embed it in client JavaScript—proxy via your backend.

  • Watch credits. One call = 0.5 credits; history = +0.5. Set alerts.

  • Use unique sdkUniqueId. One per user/session keeps histories clean.

  • Handle stream ‘end’ & ‘error’. Always close or retry gracefully.

  • Stay updated. Check the npm changelog for new SDK features or model IDs.


Last updated 28 days ago

Was this helpful?

You’re now ready to integrate ChainGPT using the exact endpoints and parameters defined by the Tech Team. For deeper dives, see the full or . Happy building!

API Reference
SDK docs