Knowledge2026年5月7日·1 分钟阅读

Mistral Codestral — 22B Open-Weight Coding Model

Codestral is Mistral's coding-specialized model. 22B params, 32K context, 80+ languages including Python, JS, Go, Rust, Bash. Free for non-commercial use.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Stage only · 15/100Stage only
Agent 入口
任意 MCP/CLI Agent
类型
Knowledge
安装
Stage only
信任
信任等级:New
入口
Asset
通用 CLI 安装命令
npx tokrepo install 055b165e-d732-4e1d-a1b3-70be25393826

简介

Codestral 是 Mistral AI 的编码专用模型 —— 220 亿参数、32K 上下文、覆盖 Python / JavaScript / Bash / Fortran 等 80+ 语言。开源权重的 Codestral 22B 在科研和非商用场景免费;生产用最新 Codestral 通过 Mistral API 或 Le Chat 调。适合 Continue / Aider 本地补全、延迟敏感的代码生成。兼容 Ollama / vLLM / llama.cpp / Continue / Aider / LiteLLM。装机时间 5 分钟(ollama pull 或拿 API key)。


用 Ollama 本地跑 Codestral

# 拉模型
ollama pull codestral

# 聊天
ollama run codestral

# 当补全服务跑(端口 11434)
curl http://localhost:11434/api/generate -d '{
  "model": "codestral",
  "prompt": "Write a Rust function that returns the Nth Fibonacci number using memoization."
}'

Continue 接 Codestral

// Continue 扩展的 config.json
{
  "models": [
    {
      "title": "Codestral (local)",
      "provider": "ollama",
      "model": "codestral",
      "apiBase": "http://localhost:11434"
    }
  ],
  "tabAutocompleteModel": {
    "title": "Codestral Autocomplete",
    "provider": "ollama",
    "model": "codestral"
  }
}

Aider 接 Codestral

# 走 Mistral API(生产)
export MISTRAL_API_KEY=your-key
aider --model mistral/codestral-latest

# 或走本地 Ollama
aider --model ollama/codestral

通过 LiteLLM

from litellm import completion

response = completion(
    model="codestral/codestral-latest",
    messages=[{"role": "user", "content": "Refactor this Python function to use list comprehensions"}],
    api_key=os.environ["CODESTRAL_API_KEY"],
)

Codestral 和通用 Mistral 模型对比

模型 专长 适合
Mistral Small 通用 聊天、摘要、RAG
Codestral 编码专用 Tab 补全、重构、代码问答
Mixtral 8x7B 专家混合 高吞吐推理

FAQ

Q: Codestral 免费吗? A: Codestral 22B 开源权重在 Mistral AI Non-Production License 下免费(科研、非商用)。生产/商用通过 Mistral 的付费 API(la-platforme.mistral.ai)调。

Q: Codestral 跟 Claude / GPT 在编码上比怎样? A: 代码专项 benchmark(HumanEval、MBPP)上 Codestral 跟 Claude 3.5 Sonnet 持平。综合推理+编码 Claude / GPT-4 仍领先。Codestral 的胜场是本地部署和低延迟。

Q: Codestral 能微调吗? A: 能。Mistral 给了 Codestral 的 LoRA 微调配方。开源权重版本可以用任何标准工具(axolotl / unsloth / trl)微调。Mistral 也提供托管微调 API。


🙏

来源与感谢

Built by Mistral AI. Open-weights under Mistral AI Non-Production License.

Codestral on Hugging Face — ⭐ 1,500+

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产