deepseek-php/deepseek-php-client
Composer 安装命令:
composer require deepseek-php/deepseek-php-client
包简介
deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.
关键字:
README 文档
README
DeepSeek PHP Client
⚡️ A community-driven, open-source PHP client for DeepSeek AI, officially listed in the DeepSeek API documentation and built for expressive, production-ready AI integrations.
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 omaralwi2010@gmail.com
📄 License
This package is open-source software licensed under the MIT License.
deepseek-php/deepseek-php-client 适用场景与选型建议
deepseek-php/deepseek-php-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 87.91k 次下载、GitHub Stars 达 466, 最近一次更新时间为 2025 年 01 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「php」 「api」 「client」 「sdk」 「nlp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 deepseek-php/deepseek-php-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 deepseek-php/deepseek-php-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 deepseek-php/deepseek-php-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The bundle for easy using json-rpc api on your project
A PSR-7 compatible library for making CRUD API endpoints
Bundle Symfony DaplosBundle
Alfabank REST API integration
Biblioteca PHP pura para pagamentos SISP/Vinti4 de Cabo Verde.
Zero-dependency raw PHP DNS resolver, domain-ownership verification, and intoDNS/MxToolbox-style diagnostics. Queries authoritative nameservers directly over sockets — never trusts the recursive cache for ownership checks.
统计信息
- 总下载量: 87.91k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 471
- 点击次数: 38
- 依赖项目数: 6
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-02