1001fx - NoCode functions icon

1001fx - NoCode functions

1001fx is a set of functions for any automation platform. Our functions are simple, very well tested, scalable and offer features that most automation platforms do not offer.

Actions74

ai → Ask OpenAI

AI-generated

Overview

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 a text field 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.

Links and References

Discussion