oc_chat
Loading...
Searching...
No Matches
providers.openai_compat.provider Namespace Reference

Classes

class  OpenAICompatProvider

Functions

list["OpenAICompatProvider"] register_all (Sequence[Lane] lanes=LANES)
tuple[Lane,...] registered_lanes ()

Variables

list _REGISTERED = []

Detailed Description

OpenAICompatProvider — one class, one configured instance per lane.

Purpose
-------
Concrete :class:`ProviderPlugin` for any OpenAI-compatible lane. Unlike
the single-provider bundles, this class is NOT configured by class
attributes: each instance is built from a :class:`Lane` catalogue row, so
seven rows produce seven independently-named providers backed by one
implementation (plan 215 P1). The registry keys on ``name`` and only
rejects a DIFFERENT class re-using an existing name, so registering one
class under seven names is exactly what its contract allows.

Responsibilities
----------------
- :class:`OpenAICompatProvider` — implement the abstract surface from a
  lane row.
- :meth:`OpenAICompatProvider.register_lane` — build and register one
  instance for a row.
- :func:`register_all` — validate the catalogue, then register every row.
- :func:`registered_lanes` — the lane rows this bundle registered, in
  catalogue declaration order.

Diagnostics
-----------
Domain: OC_CHAT.CLIENT
Levels:
    L2 — lifecycle events
    L3 — semantic details
    L4 — deep tracing

Contracts
---------
- Identity (``name`` / ``api_key_env_var`` / ``base_url_env_var`` /
  ``default_base_url`` / ``default_model``) is set per INSTANCE from the
  row, shadowing the ABC's class-level defaults. Two instances never
  share mutable state.
- :meth:`build_extra_body` returns ``None`` always: no catalogue lane is
  configured for reasoning (the OCON as-shipped condition), so there is
  no provider-specific payload to add. A lane that later needs one adds
  it here keyed on its own name — never a blanket default.
- :meth:`transform_outgoing_messages` is a true pass-through: no lane has
  a prefix-cache trick to serve.
- :meth:`parse_usage` delegates to :func:`normalise_usage`, which is
  total over malformed input.
- :func:`register_all` is idempotent and validates FIRST: an invalid row
  raises :exc:`CatalogueError` before ANY lane is registered, so a
  half-registered bundle is unreachable (plan 215 P5).
- Nothing here reads an API key. The harness resolves the key from the
  env-var NAME this provider advertises.

Dependencies
------------
- oc_diagnostics (structured debug logging via _dbg)
- option_c_agent_contracts (ProviderPlugin ABC, ModelCaps, UsageStats, registry)
- option_c_agent_contracts.provider_plugin (OAuthCapability return type of the oauth property)
- providers.openai_compat.catalogue (LANES, Lane rows and validate_catalogue for register_all)
- providers.openai_compat.client (OpenAICompatClient returned by build_client)
- providers.openai_compat.usage (normalise_usage behind parse_usage)
- providers.openai_compat.oauth (lazy; OpenRouterOAuth for the openrouter lane's oauth property)

Function Documentation

◆ register_all()

list["OpenAICompatProvider"] providers.openai_compat.provider.register_all ( Sequence[Lane] lanes = LANES)
Validate *lanes*, then register one provider per row.

Validation runs to completion BEFORE the first registration, so an
invalid row aborts loudly with its name and leaves the registry
untouched (plan 215 P5/W1).

Definition at line 202 of file provider.py.

◆ registered_lanes()

tuple[Lane, ...] providers.openai_compat.provider.registered_lanes ( )
The lane rows this bundle registered, in catalogue declaration order.

Definition at line 220 of file provider.py.

Variable Documentation

◆ _REGISTERED

list providers.openai_compat.provider._REGISTERED = []
protected

Definition at line 89 of file provider.py.