承接 krisciunaskarolis/openai-images-generator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

krisciunaskarolis/openai-images-generator

Composer 安装命令:

composer require krisciunaskarolis/openai-images-generator

包简介

PHP client for OpenAI images generation

README 文档

README

PHP client for OpenAI image generation API (beta).

Client allows:

  • to generate images based on text prompts.
  • to download and save generated images.

Getting Started

Installation

composer require krisciunaskarolis/openai-images-generator

Authentication

The OpenAI API uses API keys for authentication. Visit your API Keys page to retrieve the API key you'll use in your requests.

Image generation

To generate images based on text prompts:

use Krisciunas\OpenAi\Api\GenerateImageCommand;
use Krisciunas\OpenAi\Api\ImagePrompt;

$authorizationToken = 'YOUR-OPENAI-API-KEY';
$imagesGenerationCommand = new GenerateImageCommand();

$imagesData = $imagesGenerationCommand->execute(
    $authorizationToken,
    new ImagePrompt(
        'small kitty playing with red fish', //A text description of the desired images. The maximum length is 1000 characters.
        4, //Number of images to generate. Must be between 1 and 10
        ImagePrompt::SIZE_256x256, // The size of generated images
        ImagePrompt::FORMAT_URL //The format in which images are returned
    ),
);

Saving images

To save generated images:

$imagesPersistor = new ImagesPersist('/PATH/TO/IMAGES/DIRECTORY/');
$imagesPersistor->persist($imagesData, 'FILENAME_FORMAT_%s.png');

Both images response formats (urls and base_64 encoded images data) are supported.

When saving images, placeholder in filename format will be replaced by images counter value, starting from 0.

Supported response formats

\Krisciunas\OpenAi\Api\ImagePrompt::FORMAT_URL;
\Krisciunas\OpenAi\Api\ImagePrompt::FORMAT_BASE_64;

Supported image sizes

\Krisciunas\OpenAi\Api\ImagePrompt::SIZE_256x256;
\Krisciunas\OpenAi\Api\ImagePrompt::SIZE_512x512;
\Krisciunas\OpenAi\Api\ImagePrompt::SIZE_1024x1024;

Limitations

According to OpenAI, The Images API is in beta. During this time the API and models will evolve. To ensure all users can prototype comfortably, the default rate limit is 20 images per minute, 50 per 5 minutes.

Authors

统计信息

  • 总下载量: 147
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-12-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固