Nodes/Eden.art nodesuite/Eden_GPTStructuredOutput
ComfyUI Node Runs on cloud

Eden_GPTStructuredOutput

LLMs mumble; this node forces them to fill in your form

By edenartlabΒ·Created 3 years agoΒ·Updated 6 months agoΒ· 119
Eden_GPTStructuredOutput
    • STRING
    β—„promptGenerate a structured response about the given topicβ–Ί
    β—„system_promptYou are a helpful assistant that generates structured JSON responses.β–Ί
    β—„json_schema{ "type": "object", "properties": { "title": {"type": "string"}, "description": {"type": "string"}, "key_points": {"type": "array", "items": {"type": "string"}} }, "required": ["title", "description", "key_points"] }β–Ί
    β—„max_tokens1000β–Ί
    β—„modelgpt-4oβ–Ί
    β—„seed0β–Ί
    β—„temperature0.7β–Ί

    Eden_GPTStructuredOutput is the answer to a specific frustration: LLMs don't reliably return data in a shape you can use. You ask for a JSON object and get a paragraph with a JSON object somewhere inside it. This node forces the model into JSON mode - you paste a schema, it returns a string that's actually parseable JSON.

    How it works

    The mechanism is twofold. First, the node takes your json_schema and appends it to your system_prompt with an explicit instruction: "You must respond with a valid JSON object that strictly follows this schema. Do not include any explanations or text outside the JSON object." Second, it calls the API with response_format={"type": "json_object"}, which is OpenAI's native JSON mode - the model is constrained to emit valid JSON rather than prose.

    The schema field defaults to a simple {title, description, key_points} object so you can test immediately without writing JSON.

    Inputs

    • prompt - what you want generated ("a structured response about the given topic").
    • system_prompt - the assistant's role; gets the schema appended to it.
    • json_schema - a JSON schema string. This is the important one.
    • max_tokens (default 1000), model (gpt-4o / gpt-4-turbo), seed, and optional temperature (default 0.7).

    Output is one STRING containing the JSON.

    The trap: it returns a string, not a dict

    Here's where people get burned. The output type is STRING - a chunk of JSON text, not a structured object you can pull key_points out of directly. To actually use the fields you need a JSON-parse node downstream, or a string-processing node like Eden_StringReplace or a regex node to slice out values. In a purely visual graph this is the missing piece that turns a great idea into a hassle. If your goal is "generate 20 seed keywords," plan the parsing step in advance.

    Realistic expectations on the schema

    JSON mode guarantees valid JSON syntax, not schema compliance. A well-formed schema in the system prompt gets you most of the way, but the model can still invent fields or drop an optional one. Keep schemas small, include required, and validate with a parser before feeding values into something that will hard-fail on a missing key. If you paste malformed JSON in the schema field, expect errors downstream.

    Setup

    Install the pack via ComfyUI Manager (search "Eden.art nodesuite") or git clone https://github.com/edenartlab/eden_comfy_pipelines into custom_nodes/, then pip install -r requirements.txt. You need OPENAI_API_KEY in a .env file in the ComfyUI root - without it the node returns an error string, same as the rest of Eden's GPT family. And remember each run is a paid API call; at max_tokens 1000 you're spending real money per queue, so tighten it once the schema is working.

    CategoryEden 🌱

    Inputs (7)

    NameTypeDefaultDescription
    promptSTRINGGenerate a structured response about the given topicβ€”
    system_promptSTRINGYou are a helpful assistant that generates structured JSON responses.β€”
    json_schemaSTRING{ "type": "object", "properties": { "title": {"type": "string"}, "description": {"type": "string"}, "key_points": {"type": "array", "items": {"type": "string"}} }, "required": ["title", "description", "key_points"] }β€”
    max_tokensINT10001–9223372036854776000β€”
    modelCOMBOgpt-4o2 options: gpt-4o, gpt-4-turbo
    seedINT00–9223372036854776000β€”
    temperatureoptFLOAT0.70–2β€”

    Outputs (1)

    NameTypeDescription
    STRINGSTRINGβ€”