AI/TLDR

DeepSeek Recipe

DeepSeek's own Rust and Python library for encoding V4 and V4.1 prompts and parsing model output

TokenizersOpen source
Latest
0.1.0
Updated
10 Sep 2026
Language
Rust
License
MIT
Coverage
1 story

What's new

0.1.010 Sep 2026

DeepSeek published deepseek-recipe, the official library for converting Messages, Chat Completions and Responses requests into DeepSeek V4 and V4.1 prompts and parsing model output back. The Rust crate landed on crates.io as 0.1.0 and the Python bindings on PyPI, both MIT-licensed.

Latest news

Overview

DeepSeek Recipe is the prompt-format layer for DeepSeek models, published by DeepSeek itself as Rust crates with Python bindings. It answers a question every team serving open weights has to answer somehow: given a chat request, what exact text — or exact token ids — should go into the model, and how should the raw output be turned back into a response? Instead of describing that format in a model card and leaving each provider to reimplement it, DeepSeek ships the implementation.

The design routes everything through one shared `Conversation` type. Requests arriving in the Messages, Chat Completions or Responses format are converted into a `Conversation`, that `Conversation` is rendered into a prompt or a token-id sequence for DeepSeek V4 or V4.1, and the model's output is parsed back into whichever response format the caller asked for. Because every format converts to and from the same middle type, adding a format costs one converter rather than one per pair. Streaming and complete responses are both supported, along with text, images, reasoning content and client tool calls.

The repository is more than a library. Alongside the `deepseek-recipe-core`, `deepseek-recipe-encoding`, `deepseek-recipe-image` and `deepseek-recipe-python` crates it carries a browser demo for encoding a prompt, inspecting its special tokens and decoding a full model output, plus runnable example API servers in Rust (Axum) and Python (FastAPI). Code and public documentation are MIT-licensed, with separate notices covering the tokenizer files.

Some capabilities are explicitly not implemented yet: 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 beyond `apply_patch`, and encrypted thinking content. The README lists these, so it is worth reading that list before assuming a feature is present.

What it does

  • Converts Messages, Chat Completions and Responses requests into a single `Conversation` type, and converts model output back into the matching response format
  • Encodes DeepSeek V4 and V4.1 conversations into either a rendered prompt or raw token ids
  • Carries thinking modes, reasoning effort levels, temperature, top_p and token limits through into the encoded prompt
  • Handles images supplied as base64 or as URLs, applying the V4.1 preprocessing step via OpenCV in a dedicated image crate
  • Parses streamed output incrementally, so reasoning content and client tool calls arrive already decoded
  • Ships a web demo for encoding prompts, inspecting special tokens and decoding complete model output
  • Includes example API servers in both Rust (Axum) and Python (FastAPI)
  • MIT-licensed code and documentation, with tokenizer notices provided separately

Getting started

DeepSeek Recipe is usable from either Python or Rust. The commands below are the install instructions from the project README.

Install the Python bindings

Requires Python 3.10 or newer.

bashbash
python3 -m pip install deepseek-recipe

Or add the Rust crates

The core crate handles request and response conversion; the encoding crate renders conversations into prompts and token ids.

bashbash
cargo add deepseek-recipe@0.1 deepseek-recipe-encoding@0.1

Convert a request and encode it

In Python, a request is parsed into a `ChatCompletionRequest`, converted into the shared `Conversation` type, and rendered with a `DeepseekV41Encoding` into the prompt the model expects.

pythonpython
from deepseek_recipe import ChatCompletionRequest, DeepseekV41Encoding

Inspect prompts in the browser demo

The repository ships an encoding and decoding demo. Run it from the repo root and open the printed address to encode a prompt, see its special tokens, and decode a complete model output.

bashbash
cargo run -p encoding-decoding-demo --locked

Start from an example server

`server-rs` (Axum) and `server-py` (FastAPI) are complete example API servers built on the library — the shortest path to a working endpoint that speaks one of the supported request formats.

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Serving DeepSeek V4 or V4.1 open weights on your own hardware with the prompt format the model was trained for
  • Building an API gateway that accepts Messages, Chat Completions or Responses requests and targets DeepSeek models
  • Checking an existing chat template against the reference implementation when evaluation scores look lower than expected
  • Decoding streamed DeepSeek output into structured reasoning content and tool calls without writing a parser
  • Handling image inputs for DeepSeek V4.1 with the same preprocessing the model expects

How DeepSeek Recipe compares

DeepSeek Recipe alongside other open-source tokenizers tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
Hugging Face Tokenizers★ 11kThe Rust tokenizer library behind the Transformers ecosystem: train BPE, WordPiece and Unigram vocabularies, then encode with alignment tracking, truncation and padding.
GigaToken★ 4.1kA Rust tokenizer that encodes text at gigabytes per second and drops into existing Hugging Face Tokenizers or tiktoken code paths through compatibility wrappers.
DeepSeek RecipeDeepSeek's own Rust and Python library for encoding V4 and V4.1 prompts and parsing model output