import type { Request, Response } from "express"; export function getLandingPageHtml(req: Request, res: Response): void { const baseUrl = `${req.protocol}://${req.get("host")}/v1`; res.setHeader("Content-Type", "text/html; charset=utf-8"); res.send(` responses.js – OpenAI-compatible Responses API

OpenAI-compatible Responses API

responses.js is an open-source, lightweight server implementing OpenAI's Responses API, built on top of Chat Completions and powered by Hugging Face Inference Providers.

API Endpoint:
${baseUrl}/responses
Get started by sending requests to this endpoint
View on GitHub
OpenAI-compatible
Stateless implementation of the Responses API
Inference Providers
Powered by Hugging Face Inference Providers
Multi-modal
Text and image input support
Streaming, & Structured Output
Supports streaming, JSON schema, and function calling

Examples

import OpenAI from "openai";

const openai = new OpenAI({
  baseURL: "http://localhost:3000/v1",
  apiKey: "YOUR_API_KEY_HERE", // visit https://huggingface.co/settings/tokens
});

const response = await openai.responses.create({
  model: "Qwen/Qwen2.5-VL-7B-Instruct",
  instructions: "You are a helpful assistant.",
  input: "Tell me a three sentence bedtime story about a unicorn.",
});

console.log(response);
console.log(response.output_text);
import OpenAI from "openai";

const openai = new OpenAI({
  baseURL: "${baseUrl}",
  apiKey: "YOUR_API_KEY_HERE", // visit https://huggingface.co/settings/tokens
});

const response = await openai.responses.create({
  model: "Qwen/Qwen2.5-VL-7B-Instruct",
  input: [
    {
      role: "user",
      content: [
        { type: "input_text", text: "what is in this image?" },
        {
          type: "input_image",
          image_url: "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
        }
      ]
    }
  ]
});

console.log(response);
console.log(response.output_text);
import OpenAI from "openai";

const openai = new OpenAI({
  baseURL: "http://localhost:3000/v1",
  apiKey: "YOUR_API_KEY_HERE", // visit https://huggingface.co/settings/tokens
});
const response = await openai.responses.create({
  model: "Qwen/Qwen2.5-VL-7B-Instruct",
  input: [
    {
      role: "developer",
      content: "Talk like a pirate.",
    },
    {
      role: "user",
      content: "Are semicolons optional in JavaScript?",
    },
  ],
});

console.log(response);
console.log(response.output_text);
import { OpenAI } from "openai";
const openai = new OpenAI({
  baseURL: "http://localhost:3000/v1",
  apiKey: "YOUR_API_KEY_HERE", // visit https://huggingface.co/settings/tokens
});

const stream = await openai.responses.create({
  model: "hyperbolic@Qwen/Qwen2.5-VL-7B-Instruct",
  input: [
    {
      role: "user",
      content: "Say 'double bubble bath' ten times fast.",
    },
  ],
  stream: true,
});

for await (const event of stream) {
  console.log(event);
}
import OpenAI from "openai";

const openai = new OpenAI({
  baseURL: "${baseUrl}",
  apiKey: "YOUR_API_KEY_HERE", // visit https://huggingface.co/settings/tokens
});

const tools = [
  {
    type: "function",
    name: "get_current_weather",
    description: "Get the current weather in a given location",
    parameters: {
      type: "object",
      properties: {
        location: { type: "string", description: "The city and state, e.g. San Francisco, CA" },
        unit: { type: "string", enum: ["celsius", "fahrenheit"] }
      },
      required: ["location", "unit"]
    }
  }
];

const response = await openai.responses.create({
  model: "cerebras@meta-llama/Llama-3.3-70B-Instruct",
  tools: tools,
  input: "What is the weather like in Boston today?",
  tool_choice: "auto"
});

console.log(response);
import OpenAI from "openai";
import { zodTextFormat } from "openai/helpers/zod";
import { z } from "zod";

const openai = new OpenAI({
  baseURL: "http://localhost:3000/v1",
  apiKey: "YOUR_API_KEY_HERE", // visit https://huggingface.co/settings/tokens
});

const Step = z.object({
  explanation: z.string(),
  output: z.string(),
});

const MathReasoning = z.object({
  steps: z.array(Step),
  final_answer: z.string(),
});

const response = await openai.responses.parse({
  model: "novita@meta-llama/Meta-Llama-3-70B-Instruct",
  input: [
    {
      role: "system",
      content: "You are a helpful math tutor. Guide the user through the solution step by step.",
    },
    { role: "user", content: "how can I solve 8x + 7 = -23" },
  ],
  text: {
    format: zodTextFormat(MathReasoning, "math_reasoning"),
  },
});

console.log(response.output_parsed);
`); }