deepseek-recipe ≠ DeepInfer engine

Protocol layer: convert API requests, render prompts, encode tokens, parse outputs. It does not run inference. You provide the backend, tools, and HTTP.

Is / is-not

deepseek-recipeDeepInfer
IsRequest → Conversation → prompt / token IDs; output → Chat Completions / Responses / MessagesHigh-performance inference engine (offline OSS path for V4.1-Flash)
Is notDoes not load weights or run kernelsDoes not replace protocol conversion (use recipe or your own glue)
Caller must provideModel inference + tool execution + HTTP transportSupported accelerators + build env
LicenseMITApache-2.0

Protocol surface

max_tokens defaults

From the recipe README: after encoding, ConversationRequest::resolve_max_tokens supplies defaults when the request sets none:

ModeDefault max_tokens
Non-thinking8192
Thinking65536
Thinking + max effort131072

Python install

Python 3.10+:

python3 -m pip install deepseek-recipe
from deepseek_recipe import ChatCompletionRequest, ConversionOptions, DeepseekV41Encoding

request = ChatCompletionRequest({
    "model": "DeepSeek-V4.1-Flash",
    "messages": [{"role": "user", "content": "Hello"}],
})
converted = request.convert(ConversionOptions())
rendered = DeepseekV41Encoding().render_conversation(converted.conversation)
print(rendered.prompt)

Rust install

cargo add [email protected] [email protected] serde_json@1

See upstream development guide for source builds and image dependencies. Demo: cargo run -p encoding-decoding-demo --locked → http://127.0.0.1:7778.

Glue notes

API triad (Messages · Chat Completions · Responses)

From the recipe README and production explainers: one Conversation format is shared; adapters map Messages / Chat Completions / Responses in and out. Special-token injection is blocked by encoding control tokens by ID while ordinary text that looks like tags stays literal. Streaming uses a state machine across UTF-8 / DSML / tool-argument chunk boundaries.

ConcernRecipe responsibilityCaller still owns
Request shapesConvert triad → Conversation + prompt / tokensHTTP auth, rate limits
Injection safetySpecial tokens by ID; user text cannot inject control tokensUntrusted URL fetch filters for images
StreamingIncremental parse of reasoning / body / toolsInference token stream from your backend
ToolsParse tool-call events into protocol framesActually execute tools