Nodes/civitai-comfy-nodes/Civitai Chat Completion
ComfyUI Node

Civitai Chat Completion

OpenAI-style chat completions with JSON, tools, and even image output — wired into your graph

By civitai·Created 2 months ago·Updated about a month ago· 42
Civitai Chat Completion
  • api_config
  • id
  • object
  • created
  • model
  • choices
  • usage
  • system_fingerprint
  • parsed
  • workflow_id
  • raw_json
model
messages_json
temperature1.00
top_p1.00
max_tokens1
n1
stop_json
presence_penalty0.00
frequency_penalty0.00
seed0
user
tools_json
tool_choice_json
modalities_json
image_config_json
response_format_json

The simple chat node in this pack is a wrapper; Civitai Chat Completion is the actual engine. It's an OpenAI-compatible chat-completion call with the whole parameter surface exposed - temperature, penalties, tools, structured JSON output - and it's the node you reach for when a single prompt-in/prompt-out wrapper isn't enough.

What it is

A chat completion step on Civitai's orchestration API. You hand it a model name and a messages_json array (the standard [{role, content}, ...] shape), and it returns the response plus every OpenAI field you'd expect. No local model, no VRAM - every call is billed in Buzz, same as the rest of the pack.

Inputs that matter

Required: model (e.g. "gpt-4o", "gpt-4-turbo", "gpt-4o-mini") and messages_json - a JSON array of messages, as text. This is one of the pack's "freeform structures stay JSON text" inputs, so you paste or compute the JSON string; the node validates it before submitting and errors locally if it doesn't parse.

The optional list is long but only a few earn your attention:

  • max_tokens (default 1 - remember to raise it), temperature (0–2), top_p - the usual sampling controls.
  • tools_json and tool_choice_json - define tools the model can call; tool_choice can be "auto", "none", "required", or an object naming a specific function.
  • response_format_json - when set to json_object or json_schema, the emitted content is parsed server-side and surfaced on the parsed output, which downstream steps can reference field-by-field (e.g. output.parsed.<field> via $ref). This is the structured-output path for building agents that produce data, not prose.
  • modalities_json - default text-only; include "image" and the request routes to the image generation pipeline, returning generated images on the assistant message. That's the wildcard: one node that can hand back pictures.
  • n - how many completions to generate.

Outputs

Ten of them, and the useful ones are: choices (the completions), usage (token counts - watch this on your Buzz bill), parsed (the structured-JSON result), and model/id/created for bookkeeping. Plus the pack-standard workflow_id and raw_json.

Install & gotchas

Same pack install as everything here - ComfyUI Manager (search Civitai Comfy Nodes), comfy node registry-install civitai-comfy-nodes, or git clone + pip install -r requirements.txt. Auth via CIVITAI_API_TOKEN, stored OAuth, or a wired Civitai Auth node.

Where beginners trip:

  1. The default max_tokens is 1. The schema default really is 1, so a fresh node returns a single token until you raise it. Bump to a few hundred.
  2. messages_json must be valid JSON or the node fails fast with "Input 'messages_json' is not valid JSON". Single quotes will bite you - it needs proper JSON quoting.
  3. Cost visibility. Every call is metered. raw_json includes usage/cost info; get in the habit of reading it on expensive runs. A 402 means out of Buzz.
  4. It's a hosted frontier model, so filtering follows the provider. Unlike a local abliterated LLM, there are no weights to patch - whatever the service refuses, the node refuses.

Honest take: for a one-off text job, Civitai Chat (Simple) is friendlier. This node earns its complexity when you need tools, JSON output, or multimodal results inside a real workflow - that's where having an OpenAI-grade chat API as a graph node actually shines.

CategoryCivitai/Text

Inputs (17)

NameTypeDefaultDescription
modelSTRINGThe model to use for chat completion. Examples: "gpt-4o", "gpt-4-turbo", "gpt-4o-mini"
messages_jsonSTRINGThe messages to generate a completion for.
temperatureoptFLOAT1.000–2Temperature for sampling (0-2). Higher values make output more random.
top_poptFLOAT1.000–1Nucleus sampling parameter. Consider tokens with top_p probability mass.
max_tokensoptINT11–128000Maximum number of tokens to generate.
noptINT11–128Number of completions to generate.
stop_jsonoptSTRINGUp to 4 sequences where the API will stop generating tokens.
presence_penaltyoptFLOAT0.00-2–2Presence penalty (-2.0 to 2.0). Positive values penalize new tokens based on whether they appear in the text so far.
frequency_penaltyoptFLOAT0.00-2–2Frequency penalty (-2.0 to 2.0). Positive values penalize new tokens based on their existing frequency in the text.
seedoptINT00–4294967295Seed for deterministic sampling (beta feature).
useroptSTRINGA unique identifier for the end-user.
tools_jsonoptSTRINGTool definitions available for the model to call.
tool_choice_jsonoptSTRINGControls which (if any) tool is called by the model. Can be "auto", "none", "required", or an object specifying a particular function.
modalities_jsonoptSTRINGOutput modalities the model should produce. Defaults to text-only when omitted. Supported values: "text", "image". When "image" is included, the request is routed to the image generation pipeline and returns generated images on the assistant message.
image_config_jsonoptSTRINGImage generation parameters used when Civitai.Orchestration.Grains.Workflows.Steps.ChatCompletion.ChatCompletionInput.Modalities contains "image". Mirrors OpenRouter's `image_config` shape on chat-completion requests.
response_format_jsonoptSTRINGOpenAI-compatible response_format. When Civitai.Orchestration.Grains.Workflows.Steps.ChatCompletion.ChatCompletionResponseFormat.Type is `json_object` or `json_schema`, the LLM-emitted content is parsed as JSON server-side and exposed on Civitai.Orchestration.Grains.Workflows.Steps.ChatCompletion.ChatCompletionOutput.Parsed, allowing downstream workflow steps to reference individual fields via `$ref` paths like `output.parsed.<field>`.
api_configoptCIVITAI_CONFIGOptional Civitai Auth connection; defaults to CIVITAI_API_TOKEN or stored OAuth login.

Outputs (10)

NameTypeDescription
idSTRING
objectSTRING
createdSTRING
modelSTRING
choicesSTRING
usageSTRING
system_fingerprintSTRING
parsedSTRING
workflow_idSTRING
raw_jsonSTRING