Skip to main content

Introduction

The DeerFlowClient is an embedded Python client that provides direct programmatic access to DeerFlow’s agent capabilities without requiring LangGraph Server or Gateway API processes.
The Python Client implements the same protocol as the Gateway API, making it easy to switch between embedded mode and HTTP streaming without changing your event-handling logic.

Installation

The client is included in the DeerFlow backend package:

Basic Usage

Simple Chat

Streaming Responses

Query Configuration

Initialization Options

The client accepts several configuration parameters:
str | None
default:"None"
Path to config.yaml. Uses default resolution if None.
LangGraph Checkpointer
default:"None"
LangGraph checkpointer instance for state persistence. Required for multi-turn conversations on the same thread_id. Without a checkpointer, each call is stateless.
str | None
default:"None"
Override the default model name from config.
bool
default:"True"
Enable model’s extended thinking mode.
bool
default:"False"
Enable subagent delegation capabilities.
bool
default:"False"
Enable TodoList middleware for plan mode.

Example: Custom Configuration

Gateway API Alignment

The DeerFlowClient is designed to align with the Gateway API:
  • Event types match the LangGraph SSE protocol
  • Response schemas mirror Gateway API responses
  • File operations use the same virtual path structure
This means you can develop locally with the embedded client and deploy with the Gateway API without changing your code.

Multi-Turn Conversations

Multi-turn conversations require a checkpointer at initialization. Without one, each stream() / chat() call is stateless — thread_id is only used for file isolation (uploads / artifacts).

Agent Recreation

The system prompt (including date, memory, and skills context) is generated when the internal agent is first created and cached until the configuration key changes.
Call reset_agent() to force a refresh in long-running processes:
This is useful after:
  • External changes to memory
  • Skill installations
  • Configuration updates that should be reflected in the system prompt

API Reference

For detailed method documentation, see:

Chat

Single-message request/response

Streaming

Real-time event streaming

Configuration

Models, skills, memory, and file management