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.8.tar.gz (174.7 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.8-py3-none-any.whl (214.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flowllm-0.2.0.8.tar.gz
  • Upload date:
  • Size: 174.7 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.8.tar.gz
Algorithm Hash digest
SHA256 348cc42ac95fd2918071f8df8ce796af75bf91d78cad7638375fa62fc74261e9
MD5 7dd11662c7494d6b3df2c098f914566b
BLAKE2b-256 91dae61e07bb98cb28ebf7c7d107c866f71afc1fadf92e940abe89fdca64f773

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flowllm-0.2.0.8-py3-none-any.whl
  • Upload date:
  • Size: 214.0 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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 d2c053ef48ed159ff26ea3f704738f7bcbbe0f3ae14cd73af20e9cd63005b936
MD5 0f42ff1f17ba3d7839bb3f829b991e83
BLAKE2b-256 241cc6100f547aabd153eb3f039802b9f58fba2d867b2ea5ac253fed1dc05a32

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