PHPackages                             1tomany/llm-sdk-bundle - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. 1tomany/llm-sdk-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

1tomany/llm-sdk-bundle
======================

Symfony bundle that provides bindings for the 1tomany/llm-sdk package

v0.7.0(2mo ago)060↓38.1%MITPHPPHP &gt;=8.4

Since Feb 7Pushed 2mo agoCompare

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

READMEChangelog (10)Dependencies (15)Versions (18)Used By (0)

AI and LLM SDK Bundle for Symfony
=================================

[](#ai-and-llm-sdk-bundle-for-symfony)

This package wraps the `1tomany/llm-sdk` library into an easy to use Symfony bundle.

Installation
------------

[](#installation)

Install the bundle using Composer:

```
composer require 1tomany/llm-sdk-bundle

```

Configuration
-------------

[](#configuration)

Below is the complete configuration for this bundle. To customize it for your Symfony application, create a file named `onetomany_llmsdk.yaml` in `config/packages/` and make the necessary changes.

```
onetomany_llmsdk:
    anthropic:
        api_key: "%env(ANTHROPIC_API_KEY)%"
        api_version: "2023-06-01"
        http_client: "http_client"
        serializer: "serializer"
    gemini:
        api_key: "%env(GEMINI_API_KEY)%"
        api_version: "v1beta"
        http_client: "http_client"
        serializer: "serializer"
    openai:
        api_key: "%env(OPENAI_API_KEY)%"
        http_client: "http_client"
        serializer: "serializer"

when@dev:
    onetomany_llmsdk:
        mock:
            enabled: true
```

By default, the `http_client` and `serializer` properties in the `anthropic`, `gemini` and `openai` blocks use the `@http_client` and `@serializer` services defined in a standard Symfony application. You're free to use your own scoped HTTP client or serializer services.

If you wish to disable a vendor, simply delete the configuration block from the file. For example, if your application only uses Gemini, you would delete the `anthropic` and `openai` blocks, leaving you with:

```
onetomany_llmsdk:
    gemini:
        api_key: "%env(GEMINI_API_KEY)%"
```

You'll also have to define the API keys in your `.env` file or by using the [Symfony Secrets](https://symfony.com/doc/current/configuration/secrets.html) component.

Commands
--------

[](#commands)

- `onetomany:llm-sdk:list-models` console command to list all available models by LLM client

Usage
-----

[](#usage)

Any action interface can be injected into a service. Because you can have multiple clients loaded in at once, the model passed into the request dictates what client to use. This makes it very easy to allow your users to select amongst any client supported by the core `1tomany/llm-sdk` library.

```
