// deepseek-v4.js — bundle standalone. npm deps: axios, node:url /** * Scraper: deepseek-v4.js * Source : kyioapi/deepseek-v4.js * * Input : Function parameters / CLI args (e.g. prompt: string, brand: string) * Output : Promise (DeepSeek AI response with status and model metadata) * * CLI Run: * node deepseek-v4.js DeepSeek "Apa itu Node.js?" */ import axios from "axios"; import { pathToFileURL } from "node:url"; const CHATGPTIS_URL = "https://chatgptis.org/api/chat"; /** * DeepSeek AI Chat Scraper * @param {string} prompt User message or prompt * @param {string} [brand="deepseek"] AI engine brand (default: deepseek) * @param {string} [system=""] System instructions (optional) * @returns {Promise<{ status: boolean, model: string, result: string }>} */ export async function DeepSeek(prompt, brand = "deepseek", system = "") { if (!prompt || typeof prompt !== "string") { throw new Error('Parameter "prompt" is required and must be a string.'); } const messages = []; if (system) { messages.push({ role: "system", content: system }); } messages.push({ role: "user", content: prompt }); try { const { data } = await axios.post( CHATGPTIS_URL, { messages, brand: brand, system: system || "", webSearch: false, }, { headers: { "Content-Type": "application/json", "Origin": "https://chatgptis.org", "Referer": "https://chatgptis.org/", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/137.0.0.0 Safari/537.36", }, timeout: 30000, } ); const answer = typeof data === "string" ? data.trim() : JSON.stringify(data).trim(); if (!answer) { throw new Error("Empty response returned from DeepSeek engine."); } return { status: true, model: brand, result: answer, }; } catch (error) { throw new Error(`DeepSeek Error: ${error.response?.data?.error?.message || error.message}`); } } export { DeepSeek as DeepSeekThinking }; export default DeepSeek; // ───────────────────────────────────────────────────────────────────── // Self-test: jalankan langsung dengan `node deepseek-v4.js [args...]` // ───────────────────────────────────────────────────────────────────── if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) { const prompt = process.argv[2] || "Jelaskan apa itu Node.js dalam 1 kalimat"; (async () => { try { const res = await DeepSeek(prompt); console.log(JSON.stringify(res, null, 2)); } catch (e) { console.error("Error: " + e.message); process.exitCode = 1; } })(); }