Skip to main content

Polyglot Package Cheatsheet

Code-verified API reference for packages/polyglot.

Core Facades

Native Batch Jobs (Early Access)

Persist $saved, reconstruct it with BatchReference::fromArray() in a later process, then call retrieve(), results(), cancel(), or listJobs() explicitly. See docs/batch-inference/overview.md for the asynchronous lifecycle and provider capabilities.

Inference Quick Start

Use a preset for the normal path:
Get parsed JSON:

Inference Constructors

Inference Request Builder Methods

Single-call variant:
With explicit request:

Inference Execution Surfaces

Reasoning, Model Facts, and Pricing

Reasoning is projected from the ordered assistant message:
Read model facts using one exact (driver, wire model) key. An absent key returns unknown facts; the catalog does not infer from the model name:
The catalog is not used by ordinary inference unless it is passed explicitly to InferenceRuntime. Reuse one discovered catalog at the application composition root when local capability policy or metadata is needed. Known semantic fallback is off by default; direct PHP config uses allowLossyFallback: true, while Laravel and Symfony connection config uses allow_lossy_fallback: true. Every accepted adjustment is observable on the effective request and InferenceRequested event. Pricing is caller-owned and is not stored in model catalog records:

Streaming (InferenceStream)

Inference Runtime / Provider Setup

Driver registry helpers:

Embeddings Quick Start

Embeddings Constructors and Builder Methods

Single-call variant:
With explicit request:
Execution shortcuts:

Embeddings Runtime / Provider Setup

Decision Quick Start

Decision Runtime and Pending Result

Decision defaults to one attempt and has no streaming API. Lifecycle telemetry uses sdm.decision and sdm.decision.attempt. See docs/decision/overview.md for serialization, structured content, dynamic options, retry ownership, and live testing. Bundled Decision presets are explicit: Provider compatibility does not imply equal quality or calibration. Run the fixed example corpus with php examples/B06_Decisions/ProviderEvaluation/evaluate.php <preset>, then replace it with independently labeled application cases.

Testing

Deterministic test seams:
  • Tests\Support\FakeInferenceDriver
    • queue sync InferenceResponse fixtures or streaming PartialInferenceDelta batches
    • best for most inference runtime tests that do not need HTTP or adapter coverage
  • Tests\Support\FakeEmbeddingsDriver
    • queue EmbeddingsResponse fixtures and record handled requests
    • best for most embeddings runtime and memoization tests
  • MockHttpDriver
    • use when transport and provider adapter behavior still matter
    • best for golden tests, request assertions, and provider-specific error-path coverage
  • POLYGLOT_TYPESAFE_LIVE=1
    • opts into the bounded TypeSafe integration smoke
  • POLYGLOT_CLASSIFIER_DEV_LIVE=1, POLYGLOT_CLEF_LIVE=1, POLYGLOT_FASTINO_LIVE=1, POLYGLOT_JEFF_LIVE=1, POLYGLOT_LAYA_LIVE=1, and POLYGLOT_PERPLEXITY_LIVE=1
    • opt into the corresponding bounded provider smoke
  • ordinary test runs remain offline and do not require credentials, Python, model weights, or special hardware