A Rust-based coding agent terminal tool, forked from OpenAI's Codex, built to get strong results from low-cost and open models.
deepseek-ai/deepseek-recipe
Rust libraries and Python bindings that convert LLM API formats into DeepSeek conversations and render prompts.
Open-source alternative to:DeepSeek-V4-Pro
DeepSeek-V4.1-Flash
- Stars
- 1,254
- Forks
- 116
- Open issues
- 29
- Last commit
- 22 hours ago
What is it?
deepseek-recipe is a set of Rust crates with Python bindings for putting a uniform layer between an inference backend and API clients that speak different protocols. Its job is protocol plumbing: take a request in Messages, Chat Completions or Responses format, turn it into a Conversation, render that conversation into a prompt (or token IDs) for DeepSeek models, then parse the model's output back into a response in the format the client asked for.
The library deliberately leaves the hard parts to the caller. Model inference, tool execution and HTTP transport are all supplied from outside; the crates only handle conversion, rendering and parsing. It supports text and images, thinking mode, client-side tool calls, Chat Completions `prefix` continuation, streaming responses, structured output via `json_schema` or `regex`, and log probability passthrough. Image handling covers base64 and external URLs, with preprocessing by OpenCV for DeepSeek V4.1 and a `DestinationFilter` option for services that fetch untrusted URLs. Tokenizer-encoded prompts are supported for counting reasoning tokens and resolving `max_tokens` against the model's context limit.
Both Rust and Python are first-class: a Rust example shows reading a Chat Completions request with serde and rendering a V4.1 prompt, and the Python package `deepseek_recipe` (Python 3.10+) does the same. A browser demo renders prompts, highlights special tokens and parses model output into Chat Completions, Responses or Messages responses.
Key features
- 01Converts Messages, Chat Completions and Responses requests into a shared Conversation format, and parses model output back into any of them.
- 02Renders DeepSeek V4 and V4.1 conversations into prompts, or encodes them into token IDs with an attached tokenizer.
- 03Supports streaming responses, thinking mode, client tool calls and Chat Completions `prefix` continuation.
- 04Handles structured output through Chat Completions `response_format` (`json_schema` or `regex`) and Responses `text.format` (`json_schema`).
- 05Accepts images as base64 or external URLs, preprocessing them with OpenCV for V4.1.
- 06Resolves `max_tokens` against the context limit, defaulting to 8192 outside thinking mode, 65536 in thinking mode and 131072 with `max` reasoning effort.
- 07Converts `logprobs` and `top_logprobs` into `InferenceOptions` while leaving probability computation to the backend.
- 08Ships with Python bindings (`deepseek_recipe`), an Axum example server, a FastAPI example server and a browser demo.
Use cases
- Wrapping a self-hosted DeepSeek inference backend so it can serve Messages, Chat Completions and Responses clients.
- Adding streaming, tool calls or structured JSON output to an existing model endpoint without rewriting each protocol.
- Preparing training or evaluation data by rendering conversations into exact model prompts.
- Counting tokens in prompts and reasoning output, or checking `max_tokens` against the model's context limit.
- Debugging prompt formatting and output parsing through the bundled browser demo.
Quick start
- 1
Install the Python package
python3 -m pip install deepseek-recipe - 2
Convert a Chat Completions request and render the prompt with the example code in the README
Things to know
- The library does not run model inference, tool execution, or HTTP transport; the caller must supply them.
- DeepSeek V4 does not accept images, so image content is replaced with a text placeholder.
- The Rust examples require a source build for image dependencies, which the README covers in a separate development guide.
Topics
FAQ
- What is deepseek-recipe?
- Rust libraries and Python bindings that convert LLM API formats into DeepSeek conversations and render prompts. deepseek-recipe is a set of Rust crates with Python bindings for putting a uniform layer between an inference backend and API clients that speak different protocols. Its job is protocol plumbing: take a request in Messages, Chat Completions or Responses format, turn it into a Conversation, render that conversation into a prompt (or token IDs) for DeepSeek models, then parse the model's output back into a response in the format the client asked for.
- Is deepseek-recipe free to use? What license does it have?
- deepseek-recipe is open source under the MIT license. Check the license terms before using it in commercial products.
- Is deepseek-recipe still maintained?
- Actively maintained. The last commit to deepseek-recipe was on Oct 19, 2026.
- What can I use deepseek-recipe for?
- Wrapping a self-hosted DeepSeek inference backend so it can serve Messages, Chat Completions and Responses clients. Adding streaming, tool calls or structured JSON output to an existing model endpoint without rewriting each protocol. Preparing training or evaluation data by rendering conversations into exact model prompts. Counting tokens in prompts and reasoning output, or checking `max_tokens` against the model's context limit. Debugging prompt formatting and output parsing through the bundled browser demo.
- How do I install deepseek-recipe?
- Install the Python package: python3 -m pip install deepseek-recipe Convert a Chat Completions request and render the prompt with the example code in the README
- Where can I get deepseek-recipe?
- The source code and installation instructions are on GitHub: https://github.com/deepseek-ai/deepseek-recipe
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
Open-source browser automation that uses LLMs and computer vision to run web workflows on any site, extending Playwright with AI commands.
A fast BPE tokeniser for OpenAI's models, used to convert text into tokens and back losslessly.
Open-source platform for building AI-powered chat bots that connect LLMs to Slack, Discord, Telegram, WeChat, Lark, DingTalk and more.
A command-line tool that opens coding agents like OpenCode and Claude Code preconfigured to run hosted or local open models.
A secure Python sandbox written in Rust for running code generated by AI, without containers.