{"id":33994490,"url":"https://github.com/projectsaturnstudios/llm-speak-anthropic","last_synced_at":"2025-12-13T07:57:20.090Z","repository":{"id":302467074,"uuid":"1012548090","full_name":"projectsaturnstudios/llm-speak-anthropic","owner":"projectsaturnstudios","description":"A Laravel package for integrating Anthropic Claude into LLMSpeak","archived":false,"fork":false,"pushed_at":"2025-07-29T20:20:04.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-29T22:55:50.891Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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}},"created_at":"2025-07-02T13:54:30.000Z","updated_at":"2025-07-29T20:20:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"107260e9-e982-4b83-abb7-3f3eda5bab18","html_url":"https://github.com/projectsaturnstudios/llm-speak-anthropic","commit_stats":null,"previous_names":["projectsaturnstudios/llm-speak-anthropic"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/projectsaturnstudios/llm-speak-anthropic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectsaturnstudios%2Fllm-speak-anthropic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectsaturnstudios%2Fllm-speak-anthropic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectsaturnstudios%2Fllm-speak-anthropic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectsaturnstudios%2Fllm-speak-anthropic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/projectsaturnstudios","download_url":"https://codeload.github.com/projectsaturnstudios/llm-speak-anthropic/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectsaturnstudios%2Fllm-speak-anthropic/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27702361,"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-13T02:00:09.769Z","response_time":147,"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":[],"created_at":"2025-12-13T07:57:19.510Z","updated_at":"2025-12-13T07:57:20.080Z","avatar_url":"https://github.com/projectsaturnstudios.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LLMSpeak Anthropic Claude\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![PHP](https://img.shields.io/badge/PHP-8.2%2B-blue.svg)](https://php.net/releases/)\n[![Laravel](https://img.shields.io/badge/Laravel-10.x%7C11.x%7C12.x-red.svg)](https://laravel.com)\n[![Total Downloads](https://img.shields.io/packagist/dt/llm-speak/anthropic-claude.svg?style=flat-square)](https://packagist.org/packages/llm-speak/anthropic-claude)\n\n**LLMSpeak Anthropic Claude** is a Laravel package that provides a fluent, Laravel-native interface for integrating with Anthropic's Claude AI models. Built as part of the LLMSpeak ecosystem, it offers seamless integration with Laravel applications through automatic service discovery and expressive request builders.\n\n\u003e **Note:** This package is part of the larger [LLMSpeak ecosystem](https://github.com/projectsaturnstudios/llm-speak). For universal provider switching and standardized interfaces, check out the [LLMSpeak Core](https://github.com/projectsaturnstudios/llm-speak) package.\n\n## Table of Contents\n- [Features](#features)\n- [Get Started](#get-started)\n- [Usage](#usage)\n  - [Basic Request](#basic-request)\n  - [Fluent Request Building](#fluent-request-building)\n  - [System Instructions](#system-instructions)\n  - [Tool Calling](#tool-calling)\n  - [Streaming Responses](#streaming-responses)\n  - [Advanced Configuration](#advanced-configuration)\n  - [Response Handling](#response-handling)\n  - [Testing](#testing)\n- [Changelog](#changelog)\n- [Contributing](#contributing)\n- [Security](#security)\n- [Credits](#credits)\n- [License](#license)\n\n## Features\n\n- **🚀 Laravel Native**: Full Laravel integration with automatic service discovery\n- **🔧 Fluent Interface**: Expressive request builders with method chaining\n- **📊 Laravel Data**: Powered by Spatie Laravel Data for robust data validation\n- **🛠️ Tool Support**: Complete function calling capabilities\n- **💨 Streaming**: Support for real-time streaming responses\n- **🎯 Type Safety**: Full PHP 8.2+ type declarations and IDE support\n- **🔐 Secure**: Built-in API key management and request validation\n\n## Get Started\n\n\u003e **Requires [PHP 8.2+](https://php.net/releases/) and Laravel 10.x/11.x/12.x**\n\nInstall the package via [Composer](https://getcomposer.org/):\n\n```bash\ncomposer require llm-speak/anthropic-claude\n```\n\nThe package will automatically register itself via Laravel's package discovery.\n\n### Environment Configuration\n\nAdd your Anthropic API key to your `.env` file:\n\n```env\nANTHROPIC_API_KEY=your_api_key_here\n```\n\n\u003e **Note:** The package currently uses Anthropic API version `2023-06-01` (hardcoded).\n\n## Usage\n\n### Basic Request\n\nThe simplest way to send a message to Claude:\n\n```php\nuse LLMSpeak\\Anthropic\\ClaudeMessageRequest;\n\n$request = new ClaudeMessageRequest(\n    model: 'claude-3-5-sonnet-20241022',\n    messages: [\n        ['role' =\u003e 'user', 'content' =\u003e 'Hello, Claude!']\n    ]\n);\n\n$response = $request-\u003epost();\n\necho $response-\u003egetTextContent(); // \"Hello! How can I assist you today?\"\n```\n\n### Fluent Request Building\n\nBuild complex requests using the fluent interface:\n\n```php\nuse LLMSpeak\\Anthropic\\ClaudeMessageRequest;\n\n$request = new ClaudeMessageRequest(\n    model: 'claude-3-5-sonnet-20241022',\n    messages: [\n        ['role' =\u003e 'user', 'content' =\u003e 'Explain quantum computing']\n    ]\n)\n-\u003esetMaxTokens(1000)\n-\u003esetTemperature(0.7)\n-\u003esetSystem('You are a helpful physics professor.')\n-\u003esetTopK(50)\n-\u003esetTopP(0.9);\n\n$response = $request-\u003epost();\n\n// Access response properties\necho $response-\u003eid;              // msg_01ABC123...\necho $response-\u003emodel;           // claude-3-5-sonnet-20241022\necho $response-\u003estop_reason;     // end_turn\necho $response-\u003egetTotalTokens(); // 850\n```\n\n### Batch Configuration\n\nSet multiple parameters at once:\n\n```php\n$request = new ClaudeMessageRequest(\n    model: 'claude-3-5-sonnet-20241022',\n    messages: $messages\n)-\u003esetMultiple([\n    'max_tokens' =\u003e 1500,\n    'temperature' =\u003e 0.8,\n    'top_k' =\u003e 40,\n    'stop_sequences' =\u003e ['Human:', 'Assistant:']\n]);\n```\n\n### System Instructions\n\nClaude supports rich system instructions for context and behavior:\n\n```php\n$systemPrompt = \"You are Claude, an AI assistant created by Anthropic. \" .\n                \"You are helpful, harmless, and honest. \" .\n                \"Provide detailed explanations with examples.\";\n\n$request = new ClaudeMessageRequest(\n    model: 'claude-3-5-sonnet-20241022',\n    messages: [\n        ['role' =\u003e 'user', 'content' =\u003e 'Explain machine learning']\n    ]\n)-\u003esetSystem($systemPrompt);\n\n$response = $request-\u003epost();\n```\n\n### Tool Calling\n\nEnable Claude to use external functions and tools:\n\n```php\n$tools = [\n    [\n        'name' =\u003e 'get_weather',\n        'description' =\u003e 'Get current weather for a location',\n        'input_schema' =\u003e [\n            'type' =\u003e 'object',\n            'properties' =\u003e [\n                'location' =\u003e [\n                    'type' =\u003e 'string',\n                    'description' =\u003e 'City and state/country'\n                ],\n                'unit' =\u003e [\n                    'type' =\u003e 'string',\n                    'enum' =\u003e ['celsius', 'fahrenheit'],\n                    'description' =\u003e 'Temperature unit'\n                ]\n            ],\n            'required' =\u003e ['location']\n        ]\n    ]\n];\n\n$request = new ClaudeMessageRequest(\n    model: 'claude-3-5-sonnet-20241022',\n    messages: [\n        ['role' =\u003e 'user', 'content' =\u003e 'What\\'s the weather in San Francisco?']\n    ]\n)\n-\u003esetTools($tools)\n-\u003esetToolChoice('auto');\n\n$response = $request-\u003epost();\n\n// Check if tools were used\nif ($response-\u003eusedTools()) {\n    $toolCalls = $response-\u003egetToolCalls();\n    foreach ($toolCalls as $toolCall) {\n        echo \"Tool: {$toolCall['name']}\\n\";\n        echo \"Input: \" . json_encode($toolCall['input']) . \"\\n\";\n    }\n}\n```\n\n### Streaming Responses\n\nEnable real-time streaming for long responses:\n\n```php\n$request = new ClaudeMessageRequest(\n    model: 'claude-3-5-sonnet-20241022',\n    messages: [\n        ['role' =\u003e 'user', 'content' =\u003e 'Write a long story about space exploration']\n    ]\n)\n-\u003esetStream(true)\n-\u003esetMaxTokens(2000);\n\n$response = $request-\u003epost();\n\n// Stream will be handled by the MessagesEndpoint\n// Check response for streaming data format\n```\n\n### Advanced Configuration\n\nConfigure advanced parameters for fine-tuned control:\n\n```php\n$request = new ClaudeMessageRequest(\n    model: 'claude-3-5-sonnet-20241022',\n    messages: $conversationHistory\n)\n-\u003esetMaxTokens(4000)\n-\u003esetTemperature(0.6)\n-\u003esetTopK(60)\n-\u003esetTopP(0.95)\n-\u003esetStopSequences(['[END]', '###'])\n-\u003esetMetadata([\n    'user_id' =\u003e 'user_123',\n    'session_id' =\u003e 'session_456'\n])\n-\u003esetServiceTier('standard_only');\n\n$response = $request-\u003epost();\n```\n\n## Response Handling\n\nAccess rich response data:\n\n```php\n$response = $request-\u003epost();\n\n// Basic response info\n$messageId = $response-\u003eid;\n$modelUsed = $response-\u003emodel;\n$completionReason = $response-\u003estop_reason;\n\n// Content access\n$textContent = $response-\u003egetTextContent();\n$allContent = $response-\u003econtent; // Raw content array\n\n// Token usage\n$inputTokens = $response-\u003egetInputTokens();\n$outputTokens = $response-\u003egetOutputTokens();\n$totalTokens = $response-\u003egetTotalTokens();\n\n// Completion status\n$isComplete = $response-\u003ecompletedNaturally();\n$hitTokenLimit = $response-\u003ereachedTokenLimit();\n\n// Convert to array for storage/processing\n$responseArray = $response-\u003etoArray();\n```\n\n## Testing\n\nThe package provides testing utilities for mocking Anthropic responses:\n\n```php\nuse LLMSpeak\\Anthropic\\ClaudeMessageRequest;\nuse LLMSpeak\\Anthropic\\ClaudeMessageResponse;\n\n// Create a mock response\n$mockResponse = new ClaudeMessageResponse(\n    id: 'msg_test_123',\n    type: 'message',\n    role: 'assistant',\n    content: [\n        ['type' =\u003e 'text', 'text' =\u003e 'Test response']\n    ],\n    model: 'claude-3-5-sonnet-20241022',\n    stop_reason: 'end_turn',\n    stop_sequence: null,\n    usage: [\n        'input_tokens' =\u003e 10,\n        'output_tokens' =\u003e 15\n    ]\n);\n\n// Test your application logic with the mock\n$this-\u003eassertEquals('Test response', $mockResponse-\u003egetTextContent());\n```\n\n## Credits\n\n- [Project Saturn Studios](https://github.com/projectsaturnstudios)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n---\n\n**Part of the LLMSpeak Ecosystem** - Made with ADHD by [Project Saturn Studios](https://projectsaturnstudios.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprojectsaturnstudios%2Fllm-speak-anthropic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprojectsaturnstudios%2Fllm-speak-anthropic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprojectsaturnstudios%2Fllm-speak-anthropic/lists"}