{"id":34639925,"url":"https://github.com/projectsaturnstudios/llm-speak","last_synced_at":"2026-01-20T16:49:52.714Z","repository":{"id":298374151,"uuid":"999790203","full_name":"projectsaturnstudios/llm-speak","owner":"projectsaturnstudios","description":"A Laravel package for connecting to LLM Providers like Gemini, Claude, ChatGPT and OpenRouter","archived":false,"fork":false,"pushed_at":"2025-10-04T17:01:05.000Z","size":103,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-04T17:49:46.170Z","etag":null,"topics":["large-language-models","llms"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/projectsaturnstudios.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-10T19:41:25.000Z","updated_at":"2025-10-04T17:00:58.000Z","dependencies_parsed_at":"2025-07-15T05:05:10.609Z","dependency_job_id":null,"html_url":"https://github.com/projectsaturnstudios/llm-speak","commit_stats":null,"previous_names":["projectsaturnstudios/llm-speak"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/projectsaturnstudios/llm-speak","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectsaturnstudios%2Fllm-speak","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectsaturnstudios%2Fllm-speak/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectsaturnstudios%2Fllm-speak/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectsaturnstudios%2Fllm-speak/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/projectsaturnstudios","download_url":"https://codeload.github.com/projectsaturnstudios/llm-speak/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectsaturnstudios%2Fllm-speak/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28005414,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-24T02:00:07.193Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["large-language-models","llms"],"created_at":"2025-12-24T17:15:47.200Z","updated_at":"2025-12-24T17:15:48.934Z","avatar_url":"https://github.com/projectsaturnstudios.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LLM Speak\n### A Laravel package to interact with LLMs using Eloquent-like syntax.\n\n## Installation\n\n### 1) Install via Composer\n\n```bash\ncomposer require llm-speak/core\n```\n\n### 2) Publish configuration (optional)\n\n```bash\n# Publish all LLM Speak configs and installed provider configs\nphp artisan vendor:publish --tag=\"llms\"\n\n# Publish Tokenization configs and installed provider Tokenization configs\nphp artisan vendor:publish --tag=\"llms.tt\"\n\n# Publish Embeddings configs and installed provider Embeddings configs\nphp artisan vendor:publish --tag=\"llms.ve\"\n\n# Publish OneShot Inferencing configs and installed provider Inferencing configs\nphp artisan vendor:publish --tag=\"llms.mi\"\n```\n\n### 3) Install Drivers\n\nDrivers include:\n  - OpenAI Compatible — Embeddings, Inferencing, Chat Completions\n  - Ollama            — Embeddings, Inferencing, Chat Completions\n  - LMStudio          — Embeddings, Inferencing, Chat Completions\n  - MistralAI         — Embeddings, Inferencing, Chat Completions\n  - Gemini            — Embeddings, Inferencing, Chat Completions\n  - xAI               — Tokenization, Chat Completions\n  - OpenRouter        — Inferencing, Chat Completions\n  - Anthropic         — Chat Completions\n  - OpenAI Responses  — Chat Completions\n  - HuggingFace       — Chat Completions\n\n## Usage\n\n### Create a Neural Model\n1. Create a Neural Model that extends the type of interaction you want (e.g., Tokenization, Embeddings, Inference, Completions).\n2. Available Neural Models: `TokenizationModel`, `EmbeddingsModel`, `InferenceModel`, `CompletionsModel`.\n3. When creating the model, the default provider and model are read from the model's config.\n4. You can override by setting the model's `$connection` and `$model_id` properties.\n\n```php\nuse LLMSpeak\\Core\\NeuralModels\\CompletionsModel;\n\nclass SomeModel extends CompletionsModel\n{\n    // Optional: override the default provider/model from config\n    protected string $connection = 'oaic';\n    protected string $model_id = 'gpt-3.5-turbo-instruct';\n}\n```\n\n```php\nuse LLMSpeak\\Core\\NeuralModels\\InferenceModel;\n\nclass SomeModel extends InferenceModel\n{\n    // Optional: override the default provider/model from config\n    protected string $connection = 'oaic';\n    protected string $model_id = 'gpt-3.5-turbo-instruct';\n}\n```\n\n```php\nuse LLMSpeak\\Core\\NeuralModels\\EmbeddingsModel;\n\nclass SomeModel extends EmbeddingsModel\n{\n    // Optional: override the default provider/model from config\n    protected string $connection = 'oaic';\n    protected string $model_id = 'text-embedding-ada-002';\n}\n```\n\n```php\nuse LLMSpeak\\Core\\NeuralModels\\TokenizationModel;\n\nclass SomeTokenizerModel extends TokenizationModel\n{\n    // Optional: override the default provider/model from config\n    protected string $connection = 'x-ai';\n    protected string $model_id = 'grok-4-0709';\n}\n```\n\n### Chat Completions\n\nConfigure your provider in `config/chat-completions.php`:\n\n```php\n// Sample OpenAICompatible config in config/text-tokenization.php\n'connections' =\u003e [\n    'oaic' =\u003e [\n        'driver' =\u003e 'open-ai-compatible',\n        'url' =\u003e env('OAIC_URL', 'https://api.openai.com'),\n        'model' =\u003e env('OAIC_EMBED_MODEL', 'gpt-5'),\n        'headers' =\u003e [\n            'Content-Type' =\u003e 'application/json',\n            'Accept' =\u003e 'application/json',\n            'Authorization' =\u003e 'Bearer ' . env('OAIC_API_KEY', ''),\n        ],\n    ],\n    'local' =\u003e [\n        'driver' =\u003e 'ollama',\n        'url' =\u003e env('OLLAMA_URL', 'http://localhost:11434/api'),\n        'model' =\u003e env('OLLAMA_EMBED_MODEL', 'llama3:latest'),\n        'headers' =\u003e [\n            'Content-Type' =\u003e 'application/json',\n            'Accept' =\u003e 'application/json',\n        ],\n    ],\n]\n```\n\nUse the Completions model to have a model reply to your input.\n\n#### Instance usage\n```php\nuse App\\NeuralModels\\Embeddings\\OllamaEmbeddingsModel;\n\n// Start tokenization query\n$model = new OneShotModel();\n\n// Build prompts\n$query = $model-\u003ewhere('prompt', 'Why is the sky blue?');\n$query = $model-\u003ewherePrompt('Why is the sky blue?');\n$query = $model-\u003ewhereIn('prompt', ['Why is the sky blue?', 'What is Rayleigh scattering?']);\n$query = $model-\u003ewherePrompt('Why is the sky blue?')-\u003ewherePrompt('What is Rayleigh scattering?');\n\n// Execute\n$modelCollection = $model-\u003eget();        // Collection of models (responses)\n$tokensModel     = $model-\u003efirst();      // Single model (latest response)\n```\n\n#### Fluent usage\n```php\n$modelCollection = (new Chatmodel())\n    -\u003ewhere('message', 'Why is the sky blue?')\n    -\u003eget();\n\n$model = (new Chatmodel())\n    -\u003ewhere('message', 'Why is the sky blue?')\n    -\u003efirst();\n```\n\n#### Manual builder usage\n```php\n$query = (new Chatmodel())-\u003enewQuery();\n$query = $query-\u003ewhere('message', 'Why is the sky blue?');\n$modelCollection = $query-\u003eget();\n```\n\n#### Advanced usage\n\nThese additional parameters can be set on the Completions model like so.\n\n```php\n$model = (new Chatmodel())\n    -\u003ewhere('message', 'Why is the sky blue?')\n    -\u003ewhereTemperature(0.7)  // Set temperature that controls randomness\n    -\u003efirst();\n\n// Max tokens to use in response\n$model-\u003ewhereMaxTokens($max_tokens); \n// Penalize new tokens based on their existing frequency in the text so far\n$model-\u003ewhereFrequencyPenalty($frequency_penalty); \n// Penalize new tokens based on whether they appear in the text so far\n$model-\u003ewherePresencePenalty($presence_penalty);\n// Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.\n$model-\u003ewhereSeed($seed);\n// Number of completions to generate for each prompt\n$model-\u003ewhereN($n);\n// Modify the behavior of the model with system instructions\n$model-\u003ewhereSystemInstructions($instructions); \n// Add tool functions for the model to request.\n$model-\u003ewhereTools($user_id);\n\n```\nNOTE: Not all providers support all these parameters.\n\n### OneShot Inferencing\n\nConfigure your provider in `config/inferencing.php`:\n\n```php\n// Sample OpenAICompatible config in config/text-tokenization.php\n'connections' =\u003e [\n    'oaic' =\u003e [\n        'driver' =\u003e 'open-ai-compatible',\n        'url' =\u003e env('OAIC_URL', 'https://api.openai.com'),\n        'model' =\u003e env('OAIC_EMBED_MODEL', 'gpt-3.5-turbo-instruct'),\n        'headers' =\u003e [\n            'Content-Type' =\u003e 'application/json',\n            'Accept' =\u003e 'application/json',\n            'Authorization' =\u003e 'Bearer ' . env('OAIC_API_KEY', ''),\n        ],\n    ],\n    'local' =\u003e [\n        'driver' =\u003e 'ollama',\n        'url' =\u003e env('OLLAMA_URL', 'http://localhost:11434/api'),\n        'model' =\u003e env('OLLAMA_EMBED_MODEL', 'llama3:latest'),\n        'headers' =\u003e [\n            'Content-Type' =\u003e 'application/json',\n            'Accept' =\u003e 'application/json',\n        ],\n    ],\n]\n```\n\nUse the Inference model to have a model response to your input.\n\n#### Instance usage\n```php\nuse App\\NeuralModels\\Embeddings\\OllamaEmbeddingsModel;\n\n// Start tokenization query\n$model = new OneShotModel();\n\n// Build prompts\n$query = $model-\u003ewhere('prompt', 'Why is the sky blue?');\n$query = $model-\u003ewherePrompt('Why is the sky blue?');\n$query = $model-\u003ewhereIn('prompt', ['Why is the sky blue?', 'What is Rayleigh scattering?']);\n$query = $model-\u003ewherePrompt('Why is the sky blue?')-\u003ewherePrompt('What is Rayleigh scattering?');\n\n// Execute\n$modelCollection = $model-\u003eget();        // Collection of models (responses)\n$tokensModel     = $model-\u003efirst();      // Single model (latest response)\n```\n\n#### Fluent usage\n```php\n$modelCollection = (new OneShotModel())\n    -\u003ewhere('prompt', 'Why is the sky blue?')\n    -\u003eget();\n\n$model = (new OneShotModel())\n    -\u003ewhere('prompt', 'Why is the sky blue?')\n    -\u003efirst();\n```\n\n#### Manual builder usage\n```php\n$query = (new OneShotModel())-\u003enewQuery();\n$query = $query-\u003ewhere('prompt', 'Why is the sky blue?');\n$modelCollection = $query-\u003eget();\n```\n\n#### Advanced usage\n\nThese additional parameters can be set on the Embeddings model like so.\n\n```php\n$model = (new OneShotModel())\n    -\u003ewhere('prompt', 'Why is the sky blue?')\n    -\u003ewhereTemperature(0.7)  // Set temperature that controls randomness\n    -\u003efirst();\n\n// Max tokens to use in response\n$model-\u003ewhereMaxTokens($max_tokens); \n// Penalize new tokens based on their existing frequency in the text so far\n$model-\u003ewhereFrequencyPenalty($frequency_penalty); \n// Penalize new tokens based on whether they appear in the text so far\n$model-\u003ewherePresencePenalty($presence_penalty);\n// Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.\n$model-\u003ewhereSeed($seed);\n// Number of completions to generate for each prompt\n$model-\u003ewhereN($n);\n\n```\nNOTE: Not all providers support all these parameters.\n\n### Vector Embeddings\n\nConfigure your provider in `config/vector-embeddings.php`:\n\n```php\n// Sample OpenAICompatible config in config/text-tokenization.php\n'connections' =\u003e [\n    'oaic' =\u003e [\n        'driver' =\u003e 'open-ai-compatible',\n        'url' =\u003e env('OAIC_URL', 'https://api.openai.com'),\n        'model' =\u003e env('OAIC_EMBED_MODEL', 'text-embedding-ada-002'),\n        'headers' =\u003e [\n            'Content-Type' =\u003e 'application/json',\n            'Accept' =\u003e 'application/json',\n            'Authorization' =\u003e 'Bearer ' . env('OAIC_API_KEY', ''),\n        ],\n    ],\n    'local' =\u003e [\n        'driver' =\u003e 'ollama',\n        'url' =\u003e env('OLLAMA_URL', 'http://localhost:11434/api'),\n        'model' =\u003e env('OLLAMA_EMBED_MODEL', 'llama3:latest'),\n        'headers' =\u003e [\n            'Content-Type' =\u003e 'application/json',\n            'Accept' =\u003e 'application/json',\n        ],\n    ],\n]\n```\n\nUse the Embeddings model to convert text to vectors.\n\n#### Instance usage\n```php\nuse App\\NeuralModels\\Embeddings\\OllamaEmbeddingsModel;\n\n// Start tokenization query\n$model = new OllamaEmbeddingsModel();\n\n// Build prompts\n$query = $model-\u003ewhere('text', 'Why is the sky blue?');\n$query = $model-\u003ewhereInput('Why is the sky blue?');\n$query = $model-\u003ewhereIn('text', ['Why is the sky blue?', 'What is Rayleigh scattering?']);\n$query = $model-\u003ewhereInput('Why is the sky blue?')-\u003ewhereInput('What is Rayleigh scattering?');\n\n// Execute\n$modelCollection = $model-\u003eget();        // Collection of models (responses)\n$tokensModel     = $model-\u003efirst();      // Single model (latest response)\n```\n\n#### Fluent usage\n```php\n$modelCollection = (new OllamaEmbeddingsModel())\n    -\u003ewhere('input', 'Why is the sky blue?')\n    -\u003eget();\n\n$model = (new OllamaEmbeddingsModel())\n    -\u003ewhere('input', 'Why is the sky blue?')\n    -\u003efirst();\n```\n\n#### Manual builder usage\n```php\n$query = (new OllamaEmbeddingsModel())-\u003enewQuery();\n$query = $query-\u003ewhere('input', 'Why is the sky blue?');\n$modelCollection = $query-\u003eget();\n```\n\n#### Advanced usage\n\nThese additional parameters can be set on the Embeddings model like so.\n\n```php\n$model = (new OAICEmbeddingsModel())\n    -\u003ewhere('input', 'Why is the sky blue?')\n    -\u003ewhereDimensions(1536)  // Set dimension if needed\n    -\u003efirst();\n\n$model-\u003ewhereEncodingFormat($encoding_format);\n$model-\u003ewhereUser($user_id);\n$model-\u003ewhereTitle($title);\n$model-\u003ewhereTaskType($task_type);\n```\nNOTE: Not all providers support all these parameters.\n\n### Tokenization\n\nConfigure your provider in `config/text-tokenization.php`:\n\n```php\n// Sample xAI config in config/text-tokenization.php\n'connections' =\u003e [\n    'x-ai' =\u003e [\n        'driver' =\u003e 'x-ai',\n        'url' =\u003e env('XAI_URL', 'https://api.x.ai'),\n        'model' =\u003e env('XAI_TOKEN_MODEL', 'grok-4-0709'),\n        'headers' =\u003e [\n            'Content-Type' =\u003e 'application/json',\n            'Accept' =\u003e 'application/json',\n            'Authorization' =\u003e 'Bearer ' . env('XAI_API_KEY', ''),\n        ],\n    ],\n]\n```\n\nUse the Tokenization model to convert text to tokens.\n\n#### Instance usage\n```php\nuse App\\NeuralModels\\Tokenizations\\GrokTokensModel;\n\n// Start tokenization query\n$model = new GrokTokensModel();\n\n// Build prompts\n$query = $model-\u003ewhere('text', 'Why is the sky blue?');\n$query = $model-\u003ewhereText('Why is the sky blue?');\n$query = $model-\u003ewhereIn('text', ['Why is the sky blue?', 'What is Rayleigh scattering?']);\n$query = $model-\u003ewhereText('Why is the sky blue?')-\u003ewhereText('What is Rayleigh scattering?');\n\n// Execute\n$modelCollection = $model-\u003eget();        // Collection of models (responses)\n$tokensModel     = $model-\u003efirst();      // Single model (latest response)\n```\n\n#### Fluent usage\n```php\n$modelCollection = (new GrokTokensModel())\n    -\u003ewhere('text', 'Why is the sky blue?')\n    -\u003eget();\n\n$model = (new GrokTokensModel())\n    -\u003ewhere('text', 'Why is the sky blue?')\n    -\u003efirst();\n```\n\n#### Manual builder usage\n```php\n$query = (new GrokTokensModel())-\u003enewQuery();\n$query = $query-\u003ewhere('text', 'Why is the sky blue?');\n$modelCollection = $query-\u003eget();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprojectsaturnstudios%2Fllm-speak","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprojectsaturnstudios%2Fllm-speak","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprojectsaturnstudios%2Fllm-speak/lists"}