Skip to content

Examples and guides for using the OpenAI API

369 B
Raw Blame
"""Configuration shared by the two command-line apps."""

import json
import os


def api_key():
    key = os.environ.get("OPENAI_API_KEY", "").strip()
    if not key:
        raise ValueError("Set OPENAI_API_KEY to run a live call.")
    return key


def save(path, value):
    path.write_text(json.dumps(value, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")