Shims API¶
Provider Shim¶
llm_rosetta.shims.provider_shim.ProviderShim
dataclass
¶
ProviderShim(name: str, base: str, default_base_url: str | None = None, default_api_key_env: str | None = None, logo: str | None = None, model_id_field: str | None = None, from_transforms: tuple[Transform, ...] = (), to_transforms: tuple[Transform, ...] = ())
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 |
from_transforms |
tuple[Transform, ...]
|
Transforms applied when data comes FROM this provider (normalise dialect β standard). |
to_transforms |
tuple[Transform, ...]
|
Transforms applied when data goes TO this provider (standard β dialect). |
llm_rosetta.shims.provider_shim.register_shim ¶
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.