CoolFace
Apppublic

plop-internal/responses.js

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes
App README

responses.js

A lightweight Express.js server that implements a translation layer between the two main LLM APIs currently available, Responses API and Chat Completions. Works with any Chat Completion API, local or remotely hosted.

๐ŸŽฎ Live Demo

**Try responses.js right now, no installation needed!**

โœจ Features

  • โ€”ResponsesAPI: Partial implementation of OpenAI's Responses API, on top of Chat Completion API
  • โ€”Provider Agnostic: Works with any Chat Completion API (local or remote)
  • โ€”Streaming Support: Support for streamed responses
  • โ€”Structured Output: Support for structured data responses (e.g. jsonschema)
  • โ€”Function Calling: Tool and function calling capabilities
  • โ€”Multi-modal Input: Text and image input support
  • โ€”Remote MCP: Execute MCP tool calls remotely
  • โ€”Demo UI: Interactive web interface for testing

Not implemented: remote function calling, file upload, stateful API, etc.

๐Ÿš€ Quick Start

Prerequisites

  • โ€”Node.js (v18 or higher)
  • โ€”pnpm (recommended) or npm
  • โ€”an Hugging Face token with inference permissions. Create one from your user settings.

Installation & Setup

bash
# Clone the repository
git clone https://github.com/huggingface/responses.js.git
cd responses.js

# Install dependencies
pnpm install

# Start the development server
pnpm dev

The server will be available at http://localhost:3000.

Running Examples

Explore the various capabilities with our example scripts located in the ./examples folder:

bash
# Basic text input
pnpm run example text

# Multi-turn conversations
pnpm run example multi_turn

# Text + image input
pnpm run example image

# Streaming responses
pnpm run example streaming

# Structured output
pnpm run example structured_output
pnpm run example structured_output_streaming

# Function calling
pnpm run example function
pnpm run example function_streaming

๐Ÿงช Testing

Important Notes

  • โ€”Server must be running (pnpm dev) on http://localhost:3000
  • โ€”API_KEY environment variable set with your LLM provider's API key
  • โ€”Tests use real inference providers and may incur costs
  • โ€”Tests are not run in CI due to billing requirements

Running Tests

bash
# Run all tests
pnpm test

# Run specific test patterns
pnpm test --grep "streaming"
pnpm test --grep "function"
pnpm test --grep "structured"

Interactive Demo UI

Experience the API through our interactive web interface, adapted from the openai-responses-starter-app.

![Demo Video](https://youtu.be/F-tAUnW-nd0)

Setup
  1. 1.Create a configuration file:
bash
# Create demo/.env
cat > demo/.env << EOF
MODEL="moonshotai/Kimi-K2-Instruct:groq"
OPENAI_BASE_URL=http://localhost:3000/v1
OPENAI_API_KEY=${HF_TOKEN:-<your-huggingface-token>}
EOF
  1. 1.Install demo dependencies:
bash
pnpm demo:install
  1. 1.Launch the demo:
bash
pnpm demo:dev

The demo will be available at http://localhost:3001.

๐Ÿณ Running with Docker

You can run the server in a production-ready container using Docker.

Build the Docker image

bash
docker build -t responses.js .

Run the server

bash
docker run -p 3000:3000 responses.js

The server will be available at http://localhost:3000.

๐Ÿ“ Project Structure

responses.js/
โ”œโ”€โ”€ demo/             # Interactive chat UI demo
โ”œโ”€โ”€ examples/         # Example scripts using openai-node client
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ index.ts      # Application entry point
โ”‚   โ”œโ”€โ”€ server.ts     # Express app configuration and route definitions
โ”‚   โ”œโ”€โ”€ routes/       # API route implementations
โ”‚   โ”œโ”€โ”€ middleware/   # Middleware (validation, logging, etc.)
โ”‚   โ””โ”€โ”€ schemas/      # Zod validation schemas
โ”œโ”€โ”€ scripts/          # Utility and build scripts
โ”œโ”€โ”€ package.json      # Package configuration and dependencies
โ””โ”€โ”€ README.md         # This file

๐Ÿ›ฃ๏ธ Done / TODOs

Note: This project is in active development. The roadmap below represents our current priorities and may evolve. Do not take anything for granted.
  • โ€”[x] OpenAI types integration for consistent output
  • โ€”[x] Streaming mode support
  • โ€”[x] Structured output capabilities
  • โ€”[x] Function calling implementation
  • โ€”[x] Repository migration to dedicated responses.js repo
  • โ€”[x] Basic development tooling setup
  • โ€”[x] Demo application with comprehensive instructions
  • โ€”[x] Multi-turn conversation fixes for text messages + tool calls
  • โ€”[x] Correctly return "usage" field
  • โ€”[x] MCP support (non-streaming)
  • โ€”[x] MCP support (streaming)
  • โ€”[ ] Tools execution (web search, file search, image generation, code interpreter)
  • โ€”[ ] Background mode support
  • โ€”[ ] Additional API routes (GET, DELETE, CANCEL, LIST responses)
  • โ€”[ ] Reasoning capabilities

๐Ÿค Contributing

We welcome contributions! Please feel free to submit issues, feature requests, or pull requests.

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments