惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
Recent Commits to openclaw:main
Recent Commits to openclaw:main
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
罗磊的独立博客
V
Visual Studio Blog
爱范儿
爱范儿
H
Help Net Security
J
Java Code Geeks
I
InfoQ
Recent Announcements
Recent Announcements
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Recorded Future
Recorded Future
Jina AI
Jina AI
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
GbyAI
GbyAI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Y
Y Combinator Blog
Google DeepMind News
Google DeepMind News
Scott Helme
Scott Helme
S
SegmentFault 最新的问题
S
Securelist
L
LINUX DO - 热门话题
Cyberwarzone
Cyberwarzone
C
Cisco Blogs
Simon Willison's Weblog
Simon Willison's Weblog
G
Google Developers Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
T
The Blog of Author Tim Ferriss
博客园_首页
B
Blog
F
Fortinet All Blogs
AWS News Blog
AWS News Blog
V
Vulnerabilities – Threatpost
S
Secure Thoughts
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Forbes - Security
Forbes - Security
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
Schneier on Security
Project Zero
Project Zero
Martin Fowler
Martin Fowler
C
Cybersecurity and Infrastructure Security Agency CISA
N
Netflix TechBlog - Medium
N
News and Events Feed by Topic

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Serving any LLM using a single command line with Flama
Vortico · 2026-06-17 · via DEV Community

Flama 2.0 brings first-class support for generative AI: downloading, packaging, and serving large language models (LLMs) is now as simple as running a few commands in your terminal. No boilerplate code, no custom serving infrastructure, no
configuration files. Just the CLI and a model.

In this post, we walk through the entire workflow: fetching a model from HuggingFace, interacting with it locally in your terminal, and serving it over HTTP with a production-ready API and a built-in chat interface. We will also show how a locally served model can power agentic workflows, using Claude CLI as a practical example.

Before we dive into the details, we recommend you to have the following resources at hand:

Table of contents

  • Fetching a model with flama get
    • What happens under the hood
  • Interacting with the model locally
    • One-shot queries with flama model run
    • Streaming responses with flama model stream
  • Serving the model over HTTP
    • The flama serve command
    • The built-in chat interface
  • Powering agentic workflows
    • Using Claude CLI with a local model
  • Conclusions
  • References
  • Support our work
  • About the authors

Fetching a model with flama get

The first step in serving an LLM with Flama is downloading and packaging a model into a .flm artifact (a Flama Lightweight Model file). The flama get command handles this in a single step: it downloads the model weights and configuration from a supported source and serialises them into the portable .flm format.

All examples in this post assume Flama has been installed with the LLM extras via uv:

uv pip install "flama[llm,pydantic]"

Alternatively, you can run any command without a prior install by using uvx --from "flama[llm,pydantic]" flama ..., but for brevity we assume Flama is already installed throughout.

Let us fetch a quantised version of Google's Gemma 4 model, optimised for Apple Silicon via the MLX Community:

flama get --family llm --source huggingface mlx-community/gemma-4-E2B-it-qat-4bit

Downloading ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 2.3 GB 28.7 MB/s 0:00:00
Packaging...
Model saved to mlx-community_gemma-4-E2B-it-qat-4bit.flm

Two options are required: --source tells Flama where to download from (currently HuggingFace), and --family declares whether the artifact is a traditional machine-learning model (ml) or a generative model (llm). For large language models, you always pass --family llm.

The output path defaults to <model-name>.flm with slashes replaced by underscores. If you prefer a custom path, pass --output:

flama get --family llm --source huggingface mlx-community/gemma-4-E2B-it-qat-4bit --output models/gemma.flm

What happens under the hood

When you run flama get, the following happens:

  1. Flama resolves the model identifier against the HuggingFace Hub and discovers the files that make up the model (weights, tokenizer, configuration).
  2. Files are downloaded concurrently (up to 8 parallel downloads by default, configurable with --max-concurrent).
  3. Once all files are on disk, Flama packages them into a single .flm archive alongside a manifest that records the model family, the originating library, and metadata such as the model name and creation timestamp.

The result is a self-contained, portable artifact. The .flm format is framework-agnostic: the same file runs on vLLM (Linux with CUDA) or MLX (Apple Silicon), with Flama selecting the appropriate backend at load time based on what is available in the environment.

Interacting with the model locally

