Actions74
- ai Actions
- array Actions
- audiovideo Actions
- carbone Actions
- charts Actions
- code Actions
- data Actions
- datetime Actions
- events Actions
- files Actions
- geo Actions
- hellospaces Actions
- images Actions
- Get Metadata of an Image
- Scale an Image
- Overlay an Image on another Image
- Scale an Image to Fit Given Dimensions
- Resize an Image
- Mask an Image with Another Image
- Mask an Image with a Circle Mask
- Crops an image by the given x, y, width and height paramters.
- Convert Texts to an Image
- Convert HTML String or URL to an Image
- Generates a QRCode with given text and color.
- Get EXIF from Image
- Remove EXIF from Image
- Modify Image EXIF
- playground Actions
- spreadsheet Actions
- stripe Actions
- youtube Actions
ai → Ask OpenAI
AI-generatedOverview
The "Ask OpenAI" operation under the "ai" resource in this custom n8n node allows users to send a prompt to an OpenAI language model (such as text-davinci-003) and receive a generated completion. This is useful for automating tasks that require natural language understanding or generation, such as drafting emails, summarizing text, generating code snippets, or answering questions.
Practical examples:
- Automatically generate product descriptions from bullet points.
- Summarize customer support tickets.
- Create creative content like poems or stories based on user input.
- Answer user queries using AI within automated workflows.
Properties
| Name | Meaning |
|---|---|
| Prompt | Prompt that will be sent to OpenAI. This is the main instruction or question you want the AI to respond to. |
| Temperature | What sampling temperature to use, between 0 and 2. Higher values (e.g., 0.8) make output more random; lower values (e.g., 0.2) make it more focused and deterministic. |
| Max Tokens | The maximum number of tokens to generate in the completion. The sum of your prompt's tokens and max_tokens cannot exceed the model's context length (usually 2048 or 4096 tokens). |
| Model | OpenAI model to be used. Defaults to text-davinci-003. Currently, only "text-davinci-003" is available as an option. |
Output
- The node outputs a JSON object containing the response from the OpenAI API.
- The structure typically includes fields such as:
id: Identifier for the request.object: Type of object returned.created: Timestamp of creation.model: Model used for the completion.choices: Array of completions, each with atextfield containing the generated output.usage: Token usage statistics.
Example output:
{
"id": "cmpl-abc123",
"object": "text_completion",
"created": 1670000000,
"model": "text-davinci-003",
"choices": [
{
"text": "This is the AI-generated response.",
"index": 0,
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 16,
"total_tokens": 26
}
}
If the API returns an error, the output will contain an error field with details.
Dependencies
- External Service: Requires access to the 1001fx API, which acts as a proxy to OpenAI.
- API Key: You must configure the "1001fxApi" credential in n8n with a valid API key.
- n8n Configuration: No additional configuration is required beyond setting up the credential.
Troubleshooting
Common issues:
- Invalid API Key: If the API key is missing or incorrect, you'll receive an authentication error. Ensure your "1001fxApi" credential is set up correctly.
- Exceeded Token Limit: If the sum of your prompt and max tokens exceeds the model's context length, the API may return an error. Reduce the prompt size or max tokens.
- Model Not Supported: If you select a model not supported by the backend, you may get an error. Currently, only "text-davinci-003" is available.
- Malformed Input: If required properties are missing (e.g., no prompt), the node will throw an error indicating missing parameters.
Error messages:
"error": "Invalid API key"– Check your credentials."error": "Maximum context length exceeded"– Adjust your prompt or max tokens."error": "Missing required parameter: prompt"– Ensure all required fields are filled.