scraperfox-gradient-ai
v1.0.0
Published
ScraperFox integration with Gradient AI
Maintainers
Readme
Scraper Fox Gradient AI
A lightweight JavaScript client for interacting with chat.gradient.network using streaming responses.
Supports model selection, cluster mode configuration, and optional "thinking" reasoning mode.
Features
- Simple single-function interface:
gradientAI(prompt, options) - Supports multiple model presets
- Streams output and returns the final processed message
- Small, dependency-minimal, and ESM compatible
- Built on top of
impit
Installation
pnpm add scraperfox-gradient-ai
# or
npm install scraperfox-gradient-ai
# or
yarn add scraperfox-gradient-aiUsage
import { gradientAI } from "scraperfox-gradient-ai";
const result = await gradientAI("Hello AI!");
console.log(result);With Custom Options
const response = await gradientAI("Explain quantum computing simply.", {
model: "Qwen3 235B",
enableThinking: true
});
console.log(response);Available Configuration Options
| Option | Type | Default | Allowed Values |
|-----------------|---------|-----------------|-----------------------------------------|
| model | string | "GPT OSS 120B"| "GPT OSS 120B" | "Qwen3 235B" |
| clusterMode | string | "hybrid" | "hybrid" | "nvidia" (NVIDIA GPT only) |
| enableThinking| boolean | false | true or false |
Example
await gradientAI("Hello", {
model: "GPT OSS 120B",
clusterMode: "nvidia",
enableThinking: false
});How It Works
- Prompts are normalized into a standard message format
- Options are validated based on predefined model capabilities
- The request is streamed from the Gradient API endpoint
- Tokens are collected and cleaned
- The final message after
<|message|>is returned
The function ensures output is clean of internal formatting markers.
API
gradientAI(
prompt: string,
options?: {
model?: "GPT OSS 120B" | "Qwen3 235B";
clusterMode?: "hybrid" | "nvidia"; // NVIDIA GPT only
enableThinking?: boolean;
}
): Promise<string>The function always resolves with the final text response.
If streaming fails or the server output is malformed, it throws an error.
Example Output
Input: "hello AI"
Output: "Hello! How can I assist you today?"
Notes
This client intentionally abstracts from the raw stream structure.
It is suitable for CLI tools, bots, pipelines, and backend services.
Browser use depends on CORS environment.
License
MIT
