AI/TLDR

DeepSeek · 2026-09-10 · major

DeepSeek Recipe — the official prompt encoder for V4 and V4.1

DeepSeek Recipe is an MIT-licensed Rust library with Python bindings that turns Messages, Chat Completions and Responses API requests into DeepSeek V4 and V4.1 prompts, then parses streamed output back into each format.

GitHub social card for the deepseek-ai/deepseek-recipe repository

DeepSeek's own library for turning API requests into V4 and V4.1 prompts, and streamed output back into responses.

Quick facts

MakerDeepSeek
LicenseMIT
LanguageRust core with Python bindings
Python packagedeepseek-recipe 0.1.1 (Python 3.10+)
Rust cratedeepseek-recipe 0.1.0
Models coveredDeepSeek V4 and V4.1
Request formatsMessages, Chat Completions, Responses

What is it?

DeepSeek Recipe publishes the prompt format DeepSeek models actually expect, as code rather than as a description. A Rust core converts a Messages, Chat Completions or Responses request into one shared Conversation type, renders it into the prompt or token ids for DeepSeek V4 and V4.1, and parses the model's output back into the matching response shape. Python bindings, example servers and a browser demo ship in the same repository.

How does it work?

Every supported API format is converted into a single Conversation representation, so each format needs only one converter in and one out rather than a path to every other format. The encoder carries thinking modes, reasoning effort, temperature, top_p and token limits through to the prompt, and a separate image crate does the V4.1 preprocessing with OpenCV. Streamed output is decoded as it arrives, so reasoning content and client tool calls come back already parsed.

Why does it matter?

A chat template is easy to get subtly wrong, and a wrong one costs accuracy without ever raising an error. Shipping the encoder as MIT-licensed code gives serving stacks, gateways and evaluation harnesses one checkable reference for DeepSeek V4 and V4.1 instead of a template copied out of a model card — useful right now, with DeepSeek V4.1 Flash weights days old.

Who is it for?

inference providers and API gateway builders

Frequently asked questions

Is DeepSeek Recipe open source?
DeepSeek Recipe is released under the MIT License, covering both the code and the public documentation, with separate notices for the tokenizer files. That is one of the most permissive licenses available, so a commercial inference provider can vendor the encoder, patch it, and ship it inside a closed product without asking DeepSeek for anything.
What does DeepSeek Recipe not support yet?
Several things are listed as not implemented in DeepSeek Recipe: token probability outputs, document, audio and video inputs, file retrieval, server-side tool execution, JSON Schema and regex output constraints, more than one completion per request, custom Responses tools other than apply_patch, and encrypted thinking content.
How does DeepSeek Recipe handle images?
Images reach DeepSeek Recipe either as base64 data or as URLs, and a dedicated image crate applies the preprocessing step that DeepSeek V4.1 expects, using OpenCV. That keeps the pixel handling identical to the reference path, which matters because a mismatched resize or crop changes what the vision tower actually sees.
Can I use DeepSeek Recipe from Rust as well as Python?
Both. Rust users run cargo add deepseek-recipe@0.1 deepseek-recipe-encoding@0.1, and Python 3.10+ users install the bindings from PyPI. The repository also ships runnable example API servers in both languages, one built on Axum for Rust and one on FastAPI for Python, plus a browser demo for inspecting encoded prompts.

Try it

python3 -m pip install deepseek-recipe

Sources · 3 outlets

Tags

  • deepseek
  • open-source
  • rust
  • python
  • inference
  • prompt-format
  • tokenizer
  • tool-calling
  • api
  • mit-license

← All releases · Learn AI