Documentation Index
Fetch the complete documentation index at: https://mintlify.com/phpaisdk/core/llms.txt
Use this file to discover all available pages before exploring further.
Generate is the top-level static facade that ties the entire SDK together. Every text or image request begins here — it holds the configured runtime (Sdk), an optional default model, and exposes factory methods that return fluent builder objects you chain to shape each request before executing it.
Starting a text request
Generate::text() returns a PendingTextRequest. You can optionally pass a prompt string directly as a shortcut, or call ->prompt() on the returned builder.
PendingTextRequest accepts every generation parameter through a fluent interface before you call ->run() (blocking) or ->stream() (streaming generator).
Starting an image request
Generate::image() returns a PendingImageRequest. Like its text counterpart you can pass the prompt inline or set it via ->prompt().
PendingImageRequest does not share the HasMessages / ConfiguresGeneration traits used by text requests. Its builder surface covers prompt(), count(), size(), aspectRatio(), seed(), and providerOptions().Setting a default model
The “default model” pattern lets you register a model once at application boot and omit it from every individual call. CallGenerate::model() with any object that implements Model:
PendingTextRequest and PendingImageRequest each check whether the stored model implements their required interface (TextModelInterface or ImageModelInterface). If it does not, the builder starts with null and the ModelResolver will throw at call time unless you supply a model explicitly.
You can still override the default on a per-call basis:
Configuring the SDK runtime
For applications that already have a PSR-18 HTTP client and PSR-17 factories wired through a DI container, hand the fully-builtSdk object to Generate::configure(). This replaces the auto-discovered runtime with your own.
Sdk is immutable. Generate::configure() stores the instance, and every subsequent call to Generate::sdk() returns it. You can retrieve the current runtime at any time:
Resetting state (tests)
Generate::reset() clears both the stored Sdk and the runtime factory, returning the facade to its initial state. Call it in a tearDown or afterEach hook to prevent state leaking between tests.
Static method reference
| Method | Signature | Description |
|---|---|---|
text | text(?string $prompt = null): PendingTextRequest | Begin a text generation request. |
image | image(?string $prompt = null): PendingImageRequest | Begin an image generation request. |
model | model(Model $model): void | Set the application-wide default model. |
configure | configure(Sdk $sdk): void | Replace the runtime with a pre-built Sdk instance. |
sdk | sdk(): Sdk | Return the current (or auto-built) runtime. |
reset | reset(): void | Clear all stored state (intended for tests). |