> For the complete documentation index, see [llms.txt](https://docs.tensorx.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tensorx.ai/automation-platforms/langflow.md).

# Langflow

Langflow is a visual framework for building RAG applications and multi-agent AI workflows using a drag-and-drop interface.

## Prerequisites

* A Langflow instance (self-hosted or [Langflow Cloud](https://astra.datastax.com/langflow))
* Your TensorX API key from [app.tensorx.ai](https://app.tensorx.ai)

## Configuration

Langflow connects to TensorX through the **OpenAI** model component, which supports custom base URLs for OpenAI-compatible APIs.

### Step 1: Add OpenAI Model Component

1. Open your Langflow workspace
2. In the component sidebar, navigate to **Models**
3. Drag the **OpenAI** component onto your canvas

### Step 2: Configure the Component

Click on the OpenAI component to open its settings and configure:

| Parameter           | Value                         |
| ------------------- | ----------------------------- |
| **OpenAI API Base** | `https://api.tensorx.ai/v1`   |
| **OpenAI API Key**  | Your TensorX API key          |
| **Model Name**      | `deepseek/deepseek-chat-v3.1` |

{% hint style="info" %}
The **OpenAI API Base** field allows you to point to any OpenAI-compatible endpoint. Enter the full URL including `/v1`.
{% endhint %}

### Step 3: Adjust Model Parameters

Configure optional parameters as needed:

| Parameter       | Description                | Recommended |
| --------------- | -------------------------- | ----------- |
| **Temperature** | Controls randomness (0-2)  | 0.7         |
| **Max Tokens**  | Maximum response length    | 4096        |
| **Stream**      | Enable streaming responses | true        |

## Building a Basic Flow

### Simple Chat Flow

1. Add an **OpenAI** model component (configured for TensorX)
2. Add a **Chat Input** component
3. Add a **Chat Output** component
4. Connect: Chat Input → OpenAI → Chat Output
5. Click **Run** to test

### RAG Flow with Vector Store

1. Add an **OpenAI** model component for TensorX
2. Add a **Vector Store** component (Chroma, Pinecone, etc.)
3. Add a **Retriever** component
4. Add a **Prompt** component with RAG template
5. Connect components to build the retrieval pipeline
6. Add Chat Input/Output for interaction

## 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 chat, balanced     |
| `z-ai/glm-5.1`                | Tool calling, agents, code |
| `minimax/minimax-m2.5`        | Reasoning, functions       |
| `moonshotai/kimi-k2.5`        | Vision, long context       |

## Agent Workflows

When building agent workflows with tools:

### Step 1: Configure Model for Tool Calling

Use `z-ai/glm-5.1` for best tool calling support:

```
OpenAI API Base: https://api.tensorx.ai/v1
Model Name: z-ai/glm-5.1
Temperature: 0.3
```

### Step 2: Add Tool Components

1. Add tool components from the **Tools** section
2. Available tools include: Calculator, Web Search, Python Code, etc.
3. Connect tools to your agent flow

### Step 3: Build Agent Logic

1. Add an **Agent** component
2. Connect your TensorX model to the agent's LLM input
3. Connect tool components to the agent
4. Add memory component if needed for conversation history

## Example Configurations

### Code Assistant

```
OpenAI API Base: https://api.tensorx.ai/v1
Model Name: z-ai/glm-5.1
Temperature: 0.2
Max Tokens: 8192
```

### Creative Writing

```
OpenAI API Base: https://api.tensorx.ai/v1
Model Name: deepseek/deepseek-chat-v3.1
Temperature: 0.9
Max Tokens: 4096
```

### Analytical Tasks

```
OpenAI API Base: https://api.tensorx.ai/v1
Model Name: minimax/minimax-m2.5
Temperature: 0.4
Max Tokens: 4096
```

## Using Multiple Models

You can use different TensorX models in the same flow:

1. Add multiple **OpenAI** components
2. Configure each with a different model
3. Use a **Router** component to direct queries to the appropriate model
4. Or chain models for multi-step processing

## Memory and Context

### Adding Conversation Memory

1. Add a **Memory** component (e.g., Buffer Memory)
2. Connect it to your OpenAI model component
3. This enables multi-turn conversations with context

### Managing Context Length

For long conversations:

* Use models with larger context windows
* Implement summarization for older messages
* Use the Memory component's built-in truncation

## Troubleshooting

### "Invalid API Key" Error

* Verify your API key at [app.tensorx.ai](https://app.tensorx.ai)
* Check for extra spaces in the API key field
* Ensure the base URL is correct: `https://api.tensorx.ai/v1`

### "Model Not Found" Error

* Use the full model ID with provider prefix
* Example: `deepseek/deepseek-chat-v3.1` not just `deepseek-chat`
* Check available models at [app.tensorx.ai/models](https://app.tensorx.ai/models)

### Connection Timeout

* Check your Langflow instance's network connectivity
* Verify there are no firewall rules blocking the API
* Try increasing timeout settings if available

### Flow Not Responding

* Check the Langflow logs for error messages
* Verify all required connections are made
* Test individual components before full flow

## Support

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.tensorx.ai/automation-platforms/langflow.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.
