Skip to main content
Polyglot has a configuration type for each operation family: 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 an LLMConfig:

Presets

Presets are YAML files that live in well-known directories. Polyglot searches these paths in order:
  1. config/llm/presets/ (project root)
  2. packages/polyglot/resources/config/llm/presets/ (monorepo)
  3. vendor/cognesy/instructor-php/packages/polyglot/resources/config/llm/presets/
  4. vendor/cognesy/instructor-polyglot/resources/config/llm/presets/
You may also pass a custom base path:

Overriding Values

Use withOverrides() 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

Presets for embeddings are resolved from similar paths, under the embed config group:
  1. config/embed/presets/
  2. packages/polyglot/resources/config/embed/presets/
  3. vendor/cognesy/instructor-php/packages/polyglot/resources/config/embed/presets/
  4. vendor/cognesy/instructor-polyglot/resources/config/embed/presets/

Overriding Values

Request a provider-specific output width through request options, for example $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:
Adapters compose validation explicitly: 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 the options array — Polyglot will throw an InvalidArgumentException if you attempt this.

InferenceRetryPolicy

The InferenceRetryPolicy provides fine-grained control over retry behavior for inference requests:
The retry delay uses exponential backoff: 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
Length recovery allows automatic continuation when a response is cut short by the provider’s token limit. Two strategies are available: '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, use EmbeddingsRetryPolicy:

DecisionRetryPolicy

Decision defaults to one attempt. DecisionRetryPolicy enables bounded retries for configured statuses and transport failures:
The policy defaults to 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.