Async Python client library for interacting with Langflow API servers
Project description
Langflow Python Client
An async Python client library for interacting with Langflow API servers.
Features
Features
- 🚀 Async/await support - Built with modern Python async patterns for high performance
- 🔐 Authentication - Secure API key authentication for protected Langflow instances
- 🎛️ Dynamic Tweaks - Modify flow behavior at runtime without changing flow definitions
- 📁 File Upload - Upload files directly to flows for document processing and analysis
- 📝 Type Safety - Full type annotation support with IDE autocomplete
- 🔧 Flexible Configuration - Support for different input/output types (text, chat)
- 🐍 Python 3.10+ - Compatible with modern Python versions
Installation
pip install langflow-python-client
Quick Start
Basic Usage
import asyncio
from langflow_client import LangflowClient, FlowRequestOptions
from langflow_client.constants import InputTypes, OutputTypes
async def main():
# Initialize the client
client = LangflowClient(
base_url="http://localhost:7860"
)
# Get a flow instance
flow = client.flow("your-flow-id")
# Create request options
options = FlowRequestOptions(
input_type=InputTypes.TEXT,
output_type=OutputTypes.TEXT,
session_id="my-session"
)
# Run the flow
result = await flow.run(
"Hello, Langflow!",
options=options
)
print(result)
# Run the async function
asyncio.run(main())
Using Tweaks for Dynamic Configuration
Tweaks allow you to modify flow components at runtime without changing the flow definition:
async def run_with_tweaks():
client = LangflowClient(base_url="http://localhost:7860")
# Create flow with component tweaks
flow = client.flow("flow-id").tweak(**{
"TextInput-ABC123": {
"input_value": "Candidate CV content here..."
},
"OpenAI-DEF456": {
"temperature": 0.7,
"max_tokens": 500
},
"ChatOutput-GHI789": {
"should_store_message": False
}
})
# Run with options
options = FlowRequestOptions(
input_type=InputTypes.CHAT,
output_type=OutputTypes.CHAT
)
result = await flow.run(options=options)
return result
Input and Output Types
The client supports different input and output types depending on your Langflow components:
| Type | Description | Use Case |
|---|---|---|
| InputTypes.TEXT | Plain text input | Simple text processing, document analysis |
| InputTypes.CHAT | Chat message format | Interactive chatbots, conversational AI |
| OutputTypes.TEXT | Plain text output | Clean text responses |
| OutputTypes.CHAT | Chat message format | Interactive chatbots, conversational |
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langflow_python_client-1.0.0.tar.gz.
File metadata
- Download URL: langflow_python_client-1.0.0.tar.gz
- Upload date:
- Size: 20.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fbd85c666e4a3a175b2baf8f9370e068d2972b1cf2a85fd42ccca728e3d7fef
|
|
| MD5 |
a41a9ab6e3a942ca5854487529be8c47
|
|
| BLAKE2b-256 |
904cd3620f52a87b76ae1d8a95005adc7971c39808f3217ff5613e4681351418
|
File details
Details for the file langflow_python_client-1.0.0-py3-none-any.whl.
File metadata
- Download URL: langflow_python_client-1.0.0-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25643e2a3a987d7501b7c3ea03eba657bfe63f47c543b76e9e2528a9951b14ad
|
|
| MD5 |
414783d315ea254c197a71bb546dc76e
|
|
| BLAKE2b-256 |
9b8ce27de554997d108a5cabc8137c0482a9a85cf9599fd9494c4259b80702f7
|