> 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**      | An ID returned by `GET /v1/models` |

{% 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                         | Default |
| --------------- | ----------------------------------- | ------- |
| **Temperature** | Controls randomness (0-2)           | 0.7     |
| **Max Tokens**  | Optional application response limit | Unset   |
| **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

## Model selection

Call `GET /v1/models` with your TensorX API key and use one of the returned IDs. If the integration depends on a capability or token limit, query `GET /v1/model/info` before selecting the model. See [Models](/api-reference/models.md) for examples.

***

## Agent Workflows

When building agent workflows with tools:

### Step 1: Configure Model for Tool Calling

Query `GET /v1/model/info` and select a model whose `supports_function_calling` value is `true`:

```
OpenAI API Base: https://api.tensorx.ai/v1
Model Name: <MODEL_ID>
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

## 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
* Include the provider prefix shown by `GET /v1/models`
* Check available models at [tensorx.ai/models](https://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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.tensorx.ai/automation-platforms/langflow.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
