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.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
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)等任何兼容端点。

环境要求

安装

快速开始

对话补全(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
Requires php Version ^8.1
guzzlehttp/guzzle Version ^7.0
psr/http-client Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ljguo-latex/openai-php contains the following files

Loading the files please wait ...