Download the PHP package erdemkose/generative-ai-php without Composer

On this page you can find all versions of the php package erdemkose/generative-ai-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 generative-ai-php

Gemini API PHP Client - Example

Total Downloads Latest Version License

Gemini API PHP Client

Gemini API PHP Client allows you to use the Google's generative AI models, like Gemini Pro and Gemini Pro Vision.

This library is not developed or endorsed by Google.

Table of Contents

Installation

You need an API key to gain access to Google's Gemini API. Visit Google AI Studio to get an API key.

First step is to install the Gemini API PHP client with Composer.

Gemini API PHP client does not come with an HTTP client. If you are just testing or do not have an HTTP client library in your project, you need to allow php-http/discovery composer plugin or install a PSR-18 compatible client library.

How to use

Basic text generation

Text generation with system instruction

System instruction is currently supported only in beta version

Multimodal input

Image input modality is only enabled for Gemini Pro Vision model

Chat Session (Multi-Turn Conversations)

Chat Session with history

Streaming responses

Requires curl extension to be enabled

In the streaming response, the callback function will be called whenever a response is returned from the server.

Long responses may be broken into separate responses, and you can start receiving responses faster using a content stream.

Streaming Chat Session

Requires curl extension to be enabled

Embed Content

Tokens counting

Listing models

Advanced Usages

Using Beta version

Safety Settings and Generation Configuration

Using your own HTTP client

Using your own HTTP client for streaming responses

Requires curl extension to be enabled

Since streaming responses are fetched using curl extension, they cannot use the custom HTTP client passed to the Gemini Client. You need to pass a CurlHandler if you want to override connection options.

The following curl options will be overwritten by the Gemini Client.

You can also pass the headers you want to be used in the requests.


All versions of generative-ai-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
php-http/discovery Version ^1.19
psr/http-client Version ^1.0
psr/http-client-implementation Version *
psr/http-factory Version ^1.0.2
psr/http-factory-implementation Version *
psr/http-message Version ^1.0.1 || ^2.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 erdemkose/generative-ai-php contains the following files

Loading the files please wait ....