Zero-Shot Answer
Zero-Shot Answer Doesn't Call Anything — It Just Picks One Answer Out of the JSON
- value
- score
- confidence
If you go looking for "Zero-Shot Answer" expecting a model, you'll be disappointed for about ten seconds and then relieved. No server call, no key, no VRAM. It reads the JSON that Zero-Shot Classification handed you, pulls out one question's answer, and gives your graph a string and two floats. It's a dictionary lookup with three output shapes - learn the three and you never need to read its source again.
The node only makes sense as the second half of a pair. Zero-Shot Classification asks your list of questions in one request against a small local decision model; that's the heavy half. This one turns "four answers to four questions" into "billing, 0.90, 0.80", so you can wire the single value you care about into a prompt, a switch, or a text display.
What it actually does
Two inputs, three outputs, a straight line between them. It calls json.loads on the answers string, indexes it with question_id, and unpacks whatever comes back according to that answer's type.
For a choice question - the model picked one named option - value is that option's id, score is the probability of the option it picked, and confidence is the model's confidence across the question. For a score question, your ordered scale like ["Can wait", "This week", "Today"], value is the description of the nearest level, score is the expected level as a decimal, and confidence is again the model's confidence.
For a noul question - yes/no - value is literally the string "true" or "false" at a 0.5 threshold, score is the probability of true, and confidence is |2p - 1|. That last expression is the subtle one: the node normalises a yes/no into the confidence of an equivalent two-option choice, so a probability of 0.25 reports confidence 0.5 - the model said no, half-heartedly. Threshold on confidence and you're on that normalised scale, not the raw probability.
Inputs and outputs that matter
answers is a link, not a text box - the input is declared forceInput, so no widget renders and you can't paste JSON into it. Wire it from Zero-Shot Classification's answers output and stop thinking about it.
question_id is the one field you set, and it defaults to empty. Fill in the exact key from your questions object - route, urgency, whatever you named it. The lookup is literal dictionary indexing; a typo doesn't fall back to anything, it throws.
Then value (STRING), score (FLOAT), confidence (FLOAT). In practice beginners wire value and let the other two dangle, because value is what goes downstream as a branch, a prompt fragment, or a label. score and confidence are for when you actually want to gate on certainty - skip the expensive upscale when confidence is under 0.6, that sort of thing. Nothing requires you to use all three.
Installing it
The pack is on the Manager. Search ComfyUI-API-Pack by its display name, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/alchemine/comfyui-api-pack
pip install -r comfyui-api-pack/requirements.txt
Then it's under ApiPack/Inference. requirements.txt is one line, python-dotenv, and nothing in this node touches it - that's for the OpenAI and Grok nodes in the same pack. No model downloads at all. You do install the whole pack, though, because the nodes ship together.
Where people get burned
KeyError: ''. You forgot question_id. The default is an empty string and that's not a key in any response. An empty-quoted KeyError is always this.
KeyError: 'route' when route is obviously there. Either the id in question_id doesn't match the id in your questions JSON, or the upstream node never ran. Character for character, no fuzzy matching, no trimming.
A JSON decode error instead of a KeyError. This input expects the classification node's JSON. Point a caption or a prompt string at it and json.loads fails on the spot - which also makes it a bad node to prototype with, since it can't do anything without a real response wired in.
Reading score as if it were confidence. For score-type questions, score is the expected level, so 1.88 means "between This week and Today, leaning Today" - while value has already rounded to Today for you. The number and the word are deliberately different things.
One more thing: this pack is a client that talks to whatever base_url you point it at, and the API-wrapper category has a bad history in this ecosystem - a node that's supposed to phone home is where a malicious one hides. Here the default is a llama-server on your own machine, the repo is GPL-3.0, and nodes/inference.py is one readable file. Read it before you run any pack like this.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| answers | STRING | — | |
| question_id | STRING | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| value | STRING | — |
| score | FLOAT | — |
| confidence | FLOAT | — |