Chat Completions (Artifacts)

Generate and edit standalone OpenUI Cloud presentations and reports with a Chat Completions-compatible endpoint.

The Artifact Chat Completions API generates a standalone slide deck or report as an OpenUI Lang program. Use it when the artifact lifecycle is separate from an agent's Responses stream.

Endpoint: POST https://api.thesys.dev/v1/artifact/chat/completions

Use the artifactClient from the API overview, which covers authentication, base URLs, models, and shared configuration.

Generate an artifact

Every request includes metadata.thesys as a JSON string with your artifact id and a c1_artifact_type of "slides" or "report".

const artifact = await artifactClient.chat.completions.create({
  model: "openai/gpt-5",
  messages: [{ role: "user", content: "Create a three-slide deck on Q4 results." }],
  metadata: {
    thesys: JSON.stringify({
      id: "art_1",
      c1_artifact_type: "slides",
    }),
  },
});

const program = artifact.choices[0].message.content;

The response content is a raw OpenUI Lang program rooted at SlideShow or ReportView. OpenUI Cloud validates and repairs it before returning it. Set stream: true to receive the program progressively.

Render an artifact

Render the returned program with the matching managed viewer:

import { Presentation, Report } from "@openuidev/thesys";
import "@openuidev/thesys/styles.css";

export function Artifact({ kind, program }: { kind: "slides" | "report"; program: string }) {
  return kind === "slides" ? (
    <Presentation response={program} preview={false} />
  ) : (
    <Report response={program} preview={false} />
  );
}

Pass isStreaming while accumulating a streamed program.

Edit an artifact

Send the current OpenUI Lang program as an assistant message, describe the change in the next user message, and set is_edit: true.

const edited = await artifactClient.chat.completions.create({
  model: "openai/gpt-5",
  messages: [
    { role: "assistant", content: previousProgram },
    { role: "user", content: "Make slide 2 about European revenue." },
  ],
  metadata: {
    thesys: JSON.stringify({
      id: "art_1",
      c1_artifact_type: "slides",
      is_edit: true,
    }),
  },
  stream: true,
});

The response is a patch-mode OpenUI Lang program merged against the assistant-message base.

Use the Responses API instead when artifacts should be stored, opened, and edited as part of a persistent agent conversation.

On this page