GPT-OSS Local con JavaScript y Ollama

Configura un chat IA local con GPT-OSS y Ollama usando JavaScript para ejecutar modelos sin internet ni claves API; paso a paso, RAG y soluciones empresariales con Q2BSTUDIO.

20 ago 2025 • 3 min read • Q2BSTUDIO Team

Inteligencia-Artificial-

La inteligencia artificial en la nube es potente pero tiene costes y limitaciones en privacidad y dependencia de internet; por eso ejecutar modelos open weight como GPT-OSS localmente cambia las reglas del juego.

GPT-OSS está disponible en versiones gpt-oss-120b y gpt-oss-20b y puede ejecutarse directamente en tu máquina; la variante 20b requiere aproximadamente 16GB de RAM, lo que la hace práctica para experimentación local sin necesidad de hardware empresarial masivo.

Combinando GPT-OSS con Ollama puedes construir asistentes IA privados y prioritarios offline utilizando JavaScript, manteniendo datos in situ y evitando costes recurrentes de API.

Por qué JavaScript: es universal y se ejecuta en frontend, backend, escritorio y móvil; su simplicidad facilita llamadas HTTP con Fetch API; y su ecosistema es ideal para integrar en aplicaciones web, chatbots, agentes IA y soluciones empresariales.

Requisitos básicos: un sistema con 16GB o más de RAM y preferiblemente GPU o un Mac con Apple Silicon; Node.js v18 o superior instalado; Ollama instalado y en ejecución; y el modelo GPT-OSS descargado localmente con el comando ollama pull gpt-oss:20b.

Paso 1 - Inicializar proyecto Node.js: en tu terminal crea una carpeta con mkdir gptoss-node y accede con cd gptoss-node; inicializa con npm init -y e instala dependencias simples como npm install node-fetch.

Paso 2 - Cliente de chat en JavaScript: crea el archivo chat.js y construye un bucle interactivo que capture la entrada del usuario, mantenga un historial de mensajes y envíe POST a la API REST de Ollama en https://localhost:11434/api/chat especificando el modelo gpt-oss:20b y la lista de mensajes para conservar el contexto entre turnos.

El script puede usar readline para interacción en consola y hacer fetch a Ollama para obtener la respuesta del asistente; guarda cada intercambio en la historia para que las respuestas sean contextuales y coherentes.

Paso 3 - Ejecutar el chat: asegúrate de que Ollama está corriendo en segundo plano y lanza node chat.js para tener un chatbot completamente local que responde desde tu propia máquina sin claves API ni conexión obligatoria a internet.

Qué puedes hacer después: implementar recuperación aumentada por generación RAG con embeddings y búsqueda vectorial para preguntas sobre documentos; conectar herramientas y bases de datos para llamadas a APIs desde el modelo; crear asistentes de código que generen snippets y explicaciones localmente; y orquestar múltiples agentes IA para sistemas multiagente.

JavaScript facilita empaquetar esta funcionalidad en una web app usando frameworks como Next.js o Express y expandir capacidades hacia aplicaciones a medida y software a medida orientado a soluciones empresariales.

Sobre Q2BSTUDIO: Q2BSTUDIO es una empresa de desarrollo de software que ofrece aplicaciones a medida y software a medida, con especialización en inteligencia artificial, ia para empresas y ciberseguridad. Proveemos servicios cloud aws y azure, servicios inteligencia de negocio y consultoría en agentes IA y Power BI para impulsar la analítica y la toma de decisiones. Nuestro equipo diseña soluciones privadas y escalables, desde asistentes locales hasta plataformas seguras integradas con la nube.

Palabras clave y servicios destacados: aplicaciones a medida, software a medida, inteligencia artificial, ciberseguridad, servicios cloud aws y azure, servicios inteligencia de negocio, ia para empresas, agentes IA, Power BI.

Resumen: en este artículo aprendiste a configurar un proyecto Node.js, instalar dependencias como node-fetch, conectar un bucle de chat con Ollama para comunicarse con GPT-OSS, mantener historial de conversación para respuestas contextuales y planear extensiones hacia RAG, agentes IA y aplicaciones web. Si quieres llevar esta arquitectura a producción o desarrollar una solución personalizada, contacta a Q2BSTUDIO para crear software a medida seguro y optimizado para tus objetivos empresariales.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Artificial intelligence

AI agents, chatbots, and intelligent assistants that automate tasks and serve your customers 24/7 to improve the efficiency of your business.

More info

Software Development

Web, mobile, and desktop applications, intranets, e-commerce, SaaS, and management platforms designed for your company's specific needs.

More info

Cloud services

Migration, infrastructure, managed hosting, high availability, and security on Microsoft Azure and Amazon Web Services to help your business scale without limits.

More info

Cybersecurity and pentesting

Security audits, penetration testing and protection of applications, data and infrastructure on-premise and cloud, with ethical hacking and regulatory compliance.

More info

Business Intelligence

Dashboards and data analysis with Power BI: we integrate your sources, design dashboards and KPIs and turn your data into decisions.

More info

Process automation

We automate repetitive tasks and connect your applications with n8n, Power Automate, Make, and RPA, eliminating manual work and increasing productivity.

More info

Training for Companies

We train your teams in technology with criteria: web development, databases, Git, best practices and security, automation with n8n, artificial intelligence for companies and creation of AI solutions with Azure AI Foundry.

More info

Code Auditing

We audit the code that you, your team or an AI create: we tell you what is good and what to improve, we secure it and make it ready for production, web or app.

More info

AI Image Generation

We create for you the images that your business needs with artificial intelligence: product, networks, advertising, illustration and avatars. You tell us what you want and we deliver it ready to use.

More info

AI Video Generation

We create videos with artificial intelligence for you: promotional, networking, virtual presenters, dubbing and animations. You tell us the idea and we will deliver it assembled and ready to publish.

More info

AI Conversational Avatars

We create conversational avatars with AI – digital humans with a face and voice – that serve your customers and teams with the knowledge of your company, on your website, interactive monitors, WhatsApp or Teams.

More info

Online Marketing and AI

Google Ads, Meta Ads, LinkedIn Ads and AI Engine Positioning (GEO/AEO): we attract customers and make your brand appear where they search for you, also on ChatGPT, Gemini and Perplexity.

More info

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.

Live Chat