hive-intelligence
v0.1.1
Published
The Hive Intelligence SDK lets you integrate real-time crypto and Web3 intelligence into your JavaScript or TypeScript apps using simple prompt or chat-style inputs.
Readme
🧠 Hive Intelligence TypeScript SDK
The Hive Intelligence SDK lets you integrate real-time crypto and Web3 intelligence into your JavaScript or TypeScript apps using simple prompt or chat-style inputs.
🚀 Installation
Using npm:
npm install hive-intelligenceOr using yarn:
yarn add hive-intelligence🔑 Setup
Set your Hive API key as an environment variable:
export HIVE_API_KEY=your_api_key_here🧪 Example Usage
import { HiveSearchClient } from 'hive-intelligence';
import { HiveSearchRequest, HiveSearchMessage, HiveSearchResponse} from 'hive-intelligence';
// Get API key from env
const apiKey = process.env.HIVE_API_KEY;
if (!apiKey) {
throw new Error('Please set the HIVE_API_KEY environment variable');
}
// Initialize client
const client = new HiveSearchClient(apiKey);
// 🟡 Example 1: Prompt-based query
const promptRequest: HiveSearchRequest = {
prompt: 'What is the current price of Ethereum?'
};
client.search(promptRequest).then((response: HiveSearchResponse) => {
console.log('Prompt Response:', response);
}).catch(console.error);
// 🟢 Example 2: Chat-style query
const chatRequest: HiveSearchRequest = {
messages: [
{ role: 'user', content: 'Price of' },
{ role: 'assistant', content: 'Price of what?' },
{ role: 'user', content: 'BTC' }
]
};
client.search(chatRequest).then((response: HiveSearchResponse) => {
console.log('Chat Response:', response);
}).catch(console.error);📘 Request Options
prompt: Plaintext question or querymessages: Array of{ role, content }for chat- Optional parameters:
temperature: (e.g. 0.7) randomness of responsetop_k: max tokens consideredtop_p: nucleus samplinginclude_data_sources: show source info
❗ Error Handling
On error, the SDK throws HiveSearchAPIError with:
status: HTTP status codestatusText: status messagebody: full API response
