Skip to main content
Generating an artifact involves making an API call to a dedicated C1 endpoint. This is done using a standard OpenAI client library, configured to connect to the C1 Artifacts service.

Configuring the API Client

To begin, initialize your OpenAI client to use the C1 Artifacts endpoint and your Thesys API key. Artifact API Endpoint: https://api.thesys.dev/v1/artifact
You can create a new API key from Developer Console.
import OpenAI from "openai";

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

Structuring the Request

The API call’s payload has two main parts:
  • messages array for your prompt
  • metadata object for C1-specific instructions.

The messages Array

This is where you provide the prompt to generate the artifact. The content of the user message can include rich context, like data or a detailed description of the desired output. You can also include a system prompt to provide high-level instructions.

The metadata Object

This object provides C1-specific instructions for the generation. It must contain a thesys key, whose value is a stringified JSON object. Inside the thesys object, the c1_artifact_type property tells C1 what kind of artifact to generate, for example 'slides' or 'report'.
{
  "c1_artifact_type": "slides", // or 'report' for generating a report
  "id": "unique-id-for-the-artifact"
}

Full Example: Generating Slides

This example brings the concepts together to generate a slide deck from a prompt. The artifact variable in the response will contain the C1 DSL string, which is ready to be sent to your frontend for rendering.
src/app/api/generate-slides/route.ts
import { NextRequest, NextResponse } from "next/server";
import OpenAI from "openai";

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

export async function POST(req: NextRequest): Promise<NextResponse> {
  const artifact = await client.chat.completions.create({
    model: "c1/artifact/v-20251030", // Specify the model
    messages: [
      {
        role: 'system',
        content: 'system prompt here: it can include high-level instructions or context for the generation.',
      },
      {
        role: 'user',
        content: 'Generate a presentation showcasing the top 10 AI tools that can transform business operations, with implementation timelines and ROI calculations.',
      },
    ],
    metadata: {
      thesys: JSON.stringify({
        c1_artifact_type: 'slides',
        id: 'unique-id-for-the-artifact', // this is required for editing the artifact in future
      }),
    }
  });

  // artifact.choices[0].message.content contains the C1 DSL string for the generated artifact
  return { "content": artifact.choices[0].message.content };
}