A lightweight JavaScript client for interacting with chat.gradient.network using streaming responses.
Supports model selection, cluster mode configuration, and optional "thinking" reasoning mode.
- 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
pnpm add scraperfox-gradient-ai
# or
npm install scraperfox-gradient-ai
# or
yarn add scraperfox-gradient-aiimport { gradientAI } from "scraperfox-gradient-ai";
const result = await gradientAI("Hello AI!");
console.log(result);const response = await gradientAI("Explain quantum computing simply.", {
model: "Qwen3 235B",
enableThinking: true
});
console.log(response);| 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 |
await gradientAI("Hello", {
model: "GPT OSS 120B",
clusterMode: "nvidia",
enableThinking: false
});- 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.
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.
Input: "hello AI"
Output: "Hello! How can I assist you today?"
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.
MIT