What you’ll learn

• How to set "save": true on /generate so the output becomes new content
• How to retrieve that content with /content/{content_id}

Endpoints used

POST /generate · GET /content/{content_id}

# save_as_you_write.py
#
# 1) Generate a splash-page headline from existing KB
# 2) Retrieve the stored asset for later use

import os, requests, time
API = "https://sdk.senso.ai/api/v1"
HDR = {"X-API-Key": os.environ["SENSO_KEY"]}

# 1) WORKSPACE – generate + save
resp = requests.post(
    f"{API}/generate",
    headers=HDR,
    json={
        "content_type": "headline",
        "instructions": "Write a catchy 15-word homepage headline for our product.",
        "save": True
    }
).json()

cid = resp["content_id"]
print("Generated & saved content_id →", cid)

# 2) Fetch stored copy
time.sleep(2)  # small delay to ensure indexing
saved = requests.get(f"{API}/content/{cid}", headers=HDR).json()
print("\nStored text:\n", saved.get("text", "(binary or processing)"))

Run:

export SENSO_KEY=your_api_key
python save_as_you_write.py