PHPackages                             aimeos/prisma - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. aimeos/prisma

ActiveLibrary[API Development](/categories/api)

aimeos/prisma
=============

A powerful PHP package for integrating media related Large Language Models (LLMs) into your applications

0.3.1(3mo ago)1171.8k↑133.3%[1 issues](https://github.com/aimeos/prisma/issues)1LGPL-2.1+PHPPHP ^8.1CI failing

Since Nov 13Pushed 2mo agoCompare

[ Source](https://github.com/aimeos/prisma)[ Packagist](https://packagist.org/packages/aimeos/prisma)[ RSS](/packages/aimeos-prisma/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (10)Versions (48)Used By (1)

PHP Prisma
==========

[](#php-prisma)

Light-weight PHP package for integrating multi-media and text related Large Language Models (LLMs) into your applications using a unified interface.

[Supported providers](#supported-providers)

- [Audio](#audio)
- [Image](#image)
- [Text](#text)
- [Video](#video)

[API usage](#api-usage)

- [ensure](#ensure): Ensures that the provider has implemented the method
- [has](#has): Tests if the provider has implemented the method
- [model](#model): Use the model passed by its name
- [withClientOptions](#withClientOptions): Add options for the Guzzle HTTP client
- [withSystemPrompt](#withSystemPrompt): Add a system prompt for the LLM
- [Response objects](#response-objects): How data is returned by the API

[Audio API](#audio-api)

- [demix](#demix): Separate an audio file into its individual tracks
- [denoise](#denoise): Remove noise from an audio file
- [describe](#describe): Describe the content of an audio file
- [revoice](#revoice): Exchange the voice in an audio file
- [speak](#speak): Convert text to speech in an audio file
- [transcribe](#transcribe): Converts speech of an audio file to text

[Image API](#image-api)

- [background](#background): Replace background according to the prompt
- [describe](#describe): Describe the content of an image
- [detext](#detext): Remove all text from the image
- [erase](#erase): Erase parts of the image
- [imagine](#imagine): Generate an image from the prompt
- [inpaint](#inpaint): Edit an image area according to a prompt
- [isolate](#isolate): Remove the image background
- [relocate](#relocate): Place the foreground object on a new background
- [repaint](#repaint): Repaint an image according to the prompt
- [uncrop](#uncrop): Extend/outpaint the image
- [upscale](#upscale): Scale up the image
- [vectorize](#vectorize): Creates embedding vectors from images

[Text API](#text-api)

- [translate](#translate): Translate texts from one language to another

[Video API](#video-api)

- [describe](#describe): Describe the content of a video

[Custom providers](#custom-providers)

- [Base skeleton](#base-skeleton)
- [Requests](#requests)
- [Responses](#responses)
- [Examples](#examples)

Supported providers
-------------------

[](#supported-providers)

- [Alibaba](https://www.alibabacloud.com/help/en/model-studio/model-api-reference/)
- [AudioPod AI](https://audiopod.ai/)
- [Bedrock Titan (AWS)](https://docs.aws.amazon.com/bedrock/latest/userguide/titan-models.html)
- [Black Forest Labs](https://docs.bfl.ai/quick_start/introduction)
- [Clipdrop](https://clipdrop.co/apis)
- [Cohere](https://docs.cohere.com/docs/the-cohere-platform)
- [DeepL](https://developers.deepl.com/docs)
- [Deepgram](https://deepgram.com/)
- [ElevenLabs](https://elevenlabs.io/docs/overview/intro)
- [Gemini (Google)](https://aistudio.google.com/models/gemini-2-5-flash-image)
- [Google Translate](https://cloud.google.com/translate/docs/reference/rest/v2/translate)
- [Groq](https://groq.com/)
- [Ideogram](https://ideogram.ai/api)
- [Mistral](https://docs.mistral.ai/api)
- [Murf](https://murf.ai/api)
- [OpenAI](https://openai.com/api/)
- [RemoveBG](https://www.remove.bg/api)
- [StabilityAI](https://platform.stability.ai/)
- [VertexAI (Google)](https://cloud.google.com/vertex-ai/generative-ai/docs)
- [VoyageAI](https://docs.voyageai.com/)

### Audio

[](#audio)

demixdenoisedescriberevoicespeaktranscribe**Alibaba**----yes-**AudioPod**yesyes-yesyesyes**Deepgram**----yesyes**ElevenLabs**---yesyesyes**Gemini**--yes---**Groq**--yes-yesyes**Mistral**--yes--yes**Murf**---yesyes-**OpenAI**--yes-yesyes### Image

[](#image)

backgrounddescribedetexteraseimagineinpaintisolaterecognizerelocaterepaintuncropupscalevectorize**Alibaba**----yes-------yes**Bedrock Titan**----yesyesyes-----yes**Black Forest Labs**----betabeta----beta--**Clipdrop**yes-yesyesyes-yes---yesyes-**Cohere**------------yes**Gemini**-yes--yes----yes---**Groq**-yes-----------**Ideogram**betabeta--betabeta---beta-beta-**Mistral**-------yes-----**OpenAI**-yes--yesyes-------**RemoveBG**------yes-yes----**StabilityAI**---yesyesyesyes---yesyes-**VertexAI**----yesyes-----yesyes**VoyageAI**------------yes### Text

[](#text)

translate**DeepL**yes**Google**yes### Video

[](#video)

describe**Gemini**yesInstallation
------------

[](#installation)

```
composer req aimeos/prisma

```

API usage
---------

[](#api-usage)

Basic usage:

```
use Aimeos\Prisma\Prisma;

$image = Prisma::image()
    ->using( '', ['api_key' => 'xxx'])
    ->model( '' ) // if model can be selected
    ->ensure( 'imagine' ) // make sure interface is implemented
    ->imagine( 'a grumpy cat' )
    ->binary();

$texts = Prisma::text()
    ->using( 'deepl', ['api_key' => 'xxx'])
    ->ensure( 'translate' )
    ->translate( ['Hello'], 'de' )
    ->texts();
```

### ensure

[](#ensure)

Ensures that the provider has implemented the method.

```
public function ensure( string $method ) : self
```

- @param **string** `$method` Method name
- @return **Provider**
- @throws \\Aimeos\\Prisma\\Exceptions\\NotImplementedException

**Example:**

```
\Aimeos\Prisma\Prisma::image()
    ->using( '', ['api_key' => 'xxx'])
    ->ensure( 'imagine' );
```

### has

[](#has)

Tests if the provider has implemented the method.

```
public function has( string $method ) : bool
```

- @param **string** `$method` Method name
- @return **bool** TRUE if implemented, FALSE if absent

**Example:**

```
\Aimeos\Prisma\Prisma::image()
    ->using( '', ['api_key' => 'xxx'])
    ->has( 'imagine' );
```

### model

[](#model)

Use the model passed by its name.

Used if the provider supports more than one model and allows to select between the different models. Otherwise, it's ignored.

```
public function model( ?string $model ) : self
```

- @param **string|null** `$model` Model name
- @return **self** Provider interface

**Example:**

```
\Aimeos\Prisma\Prisma::image()
    ->using( '', ['api_key' => 'xxx'])
    ->model( 'dall-e-3' );
```

### withClientOptions

[](#withclientoptions)

Add options for the Guzzle HTTP client.

```
public function withClientOptions( array `$options` ) : self
```

- @param **array&lt;string, mixed&gt;** `$options` Associative list of name/value pairs
- @return **self** Provider interface

**Example:**

```
\Aimeos\Prisma\Prisma::image()
    ->using( '', ['api_key' => 'xxx'])
    ->withClientOptions( ['timeout' => 120] );
```

### withSystemPrompt

[](#withsystemprompt)

Add a system prompt for the LLM.

It may be used by providers supporting system prompts. Otherwise, it's ignored.

```
public function withSystemPrompt( ?string $prompt ) : self
```

- @param **string|null** `$prompt` System prompt
- @return **self** Provider interface

**Example:**

```
\Aimeos\Prisma\Prisma::image()
    ->using( '', ['api_key' => 'xxx'])
    ->withSystemPrompt( 'You are a professional illustrator' );
```

### Response objects

[](#response-objects)

The methods return a *FileResponse*, *TextResponse* or *VectorResponse* object that contains the returned data with optional meta/usage/description information.

**FileResponse** objects:

```
$base64 = $response->base64(); // first base64 data, from binary, base64 and URL, waits for async requests
$file = $response->binary(); // first binary data, from binary, base64 and URL, waits for async requests
$url = $response->url(); // first URL, only if URLs are returned, otherwise NULL
$mime = $response->mimetype(); // image mime type, waits for async requests
$text = $response->description(); // image description if returned by provider
$bool = $response->ready(); // FALSE for async APIs until file is available
$file = $response->first(); // first available file object
$array = $response->files(); // all available file objects

// loop over all available files
foreach( $response as $name => $file ) {
    $file->binary()
}
```

URLs are automatically converted to binary and base64 data if requested and conversion between binary and base64 data is done on request too.

**TextResponse** objects:

```
$text = $response->text(); // first text content (non-streaming)
$text = $response->first(); // first available text
$texts = $response->texts(); // all texts (non-streaming)

// loop over all available texts
foreach( $response as $text ) {
    echo $text;
}
```

**VectorResponse** objects:

```
$vector = $response->first(); // first embedding vector if only one file has been passed
$vectors = $response->vectors(); // embedding vectors for the passed files in the same order

// loop over all available vectors
foreach( $response as $vector ) {
    print_r( $vector );
}
```

Included **meta data** (optional):

```
$meta = $response->meta();
```

It returns an associative array whose content totally depends on the provider.

Included **usage data** (optional):

```
$usage = $response->usage();
```

It returns an associative array whose content depends on the provider. If the provider returns usage information, the `used` array key is available and contains a number. What the number represents depdends on the provider too.

Audio API
---------

[](#audio-api)

### demix

[](#demix)

Separate an audio file into its individual tracks.

```
public function demix( Audio $audio, int $stems, array $options = [] ) : FileResponse
```

- @param **Audio** `$audio` Input audio object
- @param **int** `$stems` Number of stems to separate into (e.g. 2 for vocals and accompaniment)
- @param **array&lt;string, mixed&gt;** `$options` Provider specific options
- @return **FileResponse** Audio file response

**Supported options:**

- AudioPod

### denoise

[](#denoise)

Remove noise from an audio file.

```
public function denoise( Audio $audio, array $options = [] ) : FileResponse
```

- @param **Audio** `$audio` Input audio object
- @param **array&lt;string, mixed&gt;** `$options` Provider specific options
- @return **FileResponse** Audio file response

**Supported options:**

- [AudioPod](https://docs.audiopod.ai/api-reference/noise-reduction)

### describe

[](#describe)

Describe the content of an audio file.

```
public function describe( Audio $audio, ?string $lang = null, array $options = [] ) : TextResponse
```

- @param **Audio** `$audio` Input audio object
- @param **string|null** `$lang` ISO language code the description should be generated in
- @param **array&lt;string, mixed&gt;** `$options` Provider specific options
- @return **TextResponse** Response text

**Supported options:**

- Gemini
- Groq
- [OpenAI](https://platform.openai.com/docs/api-reference/audio/createTranscription)

### revoice

[](#revoice)

Exchange the voice in an audio file.

```
public function revoice( Audio $audio, string $voice, array $options = [] ) : FileResponse;
```

- @param **Audio** `$audio` Input audio object
- @param **string** `$voice` Voice name or identifier
- @param **array&lt;string, mixed&gt;** `$options` Provider specific options
- @return **FileResponse** Audio file response

**Supported options:**

- AudioPod
- [ElevenLabs](https://elevenlabs.io/docs/api-reference/speech-to-speech/convert)
- [Murf](https://murf.ai/api/docs/api-reference/voice-changer/convert)

### speak

[](#speak)

Converts text to speech.

```
public function speak( string $text, string $voice = , array $options = [] ) : FileResponse;
```

- @param **string** `$text` Text to be converted to speech
- @param **string|null** `$voice` Voice identifier for speech synthesis
- @param **array&lt;string, mixed&gt;** `$options` Provider specific options
- @return **FileResponse** Audio file response

**Supported options:**

- [Alibaba](https://www.alibabacloud.com/help/en/model-studio/qwen-tts-api)
- [AudioPod](https://docs.audiopod.ai/api-reference/text-to-speech#generate-speech)
- [Deepgram](https://developers.deepgram.com/reference/text-to-speech/speak-request)
- [ElevenLabs](https://elevenlabs.io/docs/api-reference/text-to-speech/convert)
- Groq
- [Murf](https://murf.ai/api/docs/api-reference/text-to-speech/generate)
- [OpenAI](https://platform.openai.com/docs/api-reference/audio/createSpeech)

### transcribe

[](#transcribe)

Converts speech to text.

```
public function transcribe( Audio $audio, ?string $lang = null, array $options = [] ) : TextResponse
```

- @param **Audio** `$audio` Input audio object
- @param **string|null** `$lang` ISO language code of the audio content
- @param **array&lt;string, mixed&gt;** `$options` Provider specific options
- @return **TextResponse** Transcription text response

**Supported options:**

- [AudioPod](https://docs.audiopod.ai/api-reference/speech-to-text)
- [Deepgram](https://developers.deepgram.com/reference/text-to-speech/speak-request)
- [ElevenLabs](https://elevenlabs.io/docs/api-reference/speech-to-text/convert)
- Groq
- [Mistral](https://docs.mistral.ai/api/endpoint/audio/transcriptions)
- [OpenAI](https://platform.openai.com/docs/api-reference/audio/createTranscription)

Image API
---------

[](#image-api)

Most methods require an image object as input which contains a reference to the image that should be processed. This object can be created by:

```
use \Aimeos\Prisma\Files\Image;

$image = Image::fromUrl( 'https://example.com/image.php', 'image/png' );
$image = Image::fromLocalPath( 'path/to/image.png', 'image/png' );
$image = Image::fromBinary( 'PNG...', 'image/png' );
$image = Image::fromBase64( 'UE5H...', 'image/png' );

// Laravel only:
$image = Image::fromStoragePath( 'path/to/image.png', 'public', 'image/png' );
```

The last parameter of all methods (mime type) is optional. If it's not passed, the file content will be retrieved to determine the mime type if reqested.

**Note:** It's best to use **fromUrl()** if possible because all other formats (binary and base64) can be derived from the URL content but URLs can't be created from binary/base64 data.

### background

[](#background)

Replace image background with a background described by the prompt.

```
public function background( Image $image, string $prompt, array $options = [] ) : FileResponse
```

- @param **Image** `$image` Input image object
- @param **string** `$prompt` Prompt describing the new background
- @param **array&lt;string, mixed&gt;** `$options` Provider specific options
- @return **FileResponse** Response file

**Supported options:**

- Clipdrop
- [Ideogram](https://developer.ideogram.ai/api-reference/api-reference/replace-background-v3#request)
- [VertexAI](https://docs.cloud.google.com/vertex-ai/generative-ai/docs/model-reference/imagen-product-recontext-api#parameters)

**Example:**

```
use Aimeos\Prisma\Prisma;
use \Aimeos\Prisma\Files\Image;

$image = Image::fromUrl( 'https://example.com/image.png' );

$fileResponse = Prisma::image()
    ->using( '', ['api_key' => 'xxx'])
    ->background( $image, 'Golden sunset on a caribbean beach' );

$image = $fileResponse->binary();
```

### describe

[](#describe-1)

Describe the content of an image.

```
public function describe( Image $image, ?string $lang = null, array $options = [] ) : TextResponse
```

- @param **Image** `$image` Input image object
- @param **string|null** `$lang` ISO language code the description should be generated in
- @param **array&lt;string, mixed&gt;** `$options` Provider specific options
- @return **TextResponse** Response text

**Supported options:**

- Gemini
- Groq
- [Ideogram](https://developer.ideogram.ai/api-reference/api-reference/describe#request)
- OpenAI

**Example:**

```
use Aimeos\Prisma\Prisma;
use \Aimeos\Prisma\Files\Image;

$image = Image::fromUrl( 'https://example.com/image.png' );

$textResponse = Prisma::image()
    ->using( '', ['api_key' => 'xxx'])
    ->describe( $image, 'de' );

$text = $textResponse->text();
```

### detext

[](#detext)

Remove all text from the image.

```
public function detext( Image $image, array $options = [] ) : FileResponse
```

- @param **Image** `$image` Input image object
- @param **array&lt;string, mixed&gt;** `$options` Provider specific options
- @return **FileResponse** Response file

**Supported options:**

- Clipdrop

**Example:**

```
use Aimeos\Prisma\Prisma;
use \Aimeos\Prisma\Files\Image;

$image = Image::fromUrl( 'https://example.com/image.png' );

$fileResponse = Prisma::image()
    ->using( '', ['api_key' => 'xxx'])
    ->detext( `$image` );

$image = $fileResponse->binary();
```

### erase

[](#erase)

Erase parts of the image.

```
public function erase( Image $image, Image $mask, array $options = [] ) : FileResponse
```

- @param **Image** `$image` Input image object
- @param **Image** `$mask` Mask image object
- @param **array&lt;string, mixed&gt;** `$options` Provider specific options
- @return **FileResponse** Response file

The mask must be an image with black parts (#000000) to keep and white parts (#FFFFFF) to remove.

**Supported options:**

- [Clipdrop](https://clipdrop.co/apis/docs/cleanup)
- [StabilityAI](https://platform.stability.ai/docs/api-reference#tag/Edit/paths/~1v2beta~1stable-image~1edit~1erase/post)

**Example:**

```
use Aimeos\Prisma\Prisma;
use \Aimeos\Prisma\Files\Image;

$image = Image::fromUrl( 'https://example.com/image.png' );
$mask = Image::fromBinary( 'PNG...' );

$fileResponse = Prisma::image()
    ->using( '', ['api_key' => 'xxx'])
    ->erase( $image, $mask );

$image = $fileResponse->binary();
```

### imagine

[](#imagine)

Generate an image from the prompt.

```
public function imagine( string $prompt, array $images = [], array $options = [] ) : FileResponse
```

- @param **string** `$prompt` Prompt describing the image
- @param **array&lt;int, \\Aimeos\\Prisma\\Files\\Image&gt;** `$images` Associative list of file name/Image instances
- @param **array&lt;string, mixed&gt;** `$options` Provider specific options
- @return **FileResponse** Response file

**Supported options:**

- [Alibaba Qwen/Wan/Z-Image](https://www.alibabacloud.com/help/en/model-studio/qwen-image-api)
- [Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-titan-image.html)
- [Black Forest Labs](https://docs.bfl.ai/api-reference/models/generate-or-edit-an-image-with-flux2-%5Bpro%5D)
- Clipdrop
- [Gemini](https://ai.google.dev/gemini-api/docs/image-generation#optional_configurations)
- [Ideogram](https://developer.ideogram.ai/api-reference/api-reference/generate-v3#request)
- [VertexAI](https://docs.cloud.google.com/vertex-ai/generative-ai/docs/model-reference/imagen-api#generate_images)
- [OpenAI GPT image 1](https://platform.openai.com/docs/guides/image-generation?image-generation-model=gpt-image-1#customize-image-output)
- [OpenAI Dall-e-3](https://platform.openai.com/docs/guides/image-generation?image-generation-model=dall-e-3#customize-image-output)
- [OpenAI Dall-e-2](https://platform.openai.com/docs/guides/image-generation?image-generation-model=dall-e-2#customize-image-output)
- [StabilityAI Core](https://platform.stability.ai/docs/api-reference#tag/Generate/paths/~1v2beta~1stable-image~1generate~1core/post)
- [StabilityAI Ultra](https://platform.stability.ai/docs/api-reference#tag/Generate/paths/~1v2beta~1stable-image~1generate~1ultra/post)
- [StabilityAI Stable Diffusion 3.5](https://platform.stability.ai/docs/api-reference#tag/Generate/paths/~1v2beta~1stable-image~1generate~1sd3/post)

**Example:**

```
use Aimeos\Prisma\Prisma;

$fileResponse = Prisma::image()
    ->using( '', ['api_key' => 'xxx'])
    ->imagine( 'Futuristic robot looking at a dashboard' );

$image = $fileResponse->binary();
```

### inpaint

[](#inpaint)

Edit an image by inpainting an area defined by a mask according to a prompt.

```
public function inpaint( Image $image, Image $mask, string $prompt, array $options = [] ) : FileResponse
```

- @param **Image** `$image` Input image object
- @param **Image** `$mask` Input mask image object
- @param **string** `$prompt` Prompt describing the changes
- @param **array&lt;string, mixed&gt;** `$options` Provider specific options
- @return **FileResponse** Response file

The mask must be an image with black parts (#000000) to keep and white parts (#FFFFFF) to edit.

**Supported options:**

- [Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-titan-image.html)
- [Black Forest Labs](https://docs.bfl.ai/api-reference/models/generate-an-image-with-flux1-fill-%5Bpro%5D-using-an-input-image-and-mask)
- [Ideogram](https://developer.ideogram.ai/api-reference/api-reference/edit-v3#request)
- [VertexAI](https://docs.cloud.google.com/vertex-ai/generative-ai/docs/model-reference/imagen-api-edit#parameters)
- [OpenAI GPT image 1](https://platform.openai.com/docs/guides/image-generation?image-generation-model=gpt-image-1#customize-image-output)
- [OpenAI Dall-e-3](https://platform.openai.com/docs/guides/image-generation?image-generation-model=dall-e-3#customize-image-output)
- [OpenAI Dall-e-2](https://platform.openai.com/docs/guides/image-generation?image-generation-model=dall-e-2#customize-image-output)
- [StabilityAI](https://platform.stability.ai/docs/api-reference#tag/Edit/paths/~1v2beta~1stable-image~1edit~1inpaint/post)

**Example:**

```
use Aimeos\Prisma\Prisma;
use \Aimeos\Prisma\Files\Image;

$image = Image::fromUrl( 'https://example.com/image.png' );
$mask = Image::fromBinary( 'PNG...' );

$fileResponse = Prisma::image()
    ->using( '', ['api_key' => 'xxx'])
    ->inpaint( $image, $mask, 'add a pink flamingo' );

$image = $fileResponse->binary();
```

### isolate

[](#isolate)

Remove the image background.

```
public function isolate( Image $image, array $options = [] ) : FileResponse
```

- @param **Image** `$image` Input image object
- @param **array&lt;string, mixed&gt;** `$options` Provider specific options
- @return **FileResponse** Response file

**Supported options:**

- [Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-titan-image.html)
- [Clipdrop](https://clipdrop.co/apis/docs/remove-background)
- [RemoveBG](https://www.remove.bg/api#api-reference)
- [StabilityAI](https://platform.stability.ai/docs/api-reference#tag/Edit/paths/~1v2beta~1stable-image~1edit~1remove-background/post)

**Example:**

```
use Aimeos\Prisma\Prisma;
use \Aimeos\Prisma\Files\Image;

$image = Image::fromUrl( 'https://example.com/image.png' );

$fileResponse = Prisma::image()
    ->using( '', ['api_key' => 'xxx'])
    ->isolate( `$image` );

$image = $fileResponse->binary();
```

### recognize

[](#recognize)

Recognizes the text in the given image (OCR).

```
public function recognize( Image $image, array $options = [] ) : TextResponse;
```

- @param **Image** `$image` Input image object
- @param **array&lt;string, mixed&gt;** `$options` Provider specific options
- @return **TextResponse** Response text object

**Supported options:**

- [Mistral](https://docs.mistral.ai/api/endpoint/ocr#operation-ocr_v1_ocr_post)

**Example:**

```
use Aimeos\Prisma\Prisma;
use \Aimeos\Prisma\Files\Image;

$image = Image::fromUrl( 'https://example.com/image.png' );

$textTesponse = Prisma::image()
    ->using( '', ['api_key' => 'xxx'])
    ->recognize( `$image` );

$text = $textResponse->text();
```

### relocate

[](#relocate)

Place the foreground object on a new background.

```
public function relocate( Image $image, Image $bgimage, array $options = [] ) : FileResponse
```

- @param **Image** `$image` Input image with foreground object
- @param **Image** `$bgimage` Background image
- @param **array&lt;string, mixed&gt;** `$options` Provider specific options
- @return **FileResponse** Response file

**Supported options:**

- [RemoveBG](https://www.remove.bg/api#api-reference)

**Example:**

```
use Aimeos\Prisma\Prisma;
use \Aimeos\Prisma\Files\Image;

$image = Image::fromUrl( 'https://example.com/image.png' );
$bgimage = Image::fromUrl( 'https://example.com/background.png' );

$fileResponse = Prisma::image()
    ->using( '', ['api_key' => 'xxx'])
    ->relocate( $image, $bgimage );

$image = $fileResponse->binary();
```

### repaint

[](#repaint)

Repaint an image according to the prompt.

```
public function repaint( Image $image, string $prompt, array $options = [] ) : FileResponse
```

- @param **Image** `$image` Input image object
- @param **string** `$prompt` Prompt describing the changes
- @param **array&lt;string, mixed&gt;** `$options` Provider specific options
- @return **FileResponse** Response file

**Supported options:**

- [Gemini](https://ai.google.dev/gemini-api/docs/image-generation#optional_configurations)
- [Ideogram](https://developer.ideogram.ai/api-reference/api-reference/remix-v3#request)

**Example:**

```
use Aimeos\Prisma\Prisma;
use \Aimeos\Prisma\Files\Image;

$image = Image::fromUrl( 'https://example.com/image.png' );

$fileResponse = Prisma::image()
    ->using( '', ['api_key' => 'xxx'])
    ->repaint( $image, 'Use a van Goch style' );

$image = $fileResponse->binary();
```

### uncrop

[](#uncrop)

Extend/outpaint the image.

```
public function uncrop( Image $image,  int $top, int $right, int $bottom, int $left, array $options = [] ) : FileResponse
```

- @param **Image** `$image` Input image object
- @param **int** `$top` Number of pixels to extend to the top
- @param **int** `$right` Number of pixels to extend to the right
- @param **int** `$bottom` Number of pixels to extend to the bottom
- @param **int** `$left` Number of pixels to extend to the left
- @param **array&lt;string, mixed&gt;** `$options` Provider specific options
- @return **FileResponse** Response file

**Supported options:**

- [Black Forest Labs](https://docs.bfl.ai/api-reference/models/expand-an-image-by-adding-pixels-on-any-side)
- Clipdrop
- [StabilityAI](https://platform.stability.ai/docs/api-reference#tag/Edit/paths/~1v2beta~1stable-image~1edit~1outpaint/post)

**Example:**

```
use Aimeos\Prisma\Prisma;
use \Aimeos\Prisma\Files\Image;

$image = Image::fromUrl( 'https://example.com/image.png' );

$fileResponse = Prisma::image()
    ->using( '', ['api_key' => 'xxx'])
    ->uncrop( $image, 100, 200, 0, 50 );

$image = $fileResponse->binary();
```

### upscale

[](#upscale)

Scale up the image.

```
public function upscale( Image $image, int $factor, array $options = [] ) : FileResponse
```

- @param **Image** `$image` Input image object
- @param **int** `$factor` Upscaling factor between 2 and the maximum value supported by the provider
- @param **array&lt;string, mixed&gt;** `$options` Provider specific options
- @return **FileResponse** Response file

**Supported options:**

- Clipdrop
- [Ideogram](https://developer.ideogram.ai/api-reference/api-reference/upscale#request)
- [VertexAI](https://docs.cloud.google.com/vertex-ai/generative-ai/docs/model-reference/imagen-upscale-api#parameters)
- [StabilityAI](https://platform.stability.ai/docs/api-reference#tag/Upscale)

**Example:**

```
use Aimeos\Prisma\Prisma;
use \Aimeos\Prisma\Files\Image;

$image = Image::fromUrl( 'https://example.com/image.png' );

$fileResponse = Prisma::image()
    ->using( '', ['api_key' => 'xxx'])
    ->upscale( $image, 4 );

$image = $fileResponse->binary();
```

### vectorize

[](#vectorize)

Creates embedding vectors of the images' content.

```
public function vectorize( array $images, ?int $size = null, array $options = [] ) : VectorResponse
```

- @param **array&lt;int, \\Aimeos\\Prisma\\Files\\Image&gt;** `$images` List of input image objects
- @param **int|null** `$size` Size of the resulting vector or null for provider default
- @param **array&lt;string, mixed&gt;** `$options` Provider specific options
- @return **VectorResponse** Response vector object

**Supported options:**

- [Alibaba](https://www.alibabacloud.com/help/en/model-studio/multimodal-embedding-api-reference)
- Bedrock
- [Cohere](https://docs.cohere.com/reference/embed#request)
- VertexAI
- [VoyageAI](https://docs.voyageai.com/reference/multimodal-embeddings-api)

**Example:**

```
use Aimeos\Prisma\Prisma;
use \Aimeos\Prisma\Files\Image;

$images = [
    Image::fromUrl( 'https://example.com/image.png' ),
    Image::fromUrl( 'https://example.com/image2.png' ),
];

$vectorResponse = Prisma::image()
    ->using( '', ['api_key' => 'xxx'])
    ->vectorize( $images, 512 );

$vectors = $vectorResponse->vectors();
```

Text API
--------

[](#text-api)

### translate

[](#translate)

Translate one or more texts from one language to another.

```
public function translate( array $texts, string $to, ?string $from = null, ?string $context = null, array $options = [] ) : TextResponse
```

- @param **array&lt;string&gt;** `$texts` Input texts to be translated
- @param **string** `$to` ISO language code to translate the text into
- @param **string|null** `$from` ISO language code of the input text (optional, auto-detected if omitted)
- @param **string|null** `$context` Context for the translation (optional)
- @param **array&lt;string, mixed&gt;** `$options` Provider specific options
- @return **TextResponse** Response text

**Supported options:**

- [DeepL](https://developers.deepl.com/docs/api-reference/translate/openapi-spec-for-text-translation)
- [Google](https://docs.cloud.google.com/translate/docs/reference/rest/v2/translate#authorization)

**Example:**

```
use Aimeos\Prisma\Prisma;

$textResponse = Prisma::text()
    ->using( 'deepl', ['api_key' => 'xxx'])
    ->ensure( 'translate' )
    ->translate( ['Hello', 'World'], 'de', 'en' );

$texts = $textResponse->texts(); // ['Hallo', 'Welt']
```

Video API
---------

[](#video-api)

### describe

[](#describe-2)

Describe the content of a video file.

```
public function describe( Video $video, ?string $lang = null, array $options = [] ) : TextResponse
```

- @param **Video** `$video` Input video object
- @param **string|null** `$lang` ISO language code the description should be generated in
- @param **array&lt;string, mixed&gt;** `$options` Provider specific options
- @return **TextResponse** Response text

**Supported options:**

- Gemini

Custom providers
----------------

[](#custom-providers)

### Base skeleton

[](#base-skeleton)

```
