Pydantic Models

Smarter API Proxy Manifest Constants.

Smarter API Manifest - Proxy.metadata.

class smarter.apps.proxy.manifest.models.proxy.metadata.SAMProxyMetadata(*, name: str, description: str | None, version: str | None, tags: List[str] | None = <factory>, annotations: List[dict[str, str | int | float | bool | ~datetime.date | ~datetime.datetime | ~decimal.Decimal | ~uuid.UUID | bytes | list | dict]] | None=<factory>)[source]

Bases: AbstractSAMMetadataBase

Smarter API Proxy Manifest - Metadata class.

class_identifier: ClassVar[str] = 'Proxy.metadata'
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'from_attributes': True, 'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Return type:

None

Parameters:
  • self – The BaseModel instance.

  • context – The context.

Smarter API Manifest - Proxy.spec.

A Proxy forwards requests, as they are, to an LLM provider’s native API, and adds the provider’s API key, which Smarter keeps in a Secret. Callers authenticate with a Smarter API key instead, and so never see the provider’s.

spec:
  provider: anthropic                 # the name of a Provider
  apiKey: anthropic_api_key           # the name of a Secret. Optional: defaults to the Provider's.
  baseUrl: https://api.anthropic.com/v1/   # Optional: defaults to the Provider's.
  auth:
    header: x-api-key                 # where the provider expects its API key
    scheme: ""                        # its prefix, e.g. Bearer. Empty for none.
  headers:
    anthropic-version: "2023-06-01"   # added to every request
  allowedPaths:                       # glob patterns. Empty allows every path.
    - messages
    - messages/count_tokens
    - models
    - models/*
  timeout: 120                        # seconds
  isActive: true

A request to /api/v1/proxy/<name>/messages is forwarded to https://api.anthropic.com/v1/messages.

class smarter.apps.proxy.manifest.models.proxy.spec.SAMProxySpec(*, provider: str, apiKey: str | None = None, baseUrl: str | None = None, auth: SAMProxySpecAuth = <factory>, headers: dict[str, str]=<factory>, allowedPaths: list[str] = <factory>, timeout: Annotated[int, ~annotated_types.Ge(ge=1), ~annotated_types.Le(le=600)] = 120, isActive: bool = True)[source]

Bases: ProxyBaseModel

Smarter API Proxy Manifest Proxy.spec.

allowedPaths: list[str]
apiKey: str | None
auth: SAMProxySpecAuth
baseUrl: str | None
class_identifier: ClassVar[str] = 'Proxy.spec'
headers: dict[str, str]
isActive: bool
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'from_attributes': True, 'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Return type:

None

Parameters:
  • self – The BaseModel instance.

  • context – The context.

provider: str
timeout: int
classmethod validate_allowed_paths(v)[source]
Return type:

list[str]

classmethod validate_api_key(v)[source]
Return type:

Optional[str]

classmethod validate_base_url(v)[source]
Return type:

Optional[str]

classmethod validate_headers(v)[source]
Return type:

dict[str, str]

classmethod validate_provider(v)[source]
Return type:

str

class smarter.apps.proxy.manifest.models.proxy.spec.SAMProxySpecAuth(*, header: str = 'Authorization', scheme: str | None = 'Bearer')[source]

Bases: ProxyBaseModel

Spec.auth: how the provider expects its API key.

class_identifier: ClassVar[str] = 'Proxy.spec.auth'
header: str
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'from_attributes': True, 'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Return type:

None

Parameters:
  • self – The BaseModel instance.

  • context – The context.

scheme: str | None
classmethod validate_header(v)[source]
Return type:

str

classmethod validate_scheme(v)[source]
Return type:

str

Smarter API Manifest - Proxy.status.

class smarter.apps.proxy.manifest.models.proxy.status.SAMProxyStatus(*, recordLocator: str, created: datetime, modified: datetime, accountNumber: str, username: str, url: str | None = None, upstreamUrl: str | None = None, apiKeySecret: str | None = None)[source]

Bases: AbstractSAMStatusBase

Smarter API Proxy Manifest - Status class.

Read only. Besides ownership, it reports where the Proxy is, and where it forwards to.

accountNumber: str
apiKeySecret: str | None
class_identifier: ClassVar[str] = 'Proxy.status'
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'from_attributes': True, 'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Return type:

None

Parameters:
  • self – The BaseModel instance.

  • context – The context.

upstreamUrl: str | None
url: str | None
username: str

Smarter API Proxy Manifest.

class smarter.apps.proxy.manifest.models.proxy.model.SAMProxy(*, apiVersion: str, kind: str, metadata: SAMProxyMetadata, spec: SAMProxySpec, status: SAMProxyStatus | None = None)[source]

Bases: AbstractSAMBase

Smarter API Manifest - Proxy.

class_identifier: ClassVar[str] = 'Proxy'
metadata: SAMProxyMetadata
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'from_attributes': True, 'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Return type:

None

Parameters:
  • self – The BaseModel instance.

  • context – The context.

spec: SAMProxySpec
status: SAMProxyStatus | None