Create Artifact
curl --request POST \
--url https://genui.sh/api/artifacts \
--header 'Content-Type: application/json' \
--data '
{
"template": "<string>",
"title": "<string>",
"description": "<string>",
"content": {},
"expiresIn": "<string>",
"metadata": {}
}
'import requests
url = "https://genui.sh/api/artifacts"
payload = {
"template": "<string>",
"title": "<string>",
"description": "<string>",
"content": {},
"expiresIn": "<string>",
"metadata": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
template: '<string>',
title: '<string>',
description: '<string>',
content: {},
expiresIn: '<string>',
metadata: {}
})
};
fetch('https://genui.sh/api/artifacts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://genui.sh/api/artifacts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'template' => '<string>',
'title' => '<string>',
'description' => '<string>',
'content' => [
],
'expiresIn' => '<string>',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://genui.sh/api/artifacts"
payload := strings.NewReader("{\n \"template\": \"<string>\",\n \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"content\": {},\n \"expiresIn\": \"<string>\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://genui.sh/api/artifacts")
.header("Content-Type", "application/json")
.body("{\n \"template\": \"<string>\",\n \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"content\": {},\n \"expiresIn\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://genui.sh/api/artifacts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"template\": \"<string>\",\n \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"content\": {},\n \"expiresIn\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "art_abc123",
"template": "markdown",
"title": "My Document",
"status": "active",
"createdAt": "2024-01-15T12:00:00Z",
"expiresAt": "2024-01-22T12:00:00Z"
}
{
"error": {
"code": "invalid_template",
"message": "Template 'invalid' is not supported"
}
}
Artifacts
Create Artifact
POST
/
api
/
artifacts
Create Artifact
curl --request POST \
--url https://genui.sh/api/artifacts \
--header 'Content-Type: application/json' \
--data '
{
"template": "<string>",
"title": "<string>",
"description": "<string>",
"content": {},
"expiresIn": "<string>",
"metadata": {}
}
'import requests
url = "https://genui.sh/api/artifacts"
payload = {
"template": "<string>",
"title": "<string>",
"description": "<string>",
"content": {},
"expiresIn": "<string>",
"metadata": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
template: '<string>',
title: '<string>',
description: '<string>',
content: {},
expiresIn: '<string>',
metadata: {}
})
};
fetch('https://genui.sh/api/artifacts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://genui.sh/api/artifacts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'template' => '<string>',
'title' => '<string>',
'description' => '<string>',
'content' => [
],
'expiresIn' => '<string>',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://genui.sh/api/artifacts"
payload := strings.NewReader("{\n \"template\": \"<string>\",\n \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"content\": {},\n \"expiresIn\": \"<string>\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://genui.sh/api/artifacts")
.header("Content-Type", "application/json")
.body("{\n \"template\": \"<string>\",\n \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"content\": {},\n \"expiresIn\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://genui.sh/api/artifacts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"template\": \"<string>\",\n \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"content\": {},\n \"expiresIn\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "art_abc123",
"template": "markdown",
"title": "My Document",
"status": "active",
"createdAt": "2024-01-15T12:00:00Z",
"expiresAt": "2024-01-22T12:00:00Z"
}
{
"error": {
"code": "invalid_template",
"message": "Template 'invalid' is not supported"
}
}
Create a new artifact with the specified template and content.
Request
Template type. One of:
markdown, chart, table, pdfDisplay title for the artifact
Short description shown below the title
Expiration duration. Examples:
1h, 7d, 30d. If not set, artifact doesn’t expire.Custom key-value pairs to store with the artifact
Response
Unique artifact ID (format:
art_xxx)The template type used
Display title
Artifact status:
active, expired, deletedISO 8601 timestamp
ISO 8601 expiration timestamp (if set)
{
"id": "art_abc123",
"template": "markdown",
"title": "My Document",
"status": "active",
"createdAt": "2024-01-15T12:00:00Z",
"expiresAt": "2024-01-22T12:00:00Z"
}
{
"error": {
"code": "invalid_template",
"message": "Template 'invalid' is not supported"
}
}
Code Examples
curl -X POST https://genui.sh/api/artifacts \
-H "Authorization: Bearer $GENUI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"template": "markdown",
"title": "My Document",
"content": {"text": "# Hello World\n\nThis is my artifact."},
"expiresIn": "7d"
}'
import requests
import os
response = requests.post(
"https://genui.sh/api/artifacts",
headers={"Authorization": f"Bearer {os.environ['GENUI_API_KEY']}"},
json={
"template": "markdown",
"title": "My Document",
"content": {"text": "# Hello World\n\nThis is my artifact."},
"expiresIn": "7d"
}
)
artifact = response.json()
print(f"Created artifact: {artifact['id']}")
const response = await fetch('https://genui.sh/api/artifacts', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.GENUI_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
template: 'markdown',
title: 'My Document',
content: { text: '# Hello World\n\nThis is my artifact.' },
expiresIn: '7d'
})
});
const artifact = await response.json();
console.log(`Created artifact: ${artifact.id}`);
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
)
func main() {
payload := map[string]interface{}{
"template": "markdown",
"title": "My Document",
"content": map[string]string{"text": "# Hello World\n\nThis is my artifact."},
"expiresIn": "7d",
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://genui.sh/api/artifacts", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("GENUI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("Created artifact: %s\n", result["id"])
}
require 'net/http'
require 'json'
require 'uri'
uri = URI('https://genui.sh/api/artifacts')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Authorization'] = "Bearer #{ENV['GENUI_API_KEY']}"
request['Content-Type'] = 'application/json'
request.body = {
template: 'markdown',
title: 'My Document',
content: { text: '# Hello World\n\nThis is my artifact.' },
expiresIn: '7d'
}.to_json
response = http.request(request)
artifact = JSON.parse(response.body)
puts "Created artifact: #{artifact['id']}"
use reqwest::header::{AUTHORIZATION, CONTENT_TYPE};
use serde_json::json;
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api_key = env::var("GENUI_API_KEY")?;
let client = reqwest::Client::new();
let response = client
.post("https://genui.sh/api/artifacts")
.header(AUTHORIZATION, format!("Bearer {}", api_key))
.header(CONTENT_TYPE, "application/json")
.json(&json!({
"template": "markdown",
"title": "My Document",
"content": {"text": "# Hello World\n\nThis is my artifact."},
"expiresIn": "7d"
}))
.send()
.await?;
let artifact: serde_json::Value = response.json().await?;
println!("Created artifact: {}", artifact["id"]);
Ok(())
}
using System.Net.Http.Json;
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {Environment.GetEnvironmentVariable("GENUI_API_KEY")}");
var response = await client.PostAsJsonAsync("https://genui.sh/api/artifacts", new {
template = "markdown",
title = "My Document",
content = new { text = "# Hello World\n\nThis is my artifact." },
expiresIn = "7d"
});
var artifact = await response.Content.ReadFromJsonAsync<JsonElement>();
Console.WriteLine($"Created artifact: {artifact.GetProperty("id")}");
⌘I