1tomany/llm-sdk
Laravel-friendly PHP SDK for working with LLM providers. Provides a clean client API, request/response handling, and configurable drivers so you can send prompts, manage completions, and integrate AI features into your app with minimal boilerplate.
This library provides a single, unified, framework-independent library for integration with several popular AI platforms and large language models.
Install the library using Composer:
composer require 1tomany/llm-sdk
There are two ways to use this library:
OneToMany\LlmSdk\Factory\ClientFactory instance, inject that instance into each action you wish to take, and interact with the action instead of through the client.Note: A Symfony bundle is available if you wish to integrate this library into your Symfony applications with autowiring and configuration support.
Review the examples below to get an idea of how the library works.
examples/embeddings/create.php Creates an embedding vector from a prompt sent to an LLEM (large language embedding model)examples/files/upload.php Uploads a file to an LLM vendorexamples/files/delete.php Deletes a file from an LLM vendorexamples/outputs/generate.php Generates output from a prompt sent to an LLMexamples/search-stores/create.php Creates a search store for RAG outputsexamples/search-stores/read.php Displays information about a search storeexamples/search-stores/search.php Searches a store with a given promptexamples/search-stores/files/import.php Imports an uploaded file to a search storeNote: Each platform refers to generating output (inference) differently; OpenAI uses the word "Responses" while Gemini uses the word "Content". I've decided the word "Output" best represents what a large language model produces in the case of generative models, and "Embedding" in the case of embedding models.
To generate output or create an embedding, you must first compile a "Query". A query is made up of different input components: text prompts, files, a JSON schema, and/or system instructions.
This library allows you to compile a query before sending it to the model for two reasons:
| Feature | Anthropic | Gemini | Mock | OpenAI |
|---|---|---|---|---|
| Batches | ||||
| Create | ❌ | ✅ | ✅ | ✅ |
| Read | ❌ | ✅ | ✅ | ✅ |
| Cancel | ❌ | ❌ | ❌ | ❌ |
| Embeddings | ||||
| Create | ❌ | ✅ | ✅ | ✅ |
| Files | ||||
| Upload | ✅ | ✅ | ✅ | ✅ |
| Read | ❌ | ❌ | ❌ | ❌ |
| List | ❌ | ❌ | ❌ | ❌ |
| Download | ❌ | ❌ | ❌ | ❌ |
| Delete | ✅ | ✅ | ✅ | ✅ |
| Outputs | ||||
| Generate | ❌ | ✅ | ✅ | ✅ |
| Queries | ||||
| Compile | ❌ | ✅ | ✅ | ✅ |
| Search Stores | ||||
| Create | ❌ | ✅ | ❌ | ❌ |
| Read | ❌ | ✅ | ❌ | ❌ |
| Search | ❌ | ✅ | ❌ | ❌ |
| ImportFile | ❌ | ✅ | ❌ | ❌ |
The MIT License
How can I help you explore Laravel packages today?