Facades
The package provides four main facades for interacting with LLMs and code agents.StructuredOutput
The primary facade for extracting structured data from text.Basic Usage
With System Prompt
With Examples (Few-Shot Learning)
Switching Connections
Fluent API
Return Types
Available Methods
| Method | Description |
|---|---|
using(string $preset) | Switch to a different connection |
with(...) | Configure extraction with all parameters |
withMessages(...) | Set input messages |
withResponseModel(...) | Set the response model class |
withSystem(string) | Set system prompt |
withPrompt(string) | Set user prompt template |
withExamples(array) | Set few-shot examples |
withModel(string) | Override the model |
withMaxRetries(int) | Set max retry attempts |
withOptions(array) | Set additional options |
withOutputMode(OutputMode) | Set output mode |
withStreaming(bool) | Enable streaming |
withValidators(...) | Add custom validators |
withTransformers(...) | Add data transformers |
get() | Execute and return result |
stream() | Execute and return stream |
Inference
For raw LLM inference without structured output.Basic Usage
With System Message
JSON Response
Switching Connections
Available Methods
| Method | Description |
|---|---|
using(string $preset) | Switch connection |
with(...) | Configure with all parameters |
withMessages(...) | Set messages |
withModel(string) | Override model |
withTools(array) | Add tool definitions |
withToolChoice(...) | Set tool choice |
withResponseFormat(array) | Set response format |
withOptions(array) | Set options |
withStreaming(bool) | Enable streaming |
get() | Execute and return text |
asJson() | Return as JSON string |
asJsonData() | Return as array |
response() | Return full response object |
stream() | Return stream iterator |
Embeddings
For generating text embeddings (vector representations).Basic Usage
Switching Connections
With Custom Model
Full Response
Available Methods
| Method | Description |
|---|---|
using(string $preset) | Switch connection |
withInputs(string|array) | Set input text(s) |
withModel(string) | Override model |
withOptions(array) | Set options |
first() | Get first embedding vector |
all() | Get all embedding vectors |
get() | Get full response object |
AgentCtrl
For invoking CLI-based code agents (Claude Code, Codex, OpenCode) that can execute code, modify files, and perform complex tasks.Basic Usage
Agent Selection
Configuration
Streaming
Response Object
Session Management
Available Methods
| Method | Description |
|---|---|
claudeCode() | Get Claude Code agent builder |
codex() | Get Codex agent builder |
openCode() | Get OpenCode agent builder |
make(AgentType) | Get agent builder by type |
fake(array $responses) | Create testing fake |
withModel(string) | Set AI model |
withTimeout(int) | Set execution timeout |
inDirectory(string) | Set working directory |
withSandboxDriver(SandboxDriver) | Set sandbox isolation |
withMaxRetries(int) | Set retry count |
onText(callable) | Stream text callback |
onToolUse(callable) | Tool use callback |
onComplete(callable) | Completion callback |
resumeSession(string) | Resume previous session |
execute(string) | Execute and return response |
executeStreaming(string) | Execute with streaming |
Dependency Injection
Instead of facades, you can inject services directly:- Better testability (easier mocking)
- Explicit dependencies
- IDE autocompletion