Skip to main content
Artifact Creator builds new code, documents, applications, scripts, and structured content from scratch. Everything it produces is automatically saved to the Artifacts folder in your Space.

Quick Start

import requests

response = requests.post(
    "https://api.zarkai.xyz/v1/chat",
    headers={
        "x-api-key": "your_api_key",
        "Content-Type": "application/json",
    },
    json={
        "messages": [
            {"role": "user", "content": "Write a Python script that reads a CSV file and calculates monthly averages"}
        ],
        "workspace_id": "wks-xxxxx",
        "tools": ["artifact"],
        "tool_choice": "auto",
    },
)

data = response.json()
print(data["response"])

What It Creates

TypeExamples
CodePython scripts, JavaScript apps, HTML pages, API clients, automation scripts
DocumentsReports, summaries, guides, analysis documents, proposals
ApplicationsInteractive dashboards, calculators, forms, tools
Data processingETL pipelines, data transformation scripts, batch operations

Working with File Context

Reference existing files to build artifacts based on their contents:
{
  "messages": [
    {"role": "user", "content": "Create a summary report based on this data"}
  ],
  "workspace_id": "wks-xxxxx",
  "tools": ["artifact"],
  "file_ids": ["file-data123"],
  "tool_choice": "auto"
}

Managing Artifacts

Artifact Creator also handles questions about artifacts created in the current chat session:
{
  "messages": [
    {"role": "user", "content": "Where was that artifact saved?"}
  ],
  "workspace_id": "wks-xxxxx",
  "tools": ["artifact"],
  "tool_choice": "auto"
}
{
  "messages": [
    {"role": "user", "content": "Edit the report to add a conclusion section"}
  ],
  "workspace_id": "wks-xxxxx",
  "tools": ["artifact"],
  "tool_choice": "auto"
}
For managing artifacts from previous sessions or browsing all saved artifacts, use File Manager — they’re saved files like anything else in your Space.

Streaming

Python
import requests
import json

response = requests.post(
    "https://api.zarkai.xyz/v1/chat",
    headers={"x-api-key": "your_api_key", "Content-Type": "application/json"},
    json={
        "messages": [{"role": "user", "content": "Build a calculator app for compound interest"}],
        "workspace_id": "wks-xxxxx",
        "tools": ["artifact"],
        "stream": True,
    },
    stream=True,
)

for line in response.iter_lines():
    if line:
        event = json.loads(line.decode("utf-8").removeprefix("data: "))
        if event["type"] == "media_item":
            print(f"Artifact saved: {event['file_id']}")
        elif event["type"] == "ai_chunk":
            print(event["content"], end="", flush=True)
        elif event["type"] == "ai_complete":
            print(f"\n\nDone.")

Streaming Events

EventDescription
media_itemCreated artifact file reference with file_id and metadata
ai_chunkIncremental text — code, document content, or descriptions
ai_completeFinal response with artifact reference

What Artifact Creator Is Not

Artifact Creator builds new content. It cannot search, list, or retrieve your existing uploaded files — that’s File Manager. The key distinction from Code Runner: Artifact Creator creates code as a saved file. Code Runner executes code and returns results.

Examples

Create a Python script that scrapes product prices and saves to CSV
Write a comprehensive guide on setting up a CI/CD pipeline
Build a calculator app for compound interest
Draft a weekly newsletter template in HTML
Create a REST API client for the Stripe API in Python
Create a report comparing Q3 and Q4 performance based on the data I uploaded