使用 json_object 响应格式时提示词里必须包含 json 字样,否则接口报错;deepseek-chat 与 deepseek-reasoner 别名将于 2026-07-24 从 API 退役,旧模型常量在 v3.0.0 移除;默认温度 1.3、max tokens 4096,不调用 withModel 时不发送 model 字段
deepseek-php-client
deepseek-phpMIT更新放缓面向 PHP 开发者的 DeepSeek AI 客户端,封装官方 API,提供链式调用和框架友好集成,方便在 PHP 应用里接入对话与代码模型。
⚡️ A community driven PHP client for DeepSeek AI, designed to bring clean API access, fluent developer experience, and framework-friendly integration to PHP applications.
composer require deepseek-php/deepseek-php-clientREADME 未说明,仅要求 PHP 8.1+,模型推理在 DeepSeek 云端完成
PHP 客户端,让你在 PHP 项目里干净地调用 DeepSeek AI 接口
面向 PHP 开发者的 DeepSeek AI 客户端,封装官方 API,提供链式调用和框架友好集成,方便在 PHP 应用里接入对话与代码模型。
核心能力
- 用链式 Builder 组装请求,两行代码即可发起查询
- 支持流式响应,实时处理返回内容
- 兼容 PSR-18,可切换 Guzzle 或 Symfony HttpClient
- 内置 deepseek-v4-pro 与 v4-flash 模型常量
- 提供 Laravel 集成包与函数调用文档
容易踩的坑
- v2.1.0最新正式版2026-05-24 · 2026-05-24 00:51 UTC
What's Changed
- Create GitHub action workflows by @moassaad in https://github.com/deepseek-php/deepseek-php-client/pull/44
- Release v2.1.0 — Foundation + change logs (V4 models, base URL) by @omaralalwi in https://github.com/deepseek-php/deepseek-php-client/pull/55
Full Changelog: https://github.com/deepseek-php/deepseek-php-client/compare/v2.0.6...v2.1.0
- v2.0.62025-07-16 · 2025-07-16 21:47 UTC
查看更新说明
What's Changed
- feat / support response format option by @omaralalwi in https://github.com/deepseek-php/deepseek-php-client/pull/52
Full Changelog: https://github.com/deepseek-php/deepseek-php-client/compare/v2.0.5...v2.0.6
- v2.0.52025-07-16 · 2025-07-16 21:09 UTC
查看更新说明
What's Changed
- feat / support pass max tokens option by @omaralalwi in https://github.com/deepseek-php/deepseek-php-client/pull/51
Full Changelog: https://github.com/deepseek-php/deepseek-php-client/compare/v2.0.4...v2.0.5
- v2.0.4v2.0.4 – Function Calling Support 🚀2025-06-11 · 2025-06-11 22:58 UTC
查看更新说明
DeepSeek PHP Client now supports Function Calling – allowing the model to call external tools to expand its capabilities and deliver dynamic, tool-aware responses! 🧠🔧 Learn more in the [Function Calling Guide 📘](https://api-docs.deepseek.com/guides/function_calling)
✨ What's New
-
🧰 Function Calling Feature added ➤ By @moassaad in [#43](https://github.com/deepseek-php/deepseek-php-client/pull/43)
-
📝 Documentation Fix for
setTemperature➤ By @kghamilton89 in [#46](https://github.com/deepseek-php/deepseek-php-client/pull/46) -
Docs / add function calilng docs by @omaralalwi in https://github.com/deepseek-php/deepseek-php-client/pull/49
👋 New Contributor
- 🎉 Welcome @kghamilton89 — thanks for your first contribution! ➤ [#46](https://github.com/deepseek-php/deepseek-php-client/pull/46)
📌 Full Changelog: [Compare v2.0.3...v2.0.4](https://github.com/deepseek-php/deepseek-php-client/compare/v2.0.3...v2.0.4)
-
- v2.0.32025-02-23 · 2025-02-23 23:54 UTC
查看更新说明
What's Changed
- fix symfony client Compatibility by @omaralalwi in https://github.com/deepseek-php/deepseek-php-client/pull/40
Full Changelog: https://github.com/deepseek-php/deepseek-php-client/compare/v2.0.2...v2.0.3
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Table of Contents
- ✨ Features
- 📦 Installation
- 🚀 Quick Start
- 🆕 Migration Guide
- 📝 Changelog
- 🧪 Testing
- 🔒 Security
- 📄 License
✨ Features
- Seamless API Integration: PHP-first interface for DeepSeek's AI capabilities.
- Fluent Builder Pattern: Chainable methods for intuitive request building.
- Enterprise Ready: PSR-18 compliant HTTP client integration.
- Latest DeepSeek V4 Models: First-class support for
deepseek-v4-proanddeepseek-v4-flashwith 1M-token context windows and thinking / non-thinking modes. - Streaming Ready: Built-in support for real-time response handling.
- Many Http Clients: easy to use
Guzzle http client(default) , orsymfony http client. - Framework Friendly: Laravel & Symfony packages available.
Supported Models
Models::V4_PRO— flagship 1.6T/49B-active model, max 384K output tokens.Models::V4_FLASH— fast, economical 284B/13B-active model, max 384K output tokens.Legacy
Models::CHAT,Models::CODER,Models::R1, andModels::R1Zeroare deprecated and will be removed in v3.0.0. Thedeepseek-chatanddeepseek-reasoneraliases retire from the DeepSeek API on 2026-07-24.
📦 Installation
Require the package via Composer:
composer require deepseek-php/deepseek-php-client
Requirements:
- PHP 8.1+
🚀 Quick Start
Basic Usage
Get started with just two lines of code:
use DeepSeek\DeepSeekClient;
$response = DeepSeekClient::build('your-api-key')
->query('Explain quantum computing in simple terms')
->run();
echo $response;
📌 Defaults used:
- Model: API default (no
modelfield sent unless you callwithModel()) - Temperature: 1.3 (
TemperatureValues::GENERAL_CONVERSATION) - Max tokens: 4096
- Response format:
text
Advanced Configuration
use DeepSeek\DeepSeekClient;
use DeepSeek\Enums\Models;
$client = DeepSeekClient::build(apiKey:'your-api-key', baseUrl:'https://api.deepseek.com', timeout:30, clientType:'guzzle');
$response = $client
->withModel(Models::V4_PRO->value)
->withStream()
->setTemperature(1.2)
->setMaxTokens(8192)
->setResponseFormat('text') // or "json_object" with careful .
->query('Explain quantum computing in simple terms')
->run();
echo 'API Response:'.$response;
⚠️ DeepSeek JSON Mode Requirement
When using:
->setResponseFormat('json_object')
Your prompt must contain the word "json" in some form. Otherwise, the API will reject the request with the following error:
"Prompt must contain the word 'json' in some form to use 'response_format' of type 'json_object'"
🚫 Incorrect Usage
->setResponseFormat('json_object')
->query('Explain quantum computing in simple terms')
✅ Correct Usage
->setResponseFormat('json_object')
->query('Respond in valid JSON format. Explain quantum computing in simple terms.')
✅ Tip: For best results, also provide a JSON example or explicitly say: "Respond only in valid JSON."
Use with Symfony HttpClient
the package already built with symfony Http client, if you need to use package with symfony Http Client , it is easy to achieve that, just pass clientType:'symfony' with build function.
ex with symfony:
// with defaults baseUrl and timeout
$client = DeepSeekClient::build('your-api-key', clientType:'symfony')
// with customization
$client = DeepSeekClient::build(apiKey:'your-api-key', baseUrl:'https://api.deepseek.com', timeout:30, clientType:'symfony');
$client->query('Explain quantum computing in simple terms')
->run();
Get Models List
use DeepSeek\DeepSeekClient;
$response = DeepSeekClient::build('your-api-key')
->getModelsList()
->run();
echo $response;
// {
// "object": "list",
// "data": [
// {"id": "deepseek-v4-pro", "object": "model", "owned_by": "deepseek"},
// {"id": "deepseek-v4-flash", "object": "model", "owned_by": "deepseek"},
// {"id": "deepseek-chat", "object": "model", "owned_by": "deepseek"}, // deprecated, retires 2026-07-24
// {"id": "deepseek-reasoner", "object": "model", "owned_by": "deepseek"} // deprecated, retires 2026-07-24
// ]
// }
Function Calling
Function Calling allows the model to call external tools to enhance its capabilities.[1]
You Can check the documentation for function calling in FUNCTION-CALLING.md
🛠 Framework Integration
Laravel Deepseek Package
🚧 Migration Guide
Upgrading from v1.x? Check our comprehensive Migration Guide for breaking changes and upgrade instructions.
📝 Changelog
Detailed release notes available in CHANGELOG.md
🧪 Testing
./vendor/bin/pest
Test coverage coming in v2.1.
🐘✨ DeepSeek PHP Community ✨🐘
Click the button bellow or join here to be part of our growing community!
Channel Structure 🏗️
- 🗨️ General - Daily chatter
- 💡 Ideas & Suggestions - Shape the community's future
- 📢 Announcements & News - Official updates & news
- 🚀 Releases & Updates - Version tracking & migration support
- 🐞 Issues & Bug Reports - Collective problem-solving
- 🤝 Pull Requests - Code collaboration & reviews
🔒 Security
Report Vulnerabilities: to [email protected]
📄 License
This package is open-source software licensed under the MIT License.