Shims API¶
Provider Shim¶
llm_rosetta.shims.provider_shim.ProviderShim
dataclass
¶
Provider identity card with optional transforms.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Canonical provider identifier (e.g. |
base |
str
|
API standard this provider follows. Must be one of the
converter type strings ( |
default_base_url |
str | None
|
Default upstream base URL. Used by the gateway
when the provider config does not specify |
default_api_key_env |
str | None
|
Default environment variable name for the
API key (e.g. |
logo |
str | None
|
URL to the provider's logo image (SVG preferred). |
model_id_field |
str | None
|
JSON field name to use as model identifier when
fetching the upstream model list. Defaults to |
pre_ir_transforms |
tuple[Transform, ...]
|
Body-level transforms applied BEFORE IR
conversion (normalise provider dialect → standard).
Aliased as |
post_ir_transforms |
tuple[Transform, ...]
|
Body-level transforms applied AFTER IR
conversion (standard → provider dialect).
Aliased as |
reasoning |
ReasoningCapability | None
|
Reasoning capability config for this provider.
When |
model_reasoning |
dict[str, ReasoningCapability] | None
|
Per-model reasoning overrides keyed by
upstream model ID (post-alias). Each entry inherits
from the provider-level |
Accept both new and legacy kwarg names.
Legacy from_transforms maps to pre_ir_transforms;
to_transforms maps to post_ir_transforms.
New names take precedence if both are provided.
Source code in src/llm_rosetta/shims/provider_shim.py
llm_rosetta.shims.provider_shim.register_shim ¶
Register (or replace) a :class:ProviderShim in the global registry.
If a shim with the same name is already registered, it is silently replaced and an INFO-level log is emitted. This allows plugin shims to override built-in defaults without raising errors.
Source code in src/llm_rosetta/shims/provider_shim.py
llm_rosetta.shims.provider_shim.unregister_shim ¶
llm_rosetta.shims.provider_shim.get_shim ¶
llm_rosetta.shims.provider_shim.list_shims ¶
llm_rosetta.shims.provider_shim.resolve_base ¶
Resolve a provider/shim name to its base converter type.
If name is already a known base type (e.g. "openai_chat"),
it is returned unchanged. Otherwise the shim registry is consulted.
If the name is not found in either, it is returned as-is (caller
decides how to handle unknown names).
Source code in src/llm_rosetta/shims/provider_shim.py
Transforms¶
llm_rosetta.shims.transforms.Transform
module-attribute
¶
A pure data transformation: receives a provider body dict and returns a (possibly mutated) body dict.
llm_rosetta.shims.transforms.apply_transforms ¶
Apply transforms sequentially to body, returning the result.
llm_rosetta.shims.transforms.strip_fields ¶
Return a transform that removes keys from the body.
No-op for keys that do not exist (idempotent).
Source code in src/llm_rosetta/shims/transforms.py
llm_rosetta.shims.transforms.rename_field ¶
Return a transform that renames a top-level field.
No-op if old does not exist (idempotent).
Source code in src/llm_rosetta/shims/transforms.py
llm_rosetta.shims.transforms.set_defaults ¶
Return a transform that sets fields only when they are absent.
Idempotent: existing values are never overwritten.