Download the PHP package ljguo-latex/openai-php without Composer
On this page you can find all versions of the php package ljguo-latex/openai-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download ljguo-latex/openai-php
More information about ljguo-latex/openai-php
Files in ljguo-latex/openai-php
Download ljguo-latex/openai-php
More information about ljguo-latex/openai-php
Files in ljguo-latex/openai-php
Vendor ljguo-latex
Package openai-php
Short Description A PHP client for the OpenAI API with support for custom URL, API key, and model.
License MIT
Homepage https://github.com/ljguo-latex/openai-php
Package openai-php
Short Description A PHP client for the OpenAI API with support for custom URL, API key, and model.
License MIT
Homepage https://github.com/ljguo-latex/openai-php
Please rate this library. Is it a good library?
Informations about the package openai-php
openai-php
适用于 OpenAI API 的轻量级 PHP 客户端,支持链式调用、流式输出,以及自定义接口地址、API Key 和默认模型。可无缝对接 OpenAI、Azure OpenAI、本地模型(如 Ollama)等任何兼容端点。
环境要求
- PHP 8.1+
- Composer
安装
快速开始
对话补全(Chat)
普通请求
多轮对话
流式输出
流式输出获取 token 用量
其他链式方法
| 方法 | 说明 |
|---|---|
model(string) |
指定模型 |
system(string) |
添加 system 消息 |
user(string) |
添加 user 消息 |
assistant(string) |
添加 assistant 消息 |
message(string) |
user() 的别名 |
withMessages(array) |
批量设置消息数组 |
temperature(float) |
采样温度,默认 1.0 |
maxTokens(int) |
最大 token 数 |
option(string, mixed) |
设置任意额外参数 |
文本补全(Completions)
向量嵌入(Embeddings)
模型列表(Models)
自定义 / 兼容端点
只需修改 baseUrl 即可对接任何 OpenAI 兼容 API:
错误处理
直接实例化客户端
运行测试
开源协议
MIT
All versions of openai-php with dependencies
PHP Build Version
Package Version
The package ljguo-latex/openai-php contains the following files
Loading the files please wait ...