Once you have a packaged .flm artifact, you can interact with it directly from your terminal using the flama model command. No server, no HTTP, no code. This is invaluable for quick testing, prompt experimentation, and pipeline scripting.

One-shot queries with flama model run

The run sub-command sends a prompt to the model, waits for the full response, and prints it:

echo "What is Flama?" | flama model mlx-community_gemma-4-E2B-it-qat-4bit.flm run --system "Be concise."

Flama is a Python framework for building production-ready APIs with a focus on machine learning and generative AI, enabling one-line model serving behind HTTP endpoints.

You can tune generation with --param flags:

echo "Explain dependency injection in three sentences." | \
  flama model mlx-community_gemma-4-E2B-it-qat-4bit.flm run \
    --system "You are a software engineering instructor." \
    --param temperature=0.7 \
    --param max_tokens=256

For multi-turn conversations, use the --transport conversation flag and pass a JSON message list:

echo '[{"role": "user", "content": "Hi!"}, {"role": "assistant", "content": "Hello! How can I help?"}, {"role": "user", "content": "What is an API?"}]' | \
  flama model mlx-community_gemma-4-E2B-it-qat-4bit.flm run --transport conversation

Streaming responses with flama model stream

For an interactive, token-by-token experience (especially useful with larger responses), use stream instead of run. Tokens are printed as they are generated, giving you immediate feedback:

echo "What is flama (python package)?" | \
  flama model mlx-community_gemma-4-E2B-it-qat-4bit.flm stream --system "Be concise."

Flama is a Python framework for building production-ready ML and generative AI APIs. It lets you serve models behind HTTP endpoints with minimal code, supporting HuggingFace, vLLM, and MLX backends, OpenAI/Anthropic/Ollama-compatible protocols, built-in chat interfaces, and the Model Context Protocol for agent tooling.

The streaming output appears progressively in your terminal, character by character, making it feel like a real conversation. This is especially satisfying when working with models that produce longer, more detailed responses.

You can also ask the model about itself and the framework it runs on:

echo "How do I serve an ML model with Flama?" | \
  flama model mlx-community_gemma-4-E2B-it-qat-4bit.flm stream \
    --system "You are a helpful assistant that knows about the Flama Python framework."

If you want to see multiple output channels (for instance, reasoning and output), pass --channel:

echo "Solve step by step: what is 23 * 47?" | \
  flama model mlx-community_gemma-4-E2B-it-qat-4bit.flm stream \
    --channel thinking --channel output

Serving the model over HTTP

The true power of Flama lies in going from a local model to a production-ready HTTP API in a single command. No Python code, no configuration files, no Docker images. Just flama serve.

The flama serve command

To serve the model we downloaded earlier:

flama serve --model file=mlx-community_gemma-4-E2B-it-qat-4bit.flm,url=/,name=gemma

INFO:     Started server process [52341]
INFO:     Waiting for application startup.
INFO:     Model starting (name: gemma)
INFO:     Model ready (name: gemma)
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)

That is it. A single command and your model is live behind a full HTTP API. Let us unpack what --model accepts:

  • file (required): Path to the .flm artifact.
  • url: The URL prefix under which the model's endpoints are mounted (default: /).
  • name: The resource name, used for OpenAPI tags and dependency injection.
  • serving: Comma-separated list of dialects to enable (e.g., native,openai,anthropic,ollama). When omitted, all dialects are mounted.
  • params: Default generation parameters (e.g., temperature=0.7).

You can serve multiple models in a single application:

flama serve \
  --model file=gemma.flm,url=/gemma,name=gemma,serving=native+openai \
  --model file=qwen.flm,url=/qwen,name=qwen,serving=native+anthropic

And you can configure the server with the usual options:

flama serve \
  --model file=mlx-community_gemma-4-E2B-it-qat-4bit.flm,url=/,name=gemma \
  --server-host 0.0.0.0 \
  --server-port 9000 \
  --app-title "My LLM API" \
  --app-docs /docs/

The built-in chat interface

