LlmService
Dual-provider LLM client (OpenAI + Anthropic chat-completions), translating each provider's tool-call wire format to and from a single OpenAI-shaped message array.
LlmService::__construct()
public function __construct(string $apiKey, string $model = 'gpt-4o', string $provider = 'openai', ?Psr\Log\LoggerInterface $logger = null):Parameters
| Name | Type | Description |
|---|---|---|
| $apiKey | string | |
| $model | string | |
| $provider | string | |
| $logger | ?Psr\Log\LoggerInterface |
LlmService::generateResponse()
public function generateResponse(string $prompt, array $tools = [], array $messages = [], int $maxTokens = 4096): arraySend a prompt (or a full message history) to the configured provider and return a single OpenAI-shaped assistant message, translating request and response tool-call formats to and from Anthropic's shape when needed.
Parameters
| Name | Type | Description |
|---|---|---|
| $prompt | string | |
| $tools | list<array<string, mixed>> | Tool summaries in MCP/OpenAI shape (`name`, `description`, `inputSchema`) |
| $messages | list<array<string, mixed>> | Full conversation so far; when empty, a single `user` message is built from `$prompt` |
| $maxTokens | int |
Returns
An OpenAI-shaped assistant message (`role`, `content`, and optionally `tool_calls`)