# Activepieces

Activepieces is an open-source automation platform similar to Zapier, with a visual workflow builder for connecting apps and services.

## Prerequisites

* An Activepieces instance (self-hosted or cloud)
* Your Tensorix API key from [app.tensorix.ai](https://app.tensorix.ai)

## Configuration

Since the built-in OpenAI piece uses a hardcoded endpoint, you'll use the **HTTP Request** piece to connect to Tensorix's OpenAI-compatible API.

{% hint style="info" %}
The HTTP Request method gives you full control over the API call and works with any OpenAI-compatible endpoint.
{% endhint %}

## Method: HTTP Request Piece

### Step 1: Add HTTP Request Piece

1. Open your Activepieces flow
2. Click **+** to add a new piece
3. Search for **HTTP** and select **HTTP Request (Advanced)**

### Step 2: Configure the Request

Set up the HTTP request with these parameters:

| Field      | Value                                         |
| ---------- | --------------------------------------------- |
| **Method** | `POST`                                        |
| **URL**    | `https://api.tensorix.ai/v1/chat/completions` |

### Step 3: Add Headers

Click **Add Header** and add the following:

| Header          | Value                          |
| --------------- | ------------------------------ |
| `Authorization` | `Bearer YOUR_TENSORIX_API_KEY` |
| `Content-Type`  | `application/json`             |

### Step 4: Configure the Body

Set **Body Type** to `Raw (JSON)` and enter:

```json
{
  "model": "deepseek/deepseek-chat-v3.1",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user",
      "content": "{{trigger.message}}"
    }
  ],
  "temperature": 0.7,
  "max_tokens": 1000
}
```

{% hint style="info" %}
Replace `{{trigger.message}}` with your actual data source from previous pieces in your flow.
{% endhint %}

### Step 5: Parse the Response

The API returns a JSON response. To extract the assistant's message:

1. Add a **Code** piece after the HTTP Request
2. Use JavaScript to parse the response:

```javascript
const response = inputs.httpResponse.body;
return {
  message: response.choices[0].message.content,
  model: response.model,
  tokens: response.usage.total_tokens
};
```

## Example Flows

### Email Summarizer

1. **Trigger**: New Email (Gmail piece)
2. **HTTP Request**: Send email body to Tensorix for summarization
3. **Action**: Save summary to Notion or send to Slack

Request body:

```json
{
  "model": "deepseek/deepseek-chat-v3.1",
  "messages": [
    {
      "role": "system",
      "content": "Summarize the following email in 2-3 sentences."
    },
    {
      "role": "user",
      "content": "{{trigger.emailBody}}"
    }
  ],
  "temperature": 0.3,
  "max_tokens": 200
}
```

### Customer Support Classifier

1. **Trigger**: New Support Ticket (webhook or integration)
2. **HTTP Request**: Classify ticket category
3. **Branch**: Route based on category
4. **Action**: Assign to appropriate team

Request body:

```json
{
  "model": "z-ai/glm-5.1",
  "messages": [
    {
      "role": "system",
      "content": "Classify this support ticket into one of: billing, technical, general, urgent. Return only the category name."
    },
    {
      "role": "user",
      "content": "{{trigger.ticketContent}}"
    }
  ],
  "temperature": 0.1,
  "max_tokens": 20
}
```

### Content Generator

1. **Trigger**: New Row in Google Sheets
2. **HTTP Request**: Generate content based on topic
3. **Action**: Update sheet with generated content

Request body:

```json
{
  "model": "deepseek/deepseek-chat-v3.1",
  "messages": [
    {
      "role": "system",
      "content": "Write a short blog post introduction about the given topic."
    },
    {
      "role": "user",
      "content": "Topic: {{trigger.topic}}"
    }
  ],
  "temperature": 0.8,
  "max_tokens": 500
}
```

## Recommended Models

{% hint style="info" %}
**For Coding Tasks:**

* `z-ai/glm-5.1` - Best for tool calling and structured outputs
* `minimax/minimax-m2.5` - Best for complex reasoning tasks
  {% endhint %}

| Model ID                      | Best For                          |
| ----------------------------- | --------------------------------- |
| `deepseek/deepseek-chat-v3.1` | General text generation           |
| `z-ai/glm-5.1`                | Classification, structured output |
| `minimax/minimax-m2.5`        | Complex reasoning, analysis       |
| `moonshotai/kimi-k2.5`        | Vision, long context              |

## Handling Streaming Responses

For long responses, you may want to handle streaming:

1. The Tensorix API supports streaming with `"stream": true`
2. However, HTTP Request piece may not handle SSE well
3. For streaming, consider using a webhook-based approach or the Code piece with fetch

## Error Handling

### Add Error Handling

1. Click on your HTTP Request piece
2. Enable **Handle Errors**
3. Add a branch to handle failed requests

### Common Errors

| Error | Cause             | Solution                    |
| ----- | ----------------- | --------------------------- |
| 401   | Invalid API key   | Check your API key          |
| 400   | Malformed request | Verify JSON body format     |
| 404   | Wrong endpoint    | Use `/v1/chat/completions`  |
| 429   | Rate limit        | Add delays between requests |

## Creating a Reusable Template

To reuse your Tensorix configuration:

1. Create a flow template with the HTTP Request piece configured
2. Use flow variables for dynamic content
3. Duplicate the template for new automations

## Storing API Key Securely

Instead of hardcoding your API key:

1. Go to **Settings** → **Connections**
2. Create a new **Custom Connection**
3. Store your API key securely
4. Reference it in your flows using `{{connections.tensorix.apiKey}}`

## Troubleshooting

### "Request Failed" Error

* Check the URL is exactly `https://api.tensorix.ai/v1/chat/completions`
* Verify headers are correctly formatted
* Test your API key with a simple curl command

### Empty Response

* Check the response body parsing
* Verify the model ID is correct
* Look at the raw response for error messages

### Timeout Errors

* Increase the timeout setting in HTTP Request piece
* Use a faster model for time-sensitive flows
* Consider breaking long operations into smaller chunks

## Support

Need help? Contact us at <support@tensorix.ai>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tensorix.ai/automation-platforms/activepieces.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