When the native serving dialect is enabled (which it is by default), your model comes with a built-in chat interface accessible at the /chat/ route (relative to the model's URL prefix). If you served the model at /, then navigate to http://127.0.0.1:8000/chat/

You will be greeted with a polished, production-quality chat interface where you can type prompts and watch the model's responses stream in token by token. The interface renders Markdown, LaTeX math (via KaTeX), and Mermaid diagrams out of the box, so technical answers look exactly as intended.

The chat interface requires no frontend code, no build step, and no external dependencies. It is a self-contained single-page application served directly from the framework. Every model you serve gets its own chat window (e.g., /gemma/chat/, /qwen/chat/), each connected to its respective model's streaming endpoint.

Powering agentic workflows

One of the most compelling use cases for a locally served LLM is powering agentic workflows. Because Flama exposes your model through industry-standard protocols (OpenAI, Anthropic, Ollama), any tool that speaks those protocols can use your local model as its backend.

Using Claude CLI with a local model

A practical example is using the Claude CLI with a local model served by Flama. Instead of sending your prompts to Anthropic's servers, you can route them through your own locally-running
model.

First, make sure your model is serving with the Anthropic dialect enabled:

flama serve --model file=mlx-community_gemma-4-E2B-it-qat-4bit.flm,url=/,name=gemma,serving=native+anthropic

Then, configure Claude CLI to use your local Flama endpoint by adding the following to your ~/.claude/settings.json (or .claude/settings.local.json for a project-specific override):

{
  "env": {
    "ANTHROPIC_BASE_URL": "http://127.0.0.1:8000/anthropic",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "gemma",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "gemma",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "gemma"
  }
}

With this configuration in place, simply launch Claude CLI as usual:

claude

Claude CLI will now route all its requests through your local Flama-served model instead of Anthropic's cloud. Here is
what a typical interaction looks like:

❯ claude

What is this repo about?

∴ Thinking…

  The user is asking what the repository is about.
  I should use the Agent tool to perform a general-purpose search or exploration,
  as this is a broad question about the project's context.

⏺ Agent(Find out what the repository is about)
  ⎿  Done (2 tool uses · 14.5k tokens · 36s)

∴ Thinking…

  The agent returned a detailed summary of the project, which is a Python library
  called "Flama" for developing and deploying APIs, especially ML APIs, focusing
  on simplifying boilerplate code while providing robust features like schema
  validation, dependency injection, and automatic documentation.

⏺ The repository is a Python library called Flama, which provides a framework
  for developing and deploying APIs, with a special focus on Machine Learning
  (ML) applications.

  It aims to make deploying ML APIs "ridiculously simple" by simplifying
  boilerplate code while offering robust features such as:
  - API development for GraphQL, REST, and ML endpoints.
  - Resource handling with CRUD methods over SQLAlchemy tables.
  - Schema validation for inputs and outputs.
  - Dependency Injection via Components.
  - Automatic generation of OpenAPI documentation (Swagger UI, ReDoc).

  What specific part of the framework or implementation would you like to explore next?

Your agentic tasks (code generation, file editing, research) run entirely on your local hardware. This gives you:

  • Privacy: Your prompts and code never leave your machine.
  • Cost: No API usage charges for development and experimentation.
  • Speed: No network latency to cloud providers (especially valuable for iterative agent loops).
  • Control: You choose the model, the quantisation, and the generation parameters.

This same pattern works with any agent framework that supports custom API base URLs: LangChain, CrewAI, AutoGen, or any
custom tool that accepts a base URL configuration.

Conclusions

Flama 2.0 makes the journey from "I want to use an LLM" to "I have a production-ready API" as short as possible. The CLI provides three levels of interaction:

  1. flama get: Download and package any model from HuggingFace into a portable .flm artifact.
  2. flama model: Interact with the model directly in your terminal, for quick testing and scripting.
  3. flama serve: Serve the model over HTTP with OpenAI/Anthropic/Ollama compatibility, a built-in chat interface, and streaming support.

No boilerplate Python code, no YAML configuration, no container orchestration. Just the CLI.

The fact that Flama speaks the protocols your tools already understand (OpenAI, Anthropic, Ollama) means that adopting a local model in your workflow requires changing nothing but a base URL. Your existing SDKs, agent frameworks, and chat interfaces work without modification.

In upcoming posts, we will explore how to build MCP servers with Flama to expose tools and resources to AI agents, and how to combine LLM serving with the Model Context Protocol for truly powerful agentic applications.

References

Support our work

If you find Flama useful for building robust Machine Learning and Generative AI APIs, we'd be thrilled if you showed your support by giving us a ⭐ on GitHub. Your stars are the best fuel for our development efforts!

You can also stay updated with the latest news and development threads by following us on 𝕏.

About the authors

Vortico: We specialize in software development, helping businesses enhance and expand their AI and technology capabilities.