Overview
This node provides ultra-fast AI chat completions using Cerebras AI models. It allows users to send a prompt and system instructions to a selected Cerebras language model and receive generated text completions in response. This is useful for scenarios such as building conversational agents, generating content, summarizing text, or any task requiring natural language generation.
Practical examples include:
- Creating a chatbot that answers user questions based on custom prompts.
- Generating creative writing or code snippets by specifying detailed instructions.
- Automating customer support replies with tailored system messages guiding the assistant’s behavior.
Properties
| Name | Meaning |
|---|---|
| Model | The Cerebras AI model to use for chat completion. Options include GPT OSS 120B, Llama variants, Qwen models, etc. |
| Prompt | The message or query sent to the AI model to generate a response. |
| System Message | Instructions or context provided to the AI model to guide its responses (default: "You are a helpful AI assistant."). |
| Options | Additional parameters to customize the AI model's output: |
| - Frequency Penalty | Penalizes repeated tokens based on their frequency to reduce repetition. Range: -2 to 2. |
| - Max Tokens | Maximum number of tokens to generate in the response. Range: 1 to 65536. |
| - Presence Penalty | Penalizes repeated tokens based on presence to encourage new topics. Range: -2 to 2. |
| - Temperature | Controls randomness of output; lower values make output more deterministic. Range: 0 to 2. |
| - Top P | Controls diversity via nucleus sampling; value between 0 and 1. |
Output
The node outputs an array of JSON objects, each containing:
model: The name of the Cerebras model used.prompt: The original prompt sent to the AI.response: The generated text completion from the AI.usage: Token usage statistics returned by the API (e.g., tokens consumed).finishReason: Reason why the generation stopped (e.g., length limit reached).
No binary data output is produced by this node.
Dependencies
- Requires an API key credential for accessing the Cerebras AI API.
- Uses the official OpenAI-compatible client library configured to communicate with Cerebras API endpoint at
https://api.cerebras.ai/v1. - The node expects the API key to be set up in n8n credentials under a generic API key credential type.
Troubleshooting
- Missing Prompt Error: If the prompt input is empty, the node throws an error indicating that the prompt is required. Ensure you provide a non-empty prompt.
- API Errors: If the Cerebras API returns an error (e.g., invalid API key, rate limits, or server issues), the node surfaces the HTTP status code and message. Verify your API key validity and network connectivity.
- Parameter Validation: Input parameters like max tokens, temperature, and penalties have defined ranges. Providing out-of-range values may cause errors or unexpected behavior.
- Timeouts or Slow Responses: Although designed for ultra-fast completions, network latency or large token requests might delay responses. Adjust max tokens or retry later if timeouts occur.
Links and References
- Cerebras AI Official Website
- OpenAI Chat Completion API Documentation (for general understanding of chat completion parameters)
- n8n Documentation on Creating Custom Nodes