Skip to main content

FlowLLM: Simplifying LLM-based HTTP/MCP Service Development

Project description

FlowLLM Logo

FlowLLM: Simplifying LLM-based HTTP/MCP Service Development
If you find it useful, please give us a ⭐ Star. Your support drives our continuous improvement.

Python Version PyPI Version License GitHub Stars

English | 简体中文


📖 Introduction

FlowLLM encapsulates LLM, Embedding, and vector_store capabilities as HTTP/MCP services. It is suitable for AI assistants, RAG applications, and workflow services, and can be integrated into MCP-compatible client tools.

🏗️ Architecture Overview

FlowLLM Framework

🌟 Applications Based on FlowLLM

Project Name Description
ReMe Memory management toolkit for agents

📢 Recent Updates

Date Update Content
2025-11-15 Added File Tool Op feature with 13 file operation tools, supporting file reading, writing, editing, searching, directory operations, system command execution, and task management
2025-11-14 Added Token counting capability, supporting accurate calculation of token counts for messages and tools via self.token_count() method, with support for multiple backends (base, openai, hf). See configuration examples in default.yaml

📚 Learning Resources

Project developers will share their latest learning materials here.

Date Title Description
2025-11-24 Mem-PAL: Memory-Augmented Personalized Assistant Mem-PAL: Memory-Augmented Personalized Assistant with Log-based Structured Memory
2025-11-14 HaluMem Analysis HaluMem: Evaluating Hallucinations in Memory Systems of Agents Analysis
2025-11-13 Gemini CLI Context Management Mechanism Multi-layer Context Management Strategy for Gemini CLI
2025-11-10 Context Management Guide Context Management Guide
2025-11-10 LangChain&Manus Video Materials LangChain & Manus Context Management Video

⭐ Core Features

  • Simple Op Development: Inherit from BaseOp or BaseAsyncOp and implement your business logic. FlowLLM provides lazy-initialized LLM, Embedding models, and vector stores accessible via self.llm, self.embedding_model, and self.vector_store. It also offers prompt template management through prompt_format() and get_prompt() methods. Additionally, FlowLLM includes built-in token counting capabilities. Use self.token_count() to accurately calculate token counts for messages and tools, supporting multiple backends (base, openai, hf, etc.).

  • Flexible Flow Orchestration: Compose Ops into Flows via YAML configuration. >> denotes serial composition; | denotes parallel composition. For example, SearchOp() >> (AnalyzeOp() | TranslateOp()) >> FormatOp() builds complex workflows. Define input/output schemas and start the service with flowllm config=your_config.

  • Automatic Service Generation: FlowLLM automatically generates HTTP, MCP, and CMD services. The HTTP service provides RESTful APIs with synchronous JSON and HTTP Stream responses. The MCP service registers as Model Context Protocol tools for MCP-compatible clients. The CMD service executes a single Op in command-line mode for quick testing and debugging.


⚡ Quick Start

📦 Step0 Installation

📥 From PyPI

pip install flowllm

🔧 From Source

git clone https://github.com/flowllm-ai/flowllm.git
cd flowllm
pip install -e .

For detailed installation and configuration, refer to the Installation Guide.

⚙️ Configuration

Create a .env file and configure your API keys. Copy from example.env and modify:

cp example.env .env

Configure your API keys in the .env file:

FLOW_LLM_API_KEY=sk-xxxx
FLOW_LLM_BASE_URL=https://xxxx/v1
FLOW_EMBEDDING_API_KEY=sk-xxxx
FLOW_EMBEDDING_BASE_URL=https://xxxx/v1

For detailed configuration, refer to the Configuration Guide.

🛠️ Step1 Build Op

from flowllm.core.context import C
from flowllm.core.op import BaseAsyncOp
from flowllm.core.schema import Message
from flowllm.core.enumeration import Role

@C.register_op()
class SimpleChatOp(BaseAsyncOp):
    async def async_execute(self):
        query = self.context.get("query", "")
        messages = [Message(role=Role.USER, content=query)]

        # Use token_count method to calculate token count
        token_num = self.token_count(messages)
        print(f"Input tokens: {token_num}")

        response = await self.llm.achat(messages=messages)
        self.context.response.answer = response.content.strip()

For details, refer to the Simple Op Guide, LLM Op Guide, and Advanced Op Guide (including Embedding, VectorStore, and concurrent execution).

📝 Step2 Configure Config

The following example demonstrates building an MCP (Model Context Protocol) service. Create a configuration file my_mcp_config.yaml:

backend: mcp

mcp:
  transport: sse
  host: "0.0.0.0"
  port: 8001

flow:
  demo_mcp_flow:
    flow_content: MockSearchOp()
    description: "Search results for a given query."
    input_schema:
      query:
        type: string
        description: "User query"
        required: true

llm:
  default:
    backend: openai_compatible
    model_name: qwen3-30b-a3b-instruct-2507
    params:
      temperature: 0.6
    token_count: # Optional, configure token counting backend
      model_name: Qwen/Qwen3-30B-A3B-Instruct-2507
      backend: hf  # Supports base, openai, hf, etc.
      params:
        use_mirror: true

🚀 Step3 Start MCP Service

flowllm \
  config=my_mcp_config \
  backend=mcp \  # Optional, overrides config
  mcp.transport=sse \  # Optional, overrides config
  mcp.port=8001 \  # Optional, overrides config
  llm.default.model_name=qwen3-30b-a3b-thinking-2507  # Optional, overrides config

After the service starts, refer to the Client Guide to use the service and obtain the tool_call required by the model.


📚 Detailed Documentation

🚀 Getting Started

🔧 Op Development

🔀 Flow Orchestration

🌐 Service Usage


🤝 Contributing

Contributions of all forms are welcome! For participation methods, refer to the Contribution Guide.


📄 License

This project is licensed under the Apache 2.0 license.


Star 历史

Star History Chart


GitHubDocumentationPyPI

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flowllm-0.2.0.7.tar.gz (174.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flowllm-0.2.0.7-py3-none-any.whl (213.9 kB view details)

Uploaded Python 3

File details

Details for the file flowllm-0.2.0.7.tar.gz.

File metadata

  • Download URL: flowllm-0.2.0.7.tar.gz
  • Upload date:
  • Size: 174.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for flowllm-0.2.0.7.tar.gz
Algorithm Hash digest
SHA256 00c39a6c5f708d1734f57daf28b3b654a3ff31c1f58b71a62cb3ea9b3b663778
MD5 3d17fee10ad3dfdbe5ff26faa39d7916
BLAKE2b-256 40a55f8f6c1dcae3cb5a45e6413a12a0298bf2c7cef5c3ea6fe3629313005a1d

See more details on using hashes here.

File details

Details for the file flowllm-0.2.0.7-py3-none-any.whl.

File metadata

  • Download URL: flowllm-0.2.0.7-py3-none-any.whl
  • Upload date:
  • Size: 213.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for flowllm-0.2.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 69c5d3181fb4ef2d3424f154ca547058691a106e5fc9074dfab3b53c2e756536
MD5 c72c8e5bb2d0387653e99fba697335f6
BLAKE2b-256 4d5778abd92492f8df1799a796eb9415e35ede7b2e223dc25e386c34dfbae434

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page