
Alibabacloud Iqs Search
- 222 installs
- 208 repo stars
- Updated August 4, 2026
- aliyun/alibabacloud-aiops-skills
Integrate Alibaba Cloud IQS intelligent search into apps and agents to deliver semantic retrieval, knowledge grounding, and ranked answers over enterprise document corpora.
About
Build-phase skill for integrating Alibaba Cloud IQS intelligent search: configure indexes and queries, connect retrieval to LLM agents and SaaS apps, tune relevance, and automate semantic search workflows across enterprise knowledge bases.
- IQS semantic search API integration
- Enterprise knowledge retrieval setup
- Query ranking and result filtering
- Agent grounding over document indexes
- Managed search service configuration
Alibabacloud Iqs Search by the numbers
- 222 all-time installs (skills.sh)
- Ranked #2,707 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/aliyun/alibabacloud-aiops-skills --skill alibabacloud-iqs-searchAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 222 |
|---|---|
| repo stars | ★ 208 |
| Last updated | August 4, 2026 |
| Repository | aliyun/alibabacloud-aiops-skills ↗ |
What it does
Integrate Alibaba Cloud IQS intelligent search into apps and agents to deliver semantic retrieval, knowledge grounding, and ranked answers over enterprise document corpora.
Files
alibabacloud-iqs-search
Prerequisites
- Node.js >= 18.0.0 (scripts use native fetch API, no external npm dependencies)
When to Use
- User asks for current/recent information
- User provides a URL to read
- Need to verify facts or get real-time data
- Research tasks requiring multiple sources
Decision Tree
Step 1: Determine Operation Type
- If user provides a URL → Use
readpage - If user asks a question needing web info → Use
search
Step 2: For Search Operations
Follow the best practices to determine parameter values. Use default values when uncertain:
- engineType
- timeRange
- contents
Step 3: For Page Reading
Follow the best practices to determine parameter values. Use default values when uncertain:
- format
- extractArticle
- stealthMode
CRITICAL: Execution Method
You MUST execute the scripts via bash command (e.g., `node scripts/search.mjs ...` or `node scripts/readpage.mjs ...`). Do NOT use your built-in web_search, WebFetch, or any other internal tools as substitutes. If the script fails, retry or report the error — do NOT fall back to built-in tools.
Parameters & Best Practices
Search Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
--query | string | Yes | - | Search query (1-500 chars) |
--engineType | string | No | LiteAdvanced | Search engine type |
--timeRange | string | No | NoLimit | Time range filter |
--contents | string | No | - | Type of return content |
--numResults | int | No | 10 | Number of search results (1-10) |
Search Best Practices
1. Query Optimization (`--query`)
- Keep queries concise (< 30 chars for best results)
- Use specific keywords, avoid stop words
- For news: include time context in query
2. Engine Selection (`--engineType`)
The four engines differ significantly in latency, recall depth, content length, and cost. Pick the cheapest engine that meets the task — do NOT default to Deep; it is ~10× slower and 50× more expensive than the standard engine.
| Engine | Avg RT | Result count | snippet | mainText | Advanced filters | Multilingual | Cost ratio (vs Standard) | Use case |
|---|---|---|---|---|---|---|---|---|
Generic | ~950ms | ~10 | ~150 chars | ≤3000 chars | ✗ | Medium | 1× | General search, news/realtime, scene queries like weather (supports city/ip) |
LiteAdvanced | ~500ms | 1-50 | ~500 chars | ≤3000 chars | ✓ | Good | Lite-tier 1× | Default recommendation: low-latency semantic search; snippets are already rich enough |
Deep | ~6s | 1-50 | ≤500 chars | ≤50000 chars | ✓ | Good (CN/EN) | Vertical 50× | Complex multi-step reasoning, research reports, offline/Agent tasks needing deep browsing |
Decision rules:
- Default → `LiteAdvanced`: low latency + semantic search + snippet covers most Agent needs without needing extra mainText fetches.
- Choose `Generic` when: the query is short and clearly informational (news, weather, simple facts), or when minimizing cost matters; also the only engine honoring
city/ipfor scene results (weather etc.). - Choose `Deep` ONLY when: the question is multi-hop / complex reasoning (FRAMES/BrowseComp-style), OR you need very long mainText (≤50000 characters, ~16× longer than other engines) for downstream LLM reasoning.
- ⚠️ Avoid `Deep` for: real-time chat, simple lookups, high-QPS scenarios — latency (~6s) and cost (50×) are prohibitive.
3. Time Range Selection (`--timeRange`)
NoLimit: Default when uncertain - engine optimizes based on query relevanceOneDay: Today onlyOneWeek: Last 7 daysOneMonth: Last 30 daysOneYear: Last 365 days
4. Content Return (`--contents`)
mainText: Return full main text content - Use when detailed information is needed, such as technical documentation, research reports, or in-depth articlessummary: Return concise summary only - Use when a quick overview is sufficient, or when the page content is too large and token reduction is needed
5. Result Count (`--numResults`)
- Control number of results returned (default: 10, range: 1-10)
---
ReadPage Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
--url | string | Yes | - | Target page URL |
--format | string | No | markdown | Return format |
--timeout | number | No | 60000 | Total timeout in milliseconds |
--pageTimeout | number | No | 15000 | Page load timeout in milliseconds |
--stealth | number | No | 0 | Enable stealth mode (0 or 1) |
--extractArticle | boolean | No | false | Extract main article content only |
ReadPage Best Practices
1. Format Selection (`--format`)
markdown: Best for articles, preserves structure (default)text: Best for data extractionhtml: When structure analysis needed
2. Article Extraction (`--extractArticle`)
- Enable for: blogs, news articles
- Disable for: product pages, directories
3. Handling Failures (`--timeout`, `--stealth`)
- If timeout: Retry with increased
--timeoutvalue - If blocked: Enable
--stealth 1 - If still fails: Report to user
Command Line Usage
Search Examples
Basic Search
node scripts/search.mjs --query "量子计算原理" --engineType LiteAdvancedReal-time Information Search
node scripts/search.mjs --query "最新金融政策" --engineType Generic --timeRange OneWeekSearch with Results Limit
node scripts/search.mjs --query "www.aliyun.com" --engineType LiteAdvanced --numResults 3Search with Full Content
node scripts/search.mjs --query "AI 法案" --engineType LiteAdvanced --contents mainTextSearch with Summary Only
node scripts/search.mjs --query "人工智能行业年度报告" --engineType LiteAdvanced --contents summaryDeep Research Search (complex multi-hop / long mainText)
# Returns up to 50000-char mainText per result; latency ~6s. Default timeout auto-bumps to 60s for Deep.
node scripts/search.mjs --query "对比 GPT-5 与 Claude Opus 4.7 的代码能力差异" --engineType Deep --numResults 5 --contents mainTextReadPage Examples
Page Reading with Markdown Format
node scripts/readpage.mjs --url "https://example.com/article" --format markdown --extractArticle truePage Reading with Plain Text Format
node scripts/readpage.mjs --url "https://example.com/article" --format text --timeout 60000Page Reading with Stealth Mode
node scripts/readpage.mjs --url "https://example.com/article" --format markdown --stealth 1 --extractArticle trueOutput Verification
After executing any search.mjs or readpage.mjs command:
1. Check the exit code: If non-zero, the command failed — do not claim success. 2. Verify output exists: If you saved results to a file, run ls -la <filepath> and head -20 <filepath> to confirm the file exists and contains valid data. 3. Never fabricate results: If the command failed or returned an error, report the failure honestly. Do not generate content from your own knowledge and present it as search results.
Error Handling
ALIYUN_IQS_API_KEY Configuration Error
If the script returns an error about missing API key:
1. STOP the current task immediately. Do NOT fall back to built-in tools (WebFetch, web_search, curl, etc.) as substitutes. 2. Report the error to the user and ask the user to configure the API key:
3. Retry the task with following instruction: Method 1: Environment Variable
export ALIYUN_IQS_API_KEY="your-api-key"Method 2: Configuration File Create or edit ~/.alibabacloud/iqs/env:
ALIYUN_IQS_API_KEY=your-api-key#!/usr/bin/env node
/**
* IQS ReadPage Script
* Usage: node readpage.mjs --url "https://example.com" [options]
*/
const API_ENDPOINT = 'https://cloud-iqs.aliyuncs.com/readpage/scrape';
/**
* Parse command line arguments
* @param {string[]} args - Process arguments
* @returns {Object} Parsed options
*/
function parseArgs(args) {
const options = {};
for (let i = 0; i < args.length; i++) {
const arg = args[i];
if (arg.startsWith('--')) {
const key = arg.slice(2);
const nextArg = args[i + 1];
if (nextArg && !nextArg.startsWith('--')) {
// Handle boolean values
if (nextArg === 'true') {
options[key] = true;
} else if (nextArg === 'false') {
options[key] = false;
} else {
options[key] = nextArg;
}
i++;
} else {
options[key] = true;
}
}
}
return options;
}
/**
* Load API key from environment or config file
* @returns {string|null} API key
*/
async function loadApiKey() {
// First check environment variable
if (process.env.ALIYUN_IQS_API_KEY) {
return process.env.ALIYUN_IQS_API_KEY;
}
// Try loading from config file
try {
const fs = await import('fs');
const path = await import('path');
const os = await import('os');
const configPath = path.join(os.homedir(), '.alibabacloud', 'iqs', 'env');
if (fs.existsSync(configPath)) {
const content = fs.readFileSync(configPath, 'utf-8');
const match = content.match(/ALIYUN_IQS_API_KEY=(.+)/);
if (match) {
return match[1].trim();
}
}
} catch {
// Config file not found or unreadable
}
return null;
}
/**
* Read and extract content from a web page
* @param {Object} options - Read options
* @returns {Promise<Object>} Formatted page content
*/
async function readPage(options) {
const apiKey = await loadApiKey();
if (!apiKey) {
throw new Error('ALIYUN_IQS_API_KEY environment variable not set');
}
if (!options.url) {
throw new Error('URL is required. Use --url "https://example.com"');
}
// Validate URL format
if (!options.url.startsWith('http://') && !options.url.startsWith('https://')) {
throw new Error('URL must start with http:// or https://');
}
// Validate timeout range
if (options.timeout !== undefined) {
const timeout = parseInt(options.timeout, 10);
if (isNaN(timeout) || timeout < 1000 || timeout > 180000) {
throw new Error('timeout must be a number between 1000ms (1s) and 180000ms (180s)');
}
}
// Validate pageTimeout range
if (options.pageTimeout !== undefined) {
const pageTimeout = parseInt(options.pageTimeout, 10);
if (isNaN(pageTimeout) || pageTimeout < 1000 || pageTimeout > 120000) {
throw new Error('pageTimeout must be a number between 1000ms (1s) and 120000ms (120s)');
}
}
const format = options.format || 'markdown';
const body = {
url: options.url,
formats: [format],
timeout: parseInt(options.timeout, 10) || 60000,
pageTimeout: parseInt(options.pageTimeout, 10) || 15000,
stealthMode: options.stealth ? 1 : 0,
readability: {
readabilityMode: options.extractArticle ? 'article' : 'none'
}
};
// Create an AbortController to handle timeouts
const controller = new AbortController();
const timeoutDuration = Math.max(parseInt(options.timeout, 10) || 60000, 5000); // Minimum 5 seconds timeout
// Set up timeout
const timeoutId = setTimeout(() => {
controller.abort();
}, timeoutDuration);
try {
const response = await fetch(API_ENDPOINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': apiKey,
'User-Agent': 'AlibabaCloud-Agent-Skills/alibabacloud-iqs-search',
'x-iqs-source': 'skill.alibabacloud-iqs-readpage',
},
body: JSON.stringify(body),
signal: controller.signal
});
clearTimeout(timeoutId);
const data = await response.json();
if (data.errorCode) {
throw new Error(`${data.errorCode}: ${data.errorMessage}`);
}
return formatContent(data.data, format);
} catch (error) {
clearTimeout(timeoutId);
if (error.name === 'AbortError') {
throw new Error(`Request timed out after ${timeoutDuration}ms`);
}
throw error;
}
const data = await response.json();
if (data.errorCode) {
throw new Error(`${data.errorCode}: ${data.errorMessage}`);
}
return formatContent(data.data, format);
}
/**
* Format page content
* @param {Object} data - Raw page data
* @param {string} format - Output format
* @returns {Object} Formatted content
*/
function formatContent(data, format) {
if (!data) {
return {
title: null,
url: null,
content: null,
statusCode: null
};
}
return {
title: data.metadata?.title,
url: data.metadata?.url,
content: data[format] || data.markdown || data.text,
statusCode: data.statusCode
};
}
// Parse CLI arguments and execute
const args = parseArgs(process.argv.slice(2));
readPage(args).then(result => {
console.log(JSON.stringify(result, null, 2));
}).catch(err => {
console.error(JSON.stringify({ error: err.message }, null, 2));
process.exit(1);
});
#!/usr/bin/env node
/**
* IQS Search Script
* Usage: node search.mjs --query "search terms" [options]
*/
const API_ENDPOINT = 'https://cloud-iqs.aliyuncs.com/search/unified';
/**
* Parse command line arguments
* @param {string[]} args - Process arguments
* @returns {Object} Parsed options
*/
function parseArgs(args) {
const options = {};
for (let i = 0; i < args.length; i++) {
const arg = args[i];
if (arg.startsWith('--')) {
const key = arg.slice(2);
const nextArg = args[i + 1];
if (nextArg && !nextArg.startsWith('--')) {
options[key] = nextArg;
i++;
} else {
options[key] = true;
}
}
}
return options;
}
/**
* Load API key from environment or config file
* @returns {string|null} API key
*/
async function loadApiKey() {
// First check environment variable
if (process.env.ALIYUN_IQS_API_KEY) {
return process.env.ALIYUN_IQS_API_KEY;
}
// Try loading from config file
try {
const fs = await import('fs');
const path = await import('path');
const os = await import('os');
const configPath = path.join(os.homedir(), '.alibabacloud', 'iqs', 'env');
if (fs.existsSync(configPath)) {
const content = fs.readFileSync(configPath, 'utf-8');
const match = content.match(/ALIYUN_IQS_API_KEY=(.+)/);
if (match) {
return match[1].trim();
}
}
} catch {
// Config file not found or unreadable
}
return null;
}
/**
* Execute search query
* @param {Object} options - Search options
* @returns {Promise<Array>} Formatted search results
*/
async function search(options) {
const apiKey = await loadApiKey();
if (!apiKey) {
throw new Error('ALIYUN_IQS_API_KEY environment variable not set');
}
if (!options.query) {
throw new Error('Query is required. Use --query "search terms"');
}
// Validate query length
if (typeof options.query === 'string' && (options.query.length < 1 || options.query.length > 500)) {
throw new Error('Query length must be between 1 and 500 characters');
}
// Validate numResults range
if (options.numResults !== undefined) {
const numResults = parseInt(options.numResults, 10);
if (isNaN(numResults) || numResults < 1 || numResults > 10) {
throw new Error('numResults must be a number between 1 and 10');
}
}
const body = {
query: options.query,
engineType: options.engineType || 'LiteAdvanced',
timeRange: options.timeRange || 'NoLimit',
contents: {
mainText: options.contents !== 'summary', // 默认为 true,除非显式指定为 'summary'
summary: options.contents == 'summary'
}
};
if (options.category) {
body.category = options.category;
}
// Set the number of results if specified
if (options.numResults) {
body.numResults = parseInt(options.numResults, 10);
}
// Set timeout (default 10 seconds)
const timeout = parseInt(options.timeout, 10) || 10000;
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), timeout);
try {
const response = await fetch(API_ENDPOINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': apiKey,
'User-Agent': 'AlibabaCloud-Agent-Skills/alibabacloud-iqs-search',
'x-iqs-source': 'skill.alibabacloud-iqs-search',
},
body: JSON.stringify(body),
signal: controller.signal
});
clearTimeout(timeoutId);
const data = await response.json();
if (data.errorCode) {
throw new Error(`${data.errorCode}: ${data.errorMessage}`);
}
// Format results and apply numResults limit if specified
let formattedResults = formatResults(data.pageItems || []);
if (options.numResults) {
const limit = parseInt(options.numResults, 10);
formattedResults = formattedResults.slice(0, limit);
}
return formattedResults;
} catch (error) {
clearTimeout(timeoutId);
if (error.name === 'AbortError') {
throw new Error(`Request timeout after ${timeout}ms`);
}
throw error;
}
}
/**
* Format search results
* @param {Array} items - Raw search results
* @returns {Array} Formatted results
*/
function formatResults(items) {
return items.map((item, index) => {
const formattedItem = {
rank: index + 1,
title: item.title,
url: item.link,
snippet: item.snippet,
source: item.hostname,
publishedTime: item.publishedTime,
relevance: item.rerankScore
};
// Include summary if it exists in the item
if (item.summary) {
formattedItem.summary = item.summary;
}
if (item.mainText) {
formattedItem.mainText = item.mainText;
}
return formattedItem;
});
}
// Parse CLI arguments and execute
const args = parseArgs(process.argv.slice(2));
search(args).then(results => {
console.log(JSON.stringify(results, null, 2));
}).catch(err => {
console.error(JSON.stringify({ error: err.message }, null, 2));
process.exit(1);
});