Chat Completion
AI-generatedOverview
This node interacts with the SmartGent chat completions API to generate chat completions based on provided messages and model selection. It is useful for automating conversational AI tasks such as customer support, virtual assistants, or any scenario requiring AI-generated chat responses. Users can specify the model, input messages with roles and content types, and customize the response format including structured JSON outputs.
Use Case Examples
- Generating a chat response from a user message using a selected AI model.
- Creating structured JSON responses for integration with other systems.
- Enabling 'thinking mode' to control token budget for response generation.
Properties
| Name | Meaning |
|---|---|
| Model Name or ID | The AI model to use for generating the chat completion. Users can select from a list or specify an ID via expression. |
| Messages | The list of messages to generate chat completions for, including roles (system, user, assistant) and content types (text or mixed with files). |
| Response Format | The format of the response, which can be default, forced JSON object, or structured JSON schema. |
| Structured Output | Details for the structured JSON schema output, including schema name and JSON schema definition. |
| Enable Thinking | Whether to enable thinking mode that uses a token budget for response generation. |
| Budget Tokens | The maximum number of tokens to use for thinking mode, applicable only if thinking is enabled. |
| Temperature | Controls randomness in the response generation, where 0 is deterministic and 2 is very random. |
Output
JSON
json- The full response data returned from the SmartGent chat completions API, including generated chat completions and metadata.
Dependencies
- SmartGent API key credential
Troubleshooting
- Common issues include invalid or missing API credentials, which will cause authentication failures.
- Malformed JSON schema in structured output will cause errors; ensure the schema JSON is valid.
- Network or API endpoint errors may occur; verify the base URL and network connectivity.
- If 'thinking mode' is enabled without specifying a token budget, the node may not behave as expected.
Links
- n8n Expressions Documentation - Reference for using expressions to specify dynamic values such as model ID.