Actions2
Overview
The DeepSeek node integrates with the DeepSeek API via the Vercel AI SDK to generate text completions or structured objects based on user input. It supports two main operations: generating plain text responses from prompts or chat messages, and generating structured JSON objects that conform to a user-defined JSON schema.
This node is useful in scenarios such as:
- Generating conversational AI responses using simple prompts or multi-message conversations.
- Extracting structured data from text by defining a JSON schema, for example, sentiment analysis results or other custom object outputs.
- Automating content generation workflows where AI-generated text or structured data is required.
Practical examples:
- Use a single prompt like "Write a summary of this article" to get a text completion.
- Provide a conversation history (messages) to simulate a chat assistant.
- Define a JSON schema for sentiment analysis and generate an object containing sentiment, score, and analyzed text.
Properties
| Name | Meaning |
|---|---|
| Model Name or ID | Select which DeepSeek model to use. Options are dynamically loaded from the DeepSeek API or can be specified by ID. Examples include "DeepSeek Chat" (optimized for conversations and structured outputs) and "DeepSeek Reasoner". |
| Input Type | Choose how to provide input: either a "Simple Prompt" (single text prompt) or "Messages" (a conversation with multiple messages). |
| System | (Shown if Input Type is "Simple Prompt") A system prompt guiding the model's behavior, e.g., "You are a helpful assistant." Optional but helps steer responses. |
| Prompt | (Shown if Input Type is "Simple Prompt") The single text prompt to generate a completion for. Can use expressions to pull data from previous nodes. |
| Messages | (Shown if Input Type is "Messages" and not using JSON input) A collection of messages forming a conversation. Each message has a role (Assistant, System, User) and corresponding content. |
| Messages as JSON | (Boolean) Whether to input messages as a JSON array string instead of using the UI collection. |
| Messages (JSON) | (Shown if Messages as JSON is true) A JSON string representing an array of message objects, each with role and content. |
| Schema Name | (Optional, shown for Generate Object operation with deepseek-chat model) Name of the output JSON schema to guide object generation. |
| Schema Description | (Optional, shown for Generate Object operation with deepseek-chat model) Description of the output JSON schema for additional guidance. |
| Schema | (Required for Generate Object operation with deepseek-chat model) JSON schema describing the structure and constraints of the object to generate. For example, a schema for sentiment analysis output. |
| Options | Collection of optional parameters: - Max Tokens: Maximum tokens to generate (default 2048). - Temperature: Controls randomness of output (0 to 2, default 0.7). - Include Request Body: Whether to include the request body in output. |
Output
The node outputs an array of items, each containing a json field with the result of the generation:
For Generate Text operation:
text: The generated text completion.reasoning,finishReason: Additional metadata about the generation process.usage: Token usage statistics including prompt, completion, and total tokens.response: Metadata about the API response such as id, modelId, timestamp, and headers.warnings: Any warnings returned by the API.- Optionally, if enabled, the original request body sent to the API.
For Generate Object operation:
object: The generated structured object conforming to the provided JSON schema.finishReason,usage,response,warnings: Similar metadata as above.- Optionally, the request body if requested.
The node does not output binary data.
Dependencies
- Requires an active DeepSeek API key credential configured in n8n.
- Uses the DeepSeek API endpoint to list models and perform generation requests.
- Depends on the Vercel AI SDK and related libraries for interacting with DeepSeek models.
- Requires valid JSON schemas for the Generate Object operation when using the deepseek-chat model.
Troubleshooting
- Invalid JSON in "Messages (JSON)" field: If the JSON string for messages is malformed, the node throws an error indicating invalid JSON. Ensure the JSON is correctly formatted as an array of objects with
roleandcontent. - Schema is not valid JSON: When providing a schema for object generation, invalid JSON will cause an error. Validate your JSON schema syntax before input.
- Invalid JSON Schema: If the schema does not conform to JSON Schema standards, the node will reject it. Use a JSON schema validator to check correctness.
- No API key provided in credentials: The node requires a valid API key credential. Make sure the credential is set up properly.
- API request failures: Network issues or invalid API keys may cause errors. Verify connectivity and credential validity.
- Continue On Fail: If enabled, the node will continue processing subsequent items even if one fails, returning error details in the output.