BlocksAI & Machine Learning
ChatGPT
Send a message to OpenAI's ChatGPT models with chat history support.
ChatGPT Block
The ChatGPT Block allows you to seamlessly integrate OpenAI's language models into your API endpoint flows. It supports generating text responses based on a provided prompt, maintaining conversation history, and fine-tuning the model's behavior through advanced settings.
Configuration
| Field | Required | Description |
|---|---|---|
| API Key | ✅ | Your OpenAI API key (usually mapped from the Secret Vault). |
| Model | ✅ | The specific OpenAI model to use (e.g., gpt-4o, gpt-3.5-turbo). |
| User Prompt | ✅ | The main text or question to send to the model. |
| System Prompt | — | Instructions that set the behavior and persona of the assistant. |
| Enable History | — | Toggle to maintain context across multiple requests. |
History Settings
If Enable History is turned on, the following fields become active:
- Storage Object Variable (Required): A variable mapped to a Storage Object to persist the chat history.
- Chat ID: A unique identifier for the conversation session. If empty, a random ID is generated.
- Message Count: The number of previous messages to include as context for the next request.
Advanced Settings
Toggle Advanced Settings to customize the model's generation:
- Temperature (0 to 2): Controls randomness. Lower values are more deterministic; higher values are more creative.
- Max Output Tokens: The maximum length of the generated response.
- Top P (0 to 1): Nucleus sampling parameter.
- Frequency Penalty (-2 to 2): Decreases the likelihood of the model repeating the same lines verbatim.
- Presence Penalty (-2 to 2): Increases the likelihood of the model talking about new topics.
Output Variable
Specify a Variable Name to store the result.
Success Payload
{
"success": true,
{
"error_key": "rate_limit_exceeded",
"error_message": "Too many requests sent in a short time. Please slow down."
}Error Handling
API_KEY_MISSING/SECRET_ERROR— Missing or invalid API key.MODEL_MISSING— No model was specified.PROMPT_MISSING— The user prompt was empty.HISTORY_VAR_MISSING— History was enabled but no storage object was provided.invalid_api_key/insufficient_quota/rate_limit_exceeded— Standard OpenAI API errors.RUNTIME_ERROR— An unexpected issue occurred during the API call.
