Cloudflare AI icon

Cloudflare AI

Use Cloudflare Workers AI models for text, image, and audio processing

Overview

This node integrates with Cloudflare Workers AI models to perform various AI-powered text processing tasks, specifically supporting chat completions for conversational AI scenarios. It allows users to send a series of messages (with roles like system, user, assistant) to generate AI-driven chat responses using selected large language models. This is useful for building chatbots, virtual assistants, or any application requiring dynamic conversational interactions.

Practical examples include:

  • Creating a customer support chatbot that responds based on prior conversation context.
  • Generating creative dialogue or story continuations.
  • Assisting with interactive Q&A or tutoring systems.

Properties

Name Meaning
Model The AI model to use. Options: Llama 3.1 8B Instruct, Llama 3 8B Instruct, Mistral 7B Instruct, Gemma 7B
Messages The list of messages forming the conversation history. Each message has: Role (System, User, Assistant) and Content (text).
Options Additional generation options:
• Max Tokens: Maximum tokens to generate (default 256)
• Temperature: Sampling temperature between 0 and 2 (default 0.7)
• Stream: Whether to stream the response (true/false)

Output

The output JSON contains the AI-generated chat completion result under the json field. Typically, this includes the generated text or structured response from the AI model in a property such as result. If the request fails, an error object with details is returned instead.

No binary data is produced for this operation.

Example output structure:

{
  "result": {
    // AI-generated chat completion content here
  }
}

Dependencies

  • Requires a valid Cloudflare API key credential with appropriate permissions.
  • Needs configuration of the Cloudflare account ID and API token within n8n credentials.
  • Uses Cloudflare's AI API endpoint for running models.

Troubleshooting

  • Common issues:

    • Invalid or missing API credentials will cause authentication failures.
    • Incorrect model names or unsupported operations may lead to request errors.
    • Improperly formatted messages array can cause the API to reject the request.
  • Error messages:

    • "Request failed": General failure; check API token validity and network connectivity.
    • Errors containing "message" from the API response indicate specific problems like invalid parameters or quota limits.
  • Resolution tips:

    • Verify API credentials and permissions.
    • Ensure the messages are correctly structured with valid roles and non-empty content.
    • Adjust max tokens and temperature settings if generation quality is poor or times out.

Links and References

Discussion