Responses API

Responses API

Generate corrected OpenUI Lang with persistent conversations and hosted tools.

Gateway provides OpenAI-compatible Responses API endpoints, letting you use multiple AI providers through a familiar interface. You can use existing OpenAI client libraries, switch to Gateway with a URL change, and keep your current tools and workflows without code rewrites.

The Responses API implements the same specification as the OpenAI Responses API.

Endpoint: POST https://api.thesys.dev/v1/embed/responses

Configure the client

lib/gateway.ts
import OpenAI from "openai";

export const gateway = new OpenAI({
  apiKey: process.env.THESYS_API_KEY,
  baseURL: "https://api.thesys.dev/v1/embed",
});

Make a request

server.ts
import { generateSystemPrompt } from "@openuidev/lang-core";
import { gateway } from "./lib/gateway";
import library from "./openui.spec.json";

const response = await gateway.responses.create({
  model: "openai/gpt-5",
  input: "Compare quarterly revenue by region.",
  instructions: generateSystemPrompt({ cloud: true, library }),
  stream: true,
});

Relay the response stream through your server route without changing its event shape. In the browser, configure the appropriate Agent Interface adapter and message format for the Responses stream.

Conversation history

Choose one state model for each application flow:

PatternUse it when
Send the full history in inputYour application owns all message storage.
Set previous_response_idYou want to chain stored responses without a named thread.
Set conversation and store: trueYou want a persistent thread managed by the Conversations API.
const first = await gateway.responses.create({
  model: "openai/gpt-5",
  input: "Compare quarterly revenue by region.",
  instructions: generateSystemPrompt({ cloud: true, library }),
  store: true,
});

const followUp = await gateway.responses.create({
  model: "openai/gpt-5",
  input: "Focus on Europe and explain the change.",
  instructions: generateSystemPrompt({ cloud: true, library }),
  previous_response_id: first.id,
  store: true,
});

For named threads, see the Conversations API.

Tools

Responses supports Gateway-hosted tools and application-run function tools. See Hosted Tools for declarations and execution ownership.

On this page