LLMConfig,
EmbeddingsConfig, and DecisionConfig. All can be loaded from YAML presets,
constructed from arrays, or parsed from DSN strings.
LLMConfig
LLMConfig holds connection, model selection, and request-default settings. Model facts live in
ModelCatalog, not in connection configuration.
Namespace: Cognesy\Polyglot\Inference\Config\LLMConfig
Fields
Creating a Config
There are three ways to create anLLMConfig:
Presets
Presets are YAML files that live in well-known directories. Polyglot searches these paths in order:config/llm/presets/(project root)packages/polyglot/resources/config/llm/presets/(monorepo)vendor/cognesy/instructor-php/packages/polyglot/resources/config/llm/presets/vendor/cognesy/instructor-polyglot/resources/config/llm/presets/
Overriding Values
UsewithOverrides() to create a modified copy of an existing config:
allowLossyFallback is deliberately separate from provider options. It authorizes only a
fallback Polyglot explicitly knows how to describe, such as JSON Schema to JSON Object or a lossy
reasoning effort mapping. It defaults to false, and accepted changes are recorded on the
effective request. Laravel and Symfony connection files use the snake-case field
allow_lossy_fallback; direct PHP construction, arrays, presets, and DSNs use
allowLossyFallback.
Model catalog
Catalog use is optional. Look up limits, modalities, and capabilities by exact driver and wire model only when an application needs those facts. An absent offering returns an explicit unknown profile:discover() resolves application config/llm/models and packaged model directories through
the same locations used for presets. Exact lookup loads one <driver>/<model>.yaml record;
identity path components are percent-encoded. Use overlay(ModelCatalog::fromPaths($directory))
for another whole-record layer. Construction reads no records; repeated lookup reuses the hydrated
profile. Enumeration is explicit, and runtime never performs network discovery. See
Model Catalog for the versioned record format and scope lifetime.
Type Coercion
LLMConfig automatically coerces numeric strings for its integer fields,
including maxTokens. EmbeddingsConfig contains connection and route data;
model limits and dimensions belong to the embeddings model catalog.
EmbeddingsConfig
EmbeddingsConfig holds the settings for connecting to an embeddings provider.
Namespace: Cognesy\Polyglot\Embeddings\Config\EmbeddingsConfig
Fields
Creating a Config
embed config group:
config/embed/presets/packages/polyglot/resources/config/embed/presets/vendor/cognesy/instructor-php/packages/polyglot/resources/config/embed/presets/vendor/cognesy/instructor-polyglot/resources/config/embed/presets/
Overriding Values
$embeddings->withOptions(['dimensions' => 1024]). Inspect provider defaults and
limits through Embeddings\Models\ModelCatalog; they are not connection settings.
DecisionConfig
DecisionConfig holds the connection and model settings for structured
decision providers.
Namespace: Cognesy\Polyglot\Decision\Config\DecisionConfig
Decision presets use the
sdm config group:
assertRoutingIdentity() checks the
driver and effective model, assertHttpTarget() checks the URL and endpoint,
and assertBearerAuthentication() is called only when that deployment requires
a key. DecisionConfig does not branch on provider names.
Use DecisionConfig::fromDefaults() to read config/sdm/default.yaml and
presetNames() to enumerate resolvable presets. See
Decision configuration and runtime for YAML examples,
search paths, redacted inspection, and runtime wiring.
Retry Policies
Retry behavior is configured separately from the provider config, via dedicated policy objects. Retry policies must not be placed inside theoptions array — Polyglot will throw an InvalidArgumentException if you attempt this.
InferenceRetryPolicy
TheInferenceRetryPolicy provides fine-grained control over retry behavior for inference requests:
baseDelayMs * 2^(attempt-1), capped at maxDelayMs. The jitter strategy adds randomness to avoid thundering herd problems:
'none'— exact exponential backoff'full'— random value between 0 and the calculated delay'equal'— half the delay plus a random amount up to half the delay
'continue' appends the partial response and sends a continuation prompt, while 'increase_max_tokens' retries with a higher max_tokens value.
The policy also retries on specific exceptions by default: TimeoutException and NetworkException. Provider-specific errors classified as retriable (rate limits, quota exceeded, transient errors) are also retried automatically.
EmbeddingsRetryPolicy
For embeddings, useEmbeddingsRetryPolicy:
DecisionRetryPolicy
Decision defaults to one attempt.DecisionRetryPolicy enables bounded retries
for configured statuses and transport failures:
408, 429, selected 5xx statuses, 529, timeout,
and network failures. It honors bounded Retry-After by default. See
Decision configuration and runtime for the
single-owner retry rule.