API Contract

The Smarter api contract: the JSON Schemas of the SAM manifests, and the OpenAPI document of the Smarter api.

Both are generated from the platform’s Pydantic models by manage.py export_api_contract, and committed beside this package: sam/<Kind>.schema.json and openapi.json. Tests fail when a committed file is out of date. They are the source from which the smarter cli and the SDKs generate their clients, so a change to a SAM model is a change to the api.

See The Api Contract.

Constants of the Smarter api contract: the SAM JSON Schemas, and the OpenAPI document of the Smarter api.

smarter.apps.api.v1.contract.const.API_VERSION = 'v1'

the version of the api, not of the platform.

The platform’s version changes with every release, which would make the committed document stale.

Type:

The document’s info.version

smarter.apps.api.v1.contract.const.DEFAULT_PLATFORM_URL = 'https://platform.smarter.sh'

The default of the document’s platform server variable.

Each Smarter installation has its own. The document is committed, and the SDKs copy it, so this example is fixed, not the running platform’s own url.

smarter.apps.api.v1.contract.const.JSON_SCHEMA_DIALECT = 'https://json-schema.org/draft/2020-12/schema'

The dialect of the document’s schemas, and of the SAM JSON Schemas.

smarter.apps.api.v1.contract.const.LOCAL_PLATFORM_URL = 'http://localhost:9357'

The platform of a local development environment.

smarter.apps.api.v1.contract.const.OPENAPI_PATH = '/home/runner/work/smarter/smarter/smarter/smarter/apps/api/v1/contract/openapi.json'

The OpenAPI document of the Smarter api, generated from smarter.apps.api.v1.contract.openapi.

smarter.apps.api.v1.contract.const.OPENAPI_VERSION = '3.1.0'

The version of the OpenAPI Specification that the document follows.

3.1 schemas are JSON Schema 2020-12.

smarter.apps.api.v1.contract.const.PROJECT_DOCS_URL = 'https://docs.smarter.sh'

The Smarter Project’s documentation, which the document’s description names.

Fixed, as DEFAULT_PLATFORM_URL is, so that the committed document is the same on every platform.

smarter.apps.api.v1.contract.const.PROJECT_WEBSITE_URL = 'https://smarter.sh'

The Smarter Project’s website, the document’s info.contact url.

Fixed, as PROJECT_DOCS_URL is.

smarter.apps.api.v1.contract.const.SAM_EXAMPLE_HOST = 'localhost'

The host of the in-process request that renders an example manifest.

Every environment allows it.

smarter.apps.api.v1.contract.const.SAM_EXAMPLE_SUFFIX = '.example.json'

The suffix of a SAM example manifest’s file name, after its kind.

smarter.apps.api.v1.contract.const.SAM_SCHEMA_DIR = '/home/runner/work/smarter/smarter/smarter/smarter/apps/api/v1/contract/sam'

The folder of the SAM JSON Schemas, one <Kind>.schema.json per kind.

smarter.apps.api.v1.contract.const.SAM_SCHEMA_SUFFIX = '.schema.json'

The suffix of a SAM JSON Schema’s file name, after its kind.

The JSON Schemas of the SAM manifests, one per kind, generated from their Pydantic models, and an example manifest of each kind.

manage.py export_api_contract writes them to sam/<Kind>.schema.json and sam/<Kind>.example.json, beside this module, and a test fails if a committed file is out of date.

  • A schema is exactly the data of the cli’s json-schema/<Kind>/ response, so a client may read either. The SDKs generate their manifest models from them, and smarter.apps.api.v1.contract.openapi includes them in the OpenAPI document.

  • An example is the data of the cli’s example-manifest/<Kind>/ response, without its read-only status, whose timestamps change on every request. The SDKs test their generated models against them, and a test checks that each example is valid under its kind’s schema.

smarter.apps.api.v1.contract.sam.sam_example(kind)[source]

A SAM kind’s example manifest, without its read-only status.

It is rendered in-process by the cli’s public example-manifest view, so that it is exactly what the api returns, because the brokers build their examples for a request.

Parameters:

kind (str) – The kind, e.g. Guardrail.

Returns:

The manifest.

Return type:

dict[str, Any]

Raises:
  • KeyError – If kind is not a SAM kind.

  • ValueError – If the view does not return an example.

smarter.apps.api.v1.contract.sam.sam_example_json(kind)[source]

A SAM kind’s example manifest, as the text of sam/<Kind>.example.json.

Parameters:

kind (str) – The kind, e.g. Guardrail.

Returns:

The manifest, as indented JSON, with a final newline.

Return type:

str

smarter.apps.api.v1.contract.sam.sam_example_path(kind, directory='/home/runner/work/smarter/smarter/smarter/smarter/apps/api/v1/contract/sam')[source]

The file of a SAM kind’s example manifest.

Parameters:
  • kind (str) – The kind, e.g. Guardrail.

  • directory (str) – The folder of the examples.

Returns:

e.g. .../sam/Guardrail.example.json.

Return type:

str

smarter.apps.api.v1.contract.sam.sam_models()[source]

The Pydantic model of each SAM kind: the model that its broker validates manifests with.

The brokers are imported here, rather than at the module’s top, because they import most of the platform’s apps.

Returns:

The models, by kind, e.g. {"Guardrail": SAMGuardrail, ...}, sorted by kind.

Return type:

dict[str, type[BaseModel]]

smarter.apps.api.v1.contract.sam.sam_schema(kind)[source]

A SAM kind’s JSON Schema (draft 2020-12): the schema that the cli’s json-schema command returns.

Parameters:

kind (str) – The kind, e.g. Guardrail.

Returns:

The schema.

Return type:

dict[str, Any]

Raises:

KeyError – If kind is not a SAM kind.

smarter.apps.api.v1.contract.sam.sam_schema_json(kind)[source]

A SAM kind’s JSON Schema, as the text of sam/<Kind>.schema.json.

Parameters:

kind (str) – The kind, e.g. Guardrail.

Returns:

The schema, as indented JSON, with a final newline.

Return type:

str

smarter.apps.api.v1.contract.sam.sam_schema_path(kind, directory='/home/runner/work/smarter/smarter/smarter/smarter/apps/api/v1/contract/sam')[source]

The file of a SAM kind’s JSON Schema.

Parameters:
  • kind (str) – The kind, e.g. Guardrail.

  • directory (str) – The folder of the schemas.

Returns:

e.g. .../sam/Guardrail.schema.json.

Return type:

str

smarter.apps.api.v1.contract.sam.write_sam_schemas(directory='/home/runner/work/smarter/smarter/smarter/smarter/apps/api/v1/contract/sam')[source]

Write every SAM kind’s JSON Schema and example manifest, and remove the files of kinds that no longer exist.

Parameters:

directory (str) – The folder to write. Defaults to sam/, beside this module.

Returns:

The paths that were written, sorted by kind, each kind’s schema before its example.

Return type:

list[str]

Pydantic models of the Smarter cli api contract, and of the OpenAPI document that publishes it.

The cli api (/api/v1/cli/) is the api of the smarter cli and of the SDKs: it applies, gets, describes and deletes the resources that SAM manifests declare. Its requests and responses are described by:

smarter.apps.api.v1.contract.openapi assembles them into an OpenAPI document, which is modeled here too (OpenApi...), so that it is built from models rather than from nested dicts. A schema inside the document is JSON Schema, which is arbitrary JSON, so it is a JsonValue.

The response models allow extra fields: adding a field is backward compatible. Removing or renaming one that is declared here is not.

smarter.apps.api.v1.contract.models.CLI_API_MODELS: tuple[type[BaseModel], ...] = (<class 'smarter.apps.api.v1.contract.models.CliApiApplied'>, <class 'smarter.apps.api.v1.contract.models.CliApiValidation'>, <class 'smarter.apps.api.v1.contract.models.CliApiGet'>, <class 'smarter.apps.api.v1.contract.models.CliApiResource'>, <class 'smarter.apps.api.v1.contract.models.CliApiStatus'>, <class 'smarter.apps.api.v1.contract.models.CliApiVersion'>, <class 'smarter.apps.api.v1.contract.models.CliApiWhoami'>, <class 'smarter.apps.api.v1.contract.models.CliApiPromptBody'>, <class 'smarter.apps.api.v1.contract.models.CliApiPrompt'>, <class 'smarter.apps.api.v1.contract.models.CliApiDocuments'>, <class 'smarter.apps.api.v1.contract.models.RestApiErrorResponse'>)

The models of the cli api’s response data whose JSON Schema the OpenAPI document includes.

Their dependencies are included with them.

(
    <class 'smarter.apps.api.v1.contract.models.CliApiApplied'>,
    <class 'smarter.apps.api.v1.contract.models.CliApiValidation'>,
    <class 'smarter.apps.api.v1.contract.models.CliApiGet'>,
    <class 'smarter.apps.api.v1.contract.models.CliApiResource'>,
    <class 'smarter.apps.api.v1.contract.models.CliApiStatus'>,
    <class 'smarter.apps.api.v1.contract.models.CliApiVersion'>,
    <class 'smarter.apps.api.v1.contract.models.CliApiWhoami'>,
    <class 'smarter.apps.api.v1.contract.models.CliApiPromptBody'>,
    <class 'smarter.apps.api.v1.contract.models.CliApiPrompt'>,
    <class 'smarter.apps.api.v1.contract.models.CliApiDocuments'>,
    <class 'smarter.apps.api.v1.contract.models.RestApiErrorResponse'>,
)
class smarter.apps.api.v1.contract.models.CliApiApplied(*, apiVersion, kind, name, **extra_data)[source]

Bases: CliApiModel

The data of an apply response: the resource that the manifest created or updated.

apiVersion: str
kind: str
model_config = {'extra': 'allow'}

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

name: str
class smarter.apps.api.v1.contract.models.CliApiDocuments(*, vectorstore, documents, added=<factory>, duplicates=<factory>, queued=None, removed=None, **extra_data)[source]

Bases: CliApiModel

The data of a documents response: a Vectorstore’s documents after the command, and what it changed.

Without files, text or a url, the command lists the documents. With them, it adds them, and with remove, it removes one. Each document is the REST api’s VectorstoreApiDocument.

added: list[VectorstoreApiDocument]
documents: list[VectorstoreApiDocument]
duplicates: list[VectorstoreApiDocument]
model_config = {'extra': 'allow'}

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

queued: bool | None
removed: VectorstoreApiDocument | None
vectorstore: str
class smarter.apps.api.v1.contract.models.CliApiGet(*, apiVersion, kind, name=None, metadata, kwargs, data, **extra_data)[source]

Bases: CliApiModel

The data of a get response: the resources of a kind that match the request’s criteria.

apiVersion: str
data: CliApiGetItems
kind: str
kwargs: dict[str, JsonValue]
metadata: CliApiGetMetadata
model_config = {'extra': 'allow'}

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

name: str | None
class smarter.apps.api.v1.contract.models.CliApiGetItems(*, titles, items, **extra_data)[source]

Bases: CliApiModel

The table of a get response: its columns, and one row per resource.

items: list[dict[str, JsonValue]]
model_config = {'extra': 'allow'}

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

titles: list[CliApiGetTitle]
class smarter.apps.api.v1.contract.models.CliApiGetMetadata(*, count, **extra_data)[source]

Bases: CliApiModel

The metadata of a get response’s data.

count: int
model_config = {'extra': 'allow'}

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

class smarter.apps.api.v1.contract.models.CliApiGetTitle(*, name, type, **extra_data)[source]

Bases: CliApiModel

A column of a get response’s table: an item’s field, and its serializer field’s type.

model_config = {'extra': 'allow'}

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

name: str
type: str
class smarter.apps.api.v1.contract.models.CliApiModel(**extra_data)[source]

Bases: BaseModel

Base class of the models of the cli api’s response data, which allow extra fields.

model_config = {'extra': 'allow'}

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

class smarter.apps.api.v1.contract.models.CliApiPrompt(*, request, response, **extra_data)[source]

Bases: CliApiModel

The data of a prompt response: the request that the cli api sent to the LLMClient, and its response.

model_config = {'extra': 'allow'}

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

request: CliApiPromptRequest
response: CliApiPromptChatResponse
class smarter.apps.api.v1.contract.models.CliApiPromptBody(*, prompt, session_key=None, messages=None, **extra_data)[source]

Bases: CliApiModel

The request body of a prompt.

messages: list[PromptChatApiMessage] | None
model_config = {'extra': 'allow'}

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

prompt: str
session_key: str | None
class smarter.apps.api.v1.contract.models.CliApiPromptChatResponse(*, api, metadata, data, **extra_data)[source]

Bases: CliApiModel

The LLMClient’s journaled response to a prompt.

api: str
data: CliApiPromptLambdaResponse
metadata: PromptChatApiJournalMetadata
model_config = {'extra': 'allow'}

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

class smarter.apps.api.v1.contract.models.CliApiPromptLambdaResponse(*, isBase64Encoded=False, statusCode, headers=<factory>, body, **extra_data)[source]

Bases: CliApiModel

The LLMClient’s response to a prompt: the version 1 prompt response, with its body decoded from a JSON string.

body: PromptChatApiCompletionV1
headers: dict[str, str]
isBase64Encoded: bool
model_config = {'extra': 'allow'}

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

statusCode: int
class smarter.apps.api.v1.contract.models.CliApiPromptRequest(*, session_key, messages, **extra_data)[source]

Bases: CliApiModel

The request that a prompt sent to the LLMClient.

messages: list[PromptChatApiMessage]
model_config = {'extra': 'allow'}

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

session_key: str
class smarter.apps.api.v1.contract.models.CliApiResource(*, Singular, Plural, APIKind, Display, DisplayPlural, Deployable, **extra_data)[source]

Bases: CliApiModel

A kind of resource that the cli api manages: an item of the resources response’s data.

APIKind: str
Deployable: bool
Display: str
DisplayPlural: str
Plural: str
Singular: str
model_config = {'extra': 'allow'}

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

class smarter.apps.api.v1.contract.models.CliApiStatus(*, infrastructures, compute, **extra_data)[source]

Bases: CliApiModel

The data of a status response: the platform’s infrastructure and compute.

compute: CliApiStatusCompute
infrastructures: CliApiStatusInfrastructures
model_config = {'extra': 'allow'}

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

class smarter.apps.api.v1.contract.models.CliApiStatusCompute(*, machine, release, platform, processor, system, version, **extra_data)[source]

Bases: CliApiModel

The platform’s compute, from Python’s platform module.

machine: str
model_config = {'extra': 'allow'}

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

platform: str
processor: str
release: str
system: str
version: str
class smarter.apps.api.v1.contract.models.CliApiStatusInfrastructures(*, kubernetes, redis, **extra_data)[source]

Bases: CliApiModel

The infrastructure of a status response.

kubernetes: dict[str, JsonValue]
model_config = {'extra': 'allow'}

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

redis: CliApiStatusRedis
class smarter.apps.api.v1.contract.models.CliApiStatusRedis(*, gcc_version=None, os=None, redis_build_id=None, redis_version=None, **extra_data)[source]

Bases: CliApiModel

The Redis server of a status response, from Redis’s INFO command.

gcc_version: str | None
model_config = {'extra': 'allow'}

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

os: str | None
redis_build_id: str | None
redis_version: str | None
class smarter.apps.api.v1.contract.models.CliApiValidation(*, valid, errors, **extra_data)[source]

Bases: CliApiModel

The data of a validate response.

errors: list[CliApiValidationError]
model_config = {'extra': 'allow'}

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

valid: bool
class smarter.apps.api.v1.contract.models.CliApiValidationError(*, loc, message, type, **extra_data)[source]

Bases: CliApiModel

An error of a manifest that validate reports.

loc: list[str | int]
message: str
model_config = {'extra': 'allow'}

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

type: str
class smarter.apps.api.v1.contract.models.CliApiVersion(*, api, cli, **extra_data)[source]

Bases: CliApiModel

The data of a version response.

api: CliApiVersionApi
cli: CliApiVersionCli
model_config = {'extra': 'allow'}

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

class smarter.apps.api.v1.contract.models.CliApiVersionApi(*, version, python, **extra_data)[source]

Bases: CliApiModel

The platform’s version, and the versions of its main Python packages.

model_config = {'extra': 'allow'}

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

python: dict[str, str | None]
version: str
class smarter.apps.api.v1.contract.models.CliApiVersionCli(*, version, **extra_data)[source]

Bases: CliApiModel

The smarter cli’s latest version.

model_config = {'extra': 'allow'}

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

version: str
class smarter.apps.api.v1.contract.models.CliApiWhoami(*, user, account, environment, **extra_data)[source]

Bases: CliApiModel

The data of a whoami response: the api key’s user and account, and the platform’s environment.

account: CliApiWhoamiAccount
environment: str
model_config = {'extra': 'allow'}

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

user: CliApiWhoamiUser
class smarter.apps.api.v1.contract.models.CliApiWhoamiAccount(*, id, hashedId=None, accountNumber, name=None, description=None, companyName=None, isDefaultAccount=None, isActive=None, createdAt=None, updatedAt=None, phoneNumber=None, address1=None, address2=None, city=None, state=None, postalCode=None, country=None, language=None, timezone=None, currency=None, **extra_data)[source]

Bases: CliApiModel

The api key’s account.

accountNumber: str
address1: str | None
address2: str | None
city: str | None
companyName: str | None
country: str | None
createdAt: str | None
currency: str | None
description: str | None
hashedId: str | None
id: int
isActive: bool | None
isDefaultAccount: bool | None
language: str | None
model_config = {'extra': 'allow'}

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

name: str | None
phoneNumber: str | None
postalCode: str | None
state: str | None
timezone: str | None
updatedAt: str | None
class smarter.apps.api.v1.contract.models.CliApiWhoamiUser(*, id, username, firstName=None, lastName=None, email=None, isStaff, isSuperuser, **extra_data)[source]

Bases: CliApiModel

The api key’s user.

email: str | None
firstName: str | None
id: int
isStaff: bool
isSuperuser: bool
lastName: str | None
model_config = {'extra': 'allow'}

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

username: str
class smarter.apps.api.v1.contract.models.OpenApiComponents(*, schemas, securitySchemes)[source]

Bases: OpenApiModel

The document’s reusable schemas and security schemes.

model_config = {'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

schemas: dict[str, JsonValue]
securitySchemes: dict[str, OpenApiSecurityScheme]
class smarter.apps.api.v1.contract.models.OpenApiContact(*, name, url)[source]

Bases: OpenApiModel

The document’s contact information.

model_config = {'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
url: str
class smarter.apps.api.v1.contract.models.OpenApiDocument(*, openapi, info, servers, security, tags, paths, components)[source]

Bases: OpenApiModel

An OpenAPI 3.1 document.

It has no jsonSchemaDialect: its schemas use the default dialect of OpenAPI 3.1, which is JSON Schema 2020-12 with OpenAPI’s keywords. Viewers such as Swagger UI support no other value.

components: OpenApiComponents
info: OpenApiInfo
model_config = {'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

openapi: str
paths: dict[str, OpenApiPathItem]
security: list[dict[str, list[str]]]
servers: list[OpenApiServer]
tags: list[OpenApiTag]
class smarter.apps.api.v1.contract.models.OpenApiInfo(*, title, version, summary=None, description=None, contact=None, license=None)[source]

Bases: OpenApiModel

The document’s metadata.

contact: OpenApiContact | None
description: str | None
license: OpenApiLicense | None
model_config = {'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

summary: str | None
title: str
version: str
class smarter.apps.api.v1.contract.models.OpenApiLicense(*, name, url)[source]

Bases: OpenApiModel

The api’s license.

model_config = {'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
url: str
class smarter.apps.api.v1.contract.models.OpenApiMediaType(*, schema, x_smarter_events=None)[source]

Bases: OpenApiModel

The schema of a request’s or response’s body, in one media type.

model_config = {'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

schema_: JsonValue
x_smarter_events: dict[str, JsonValue] | None
class smarter.apps.api.v1.contract.models.OpenApiModel[source]

Bases: BaseModel

Base class of the models of an OpenAPI 3.1 document.

They forbid extra fields, so a misspelled field fails rather than being published. Fields whose OpenAPI name is a Python keyword, or a BaseModel attribute, have an alias: e.g. in_ is in, and schema_ is schema. A field that is None is left out of the dump, because no OpenAPI field may be null. exclude_none would also drop the nulls inside the schemas, e.g. a field’s "default": null, so the models drop their own Nones instead.

model_config = {'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

class smarter.apps.api.v1.contract.models.OpenApiOperation(*, operationId, summary, description=None, tags=<factory>, parameters=<factory>, requestBody=None, responses, security=None)[source]

Bases: OpenApiModel

An http method of a path.

description: str | None
model_config = {'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

operationId: str
parameters: list[OpenApiParameter]
requestBody: OpenApiRequestBody | None
responses: dict[str, OpenApiResponse]
security: list[dict[str, list[str]]] | None
summary: str
tags: list[str]
class smarter.apps.api.v1.contract.models.OpenApiParameter(*, name, in_, description=None, required=False, schema)[source]

Bases: OpenApiModel

A path, query or header parameter of an operation.

description: str | None
in_: Literal['path', 'query', 'header']
model_config = {'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
required: bool
schema_: JsonValue
class smarter.apps.api.v1.contract.models.OpenApiPathItem(*, get=None, post=None, delete=None)[source]

Bases: OpenApiModel

A path, and its operations.

delete: OpenApiOperation | None
get: OpenApiOperation | None
model_config = {'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

post: OpenApiOperation | None
class smarter.apps.api.v1.contract.models.OpenApiRequestBody(*, description=None, required=False, content)[source]

Bases: OpenApiModel

An operation’s request body.

content: dict[str, OpenApiMediaType]
description: str | None
model_config = {'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

required: bool
class smarter.apps.api.v1.contract.models.OpenApiResponse(*, description, content=None)[source]

Bases: OpenApiModel

One of an operation’s responses.

content: dict[str, OpenApiMediaType] | None
description: str
model_config = {'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

type smarter.apps.api.v1.contract.models.OpenApiSchema = _AllowAnyJson]

A JSON Schema (2020-12), e.g. {"$ref": "#/components/schemas/SAMGuardrail"}.

class smarter.apps.api.v1.contract.models.OpenApiSecurityScheme(*, type='apiKey', name, in_='header', description=None)[source]

Bases: OpenApiModel

An api key scheme: the only one that the cli api accepts from programs.

description: str | None
in_: Literal['header']
model_config = {'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
type: Literal['apiKey']
class smarter.apps.api.v1.contract.models.OpenApiServer(*, url, description=None, variables=None)[source]

Bases: OpenApiModel

A server that hosts the api.

description: str | None
model_config = {'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

url: str
variables: dict[str, OpenApiServerVariable] | None
class smarter.apps.api.v1.contract.models.OpenApiServerVariable(*, default, description=None)[source]

Bases: OpenApiModel

A variable of a server’s url.

default: str
description: str | None
model_config = {'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

class smarter.apps.api.v1.contract.models.OpenApiTag(*, name, description=None)[source]

Bases: OpenApiModel

A tag, which groups operations.

description: str | None
model_config = {'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
class smarter.apps.api.v1.contract.models.RestApiErrorResponse(*, detail, **extra_data)[source]

Bases: BaseModel

The body of an error response of the REST api’s views: Django REST framework’s {"detail": ...}.

e.g. a 404 for a row that does not exist, or a 403 for a user who may not use the view.

detail: str
model_config = {'extra': 'allow'}

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

The OpenAPI 3.1 document of the Smarter api, generated from Pydantic models.

The document covers the apis that the smarter cli and the SDKs call, family by family:

  • the cli api (/api/v1/cli/), to apply, get, describe, validate and delete the resources that SAM manifests declare (cli),

  • the chat api (/api/v1/llm-clients/{id}/config/, .../prompt/ and .../provider-request/), to chat with an LLMClient, as JSON or as a stream of Server-Sent Events (chat),

  • the REST api of each resource family, one module each in families, whose responses are built from each app’s contract models, e.g. smarter.apps.llmclient.contract.models. Mostly reads: clients write through the cli api’s manifests, which the brokers validate.

The package’s modules:

A change to any of the models changes the document. manage.py export_api_contract writes it to openapi.json, beside this package, and a test fails if the committed file is out of date, or if a route of a family in routes.DOCUMENTED_URLCONFS is neither in the document nor in routes.UNDOCUMENTED_ROUTES.

Every platform serves this document at /api/v1/openapi.json (smarter.apps.api.v1.contract.views; /docs/openapi.json redirects there), and renders it with Scalar at /docs/openapi/. It is the platform’s only api documentation.

The building blocks of the OpenAPI document: references, responses, operations, parameters, and families of routes.

Each family of the REST api is an ApiFamily, named after its Django app, from which its tag, its operations’ ids, its paths, and the words that its descriptions use for its resource are derived, so that each is written once.

smarter.apps.api.v1.contract.openapi.builders.API_KEY_AUTH = 'ApiKeyAuth'

The name of the document’s security scheme.

smarter.apps.api.v1.contract.openapi.builders.API_KEY_ONLY = 'Requires an api key.'

The note of the REST reads that any api key may call, and whose views filter nothing more.

class smarter.apps.api.v1.contract.openapi.builders.ApiFamily(name, resource, urlconf, description, resources=None, tag_name=None, mount=None)[source]

A family of the REST api’s routes: one Django app’s, or one feature’s of an app.

Everything that the document says about the family is derived from a few names, so that each is written once: e.g. ApiFamily(name="guardrail", resource="Guardrail", ...) has the tag guardrails, the routes /guardrails/..., the operation ids guardrail_list and guardrail_retrieve, the plural Guardrails and the article a Guardrail.

__init__(name, resource, urlconf, description, resources=None, tag_name=None, mount=None)
property a: str

e.g. an LLMClient, or a Guardrail.

Type:

The resource with its article, as a sentence names it

property a_capitalized: str

e.g. An LLMClient.

Type:

The resource with its article, as a sentence’s or a summary’s first words

description: str

The description of the family’s tag, in which {plural} is plural, e.g. The {plural}’ REST reads.

mount: str | None = None

Where smarter.apps.api.v1.urls mounts the family’s routes, if not at its tag, e.g. llm-clients.

name: str

The family’s name, its Django app’s (the app’s const.namespace), e.g. guardrail.

Its operations’ ids start with it, and its tag is its plural.

openapi_tag()[source]

The document’s tag of the family’s operations.

Returns:

The tag.

Return type:

OpenApiTag

operation_id(action)[source]

The id of one of the family’s operations.

Parameters:

action (str) – What the operation does, e.g. list.

Returns:

e.g. guardrail_list.

Return type:

str

path(suffix='')[source]

The path of one of the family’s routes, relative to the server’s /api/v1.

Parameters:

suffix (str) – The route’s path, relative to prefix, e.g. {id}/events/.

Returns:

e.g. /guardrails/{id}/events/.

Return type:

str

property plural: str

The plural of resource, e.g. Guardrails.

property prefix: str

mount or tag, e.g. /guardrails/.

Type:

The path of the family’s routes, relative to /api/v1

resource: str

its SAM kind, e.g. Guardrail, or a word, e.g. vectorstore.

Type:

The family’s resource, as its descriptions name it

resources: str | None = None

it adds only an s to a capitalized Proxy.

Type:

The plural of resource, if inflect gets it wrong, e.g. Proxies

property tag: str

tag_name, or the plural of name, e.g. guardrails.

Type:

The tag of the family’s operations

tag_name: str | None = None

The family’s tag, if it isn’t the plural of name, e.g. journal.

urlconf: str

The module of the family’s url patterns.

smarter.apps.api.v1.contract.openapi.builders.OPERATION_ERROR = 'An error, e.g. 400 for an invalid request, or 404 for a row that the user may not read or own.'

The error of an action that every user may call, on what they may read or own.

smarter.apps.api.v1.contract.openapi.builders.PUBLIC: list[dict[str, list[str]]] = []

The security of an operation that needs no api key.

[]
smarter.apps.api.v1.contract.openapi.builders.READ_ERROR = 'An error, e.g. 404 for a row that does not exist, or that the user may not read.'

The error of a read that every user may call, for what they may read.

smarter.apps.api.v1.contract.openapi.builders.READ_PERMISSION = "Requires an api key. The response includes only what the user may read: their account's resources, and the platform's built-in ones."

The note of the REST reads whose views are SmarterAuthenticatedAPIView and SmarterAuthenticatedListAPIView.

smarter.apps.api.v1.contract.openapi.builders.REF_TEMPLATE = '#/components/schemas/{model}'

Where the document’s schemas refer to each other’s definitions.

smarter.apps.api.v1.contract.openapi.builders.SUPERUSER_ONLY = "Requires an api key of a superuser: the REST api's views refuse other users with a 403. Other users read their resources with the cli api's get and describe."

The note of the REST reads whose views are SmarterAdminAPIView and SmarterAdminListAPIView.

smarter.apps.api.v1.contract.openapi.builders.SUPERUSER_OPERATION_ERROR = 'An error, e.g. 400 for an invalid request, 403 for a user who is not a superuser, or 404 for a row that does not exist.'

The error of an action that only superusers may call.

smarter.apps.api.v1.contract.openapi.builders.SUPERUSER_READ_ERROR = 'An error, e.g. 404 for a row that does not exist, or 403 for a user who is not a superuser.'

SUPERUSER_ONLY.

Type:

The error of a read that only superusers may call

smarter.apps.api.v1.contract.openapi.builders.envelope(data, description)[source]

The schema of a journaled response: the journal’s envelope, beside the command’s data and message.

Parameters:
  • data (JsonValue | None) – The schema of the response’s data, or None for a response that has only a message.

  • description (str) – The schema’s description.

Returns:

The schema.

Return type:

JsonValue

smarter.apps.api.v1.contract.openapi.builders.id_or_hashed_id(resource)[source]

The {id} path parameter of a resource whose routes take its numeric id or its hashed id.

Parameters:

resource (str) – The resource’s kind, e.g. Guardrail.

Returns:

The parameter.

Return type:

OpenApiParameter

smarter.apps.api.v1.contract.openapi.builders.inflect_word(word)[source]

A word, as inflect’s functions take it: a string of at least one character.

inflect declares Word as Annotated[str, ...] for mypy, but as a class at run time, behind a flag that other type checkers, e.g. Pylance, can’t follow, so they refuse a str. inflect checks the length at run time; this checks it first, with a clearer message.

Parameters:

word (str) – The word, e.g. guardrail.

Returns:

The word, as an inflect.Word.

Return type:

Word

Raises:

ValueError – If the word is empty.

smarter.apps.api.v1.contract.openapi.builders.integer_id(name, description)[source]

A path parameter that is a row’s numeric id.

Parameters:
  • name (str) – The parameter’s name, e.g. plugin_id.

  • description (str) – Its description.

Returns:

The parameter.

Return type:

OpenApiParameter

smarter.apps.api.v1.contract.openapi.builders.json_body(schema_name, description=None, required=True)[source]

A JSON request body whose schema is one of the document’s.

Parameters:
  • schema_name (str) – The body’s schema, in components.schemas.

  • description (str | None) – The body’s description.

  • required (bool) – Whether the body is required.

Returns:

The request body.

Return type:

OpenApiRequestBody

smarter.apps.api.v1.contract.openapi.builders.json_response(description, schema_name)[source]

A JSON response whose body is one of the document’s schemas.

Parameters:
  • description (str) – The response’s description.

  • schema_name (str) – The body’s schema, in components.schemas.

Returns:

The response.

Return type:

OpenApiResponse

smarter.apps.api.v1.contract.openapi.builders.merge_paths(*families)[source]

The paths of several families, with the operations of a path that two families share in one path item.

Parameters:

families (dict[str, OpenApiPathItem]) – Each family’s paths.

Returns:

The paths.

Return type:

dict[str, OpenApiPathItem]

Raises:

ValueError – If two families define the same method of a path.

smarter.apps.api.v1.contract.openapi.builders.path_string(name, description)[source]

A path parameter that is a string, e.g. a Provider’s name.

Parameters:
  • name (str) – The parameter’s name.

  • description (str) – Its description.

Returns:

The parameter.

Return type:

OpenApiParameter

smarter.apps.api.v1.contract.openapi.builders.plural(word)[source]

The plural of a word or a phrase, e.g. guardrails, LLMClients, account contacts.

Parameters:

word (str) – The word, e.g. guardrail.

Returns:

Its plural.

Return type:

str

smarter.apps.api.v1.contract.openapi.builders.query(name, description, schema, required=False)[source]

A query parameter.

Parameters:
  • name (str) – The parameter’s name.

  • description (str) – Its description.

  • schema (JsonValue) – Its JSON Schema.

  • required (bool) – Whether it is required.

Returns:

The parameter.

Return type:

OpenApiParameter

smarter.apps.api.v1.contract.openapi.builders.ref(name)[source]

A reference to one of the document’s schemas.

Parameters:

name (str) – The schema’s name in components.schemas.

Returns:

e.g. {"$ref": "#/components/schemas/SAMGuardrail"}.

Return type:

JsonValue

smarter.apps.api.v1.contract.openapi.builders.rest_operation(operation_id, summary, description, tag, response, *, parameters, status='200', request_body=None, error='An error, e.g. 400 for an invalid request, or 404 for a row that the user may not read or own.')[source]

An operation of the REST api, whose success is one of the document’s schemas, and whose errors are DRF’s.

Parameters:
  • operation_id (str) – The operation’s id, e.g. vectorstore_search.

  • summary (str) – A one-line summary.

  • description (str) – A description, which says who may call it, and what it changes.

  • tag (str) – The operation’s tag.

  • response (str) – The successful response’s schema, in components.schemas.

  • parameters (list[OpenApiParameter]) – The operation’s parameters.

  • status (str) – The successful response’s http status, e.g. 202 for queued work.

  • request_body (OpenApiRequestBody | None) – The operation’s request body.

  • error (str) – The description of its errors, e.g. SUPERUSER_OPERATION_ERROR.

Returns:

The operation.

Return type:

OpenApiOperation

smarter.apps.api.v1.contract.openapi.builders.rest_read(operation_id, summary, description, tag, item, *, many, parameters, note="Requires an api key of a superuser: the REST api's views refuse other users with a 403. Other users read their resources with the cli api's get and describe.", success=None)[source]

A read of the REST api: a GET whose response is a row, or a list of rows, of one of the document’s schemas.

Parameters:
  • operation_id (str) – The operation’s id, e.g. llmclient_list.

  • summary (str) – A one-line summary.

  • description (str) – A description, to which note is added.

  • tag (str) – The operation’s tag.

  • item (str) – The schema of a row, in components.schemas.

  • many (bool) – Whether the response is a list of rows.

  • parameters (list[OpenApiParameter]) – The operation’s parameters.

  • note (str) – Who may read, e.g. SUPERUSER_ONLY or READ_PERMISSION. It also chooses the error’s description: SUPERUSER_READ_ERROR for SUPERUSER_ONLY, else READ_ERROR.

  • success (str | None) – The successful response’s description, if the response is not a row or a list of rows, e.g. The window’s points.

Returns:

The operation.

Return type:

OpenApiOperation

smarter.apps.api.v1.contract.openapi.builders.superuser_list_and_retrieve(family, item)[source]

A family’s REST list and retrieve, whose views only superusers may call.

Parameters:
  • family (ApiFamily) – The family.

  • item (str) – The schema of a row, in components.schemas.

Returns:

The paths.

Return type:

dict[str, OpenApiPathItem]

smarter.apps.api.v1.contract.openapi.builders.with_article(word, capitalize=False)[source]

A word or a phrase with its indefinite article, e.g. a Guardrail, an LLMClient.

Parameters:
  • word (str) – The word, e.g. LLMClient.

  • capitalize (bool) – Whether to capitalize the article, for a sentence’s or a summary’s first words.

Returns:

e.g. an LLMClient, or An LLMClient.

Return type:

str

The document’s components: the JSON Schemas of the models that its operations use.

The schemas are generated from the platform’s Pydantic models in one pass, so that a model that two families share is one schema: the SAM models of every kind, the journal and chat contracts, each family’s contract models, and the cli’s data. cli_schemas() adds the schemas that no model has, e.g. a manifest of any kind.

smarter.apps.api.v1.contract.openapi.schemas.CHAT_MODELS: tuple[type[BaseModel], ...] = (<class 'smarter.apps.prompt.contract.models.PromptChatApiConfigRequest'>, <class 'smarter.apps.prompt.contract.models.PromptChatApiConfigResponse'>, <class 'smarter.apps.prompt.contract.models.PromptChatApiPromptRequest'>, <class 'smarter.apps.prompt.contract.models.PromptChatApiPromptResponse'>, <class 'smarter.apps.prompt.contract.models.PromptChatApiErrorResponse'>, <class 'smarter.apps.prompt.contract.models.PromptChatApiProgressEvent'>, <class 'smarter.apps.prompt.contract.models.PromptChatApiProgressResult'>, <class 'smarter.apps.prompt.contract.models.PromptChatApiProviderRequestResponse'>)

The Smarter Chat api contract’s models that the chat api’s operations use.

(
    <class 'smarter.apps.prompt.contract.models.PromptChatApiConfigRequest'>,
    <class 'smarter.apps.prompt.contract.models.PromptChatApiConfigResponse'>,
    <class 'smarter.apps.prompt.contract.models.PromptChatApiPromptRequest'>,
    <class 'smarter.apps.prompt.contract.models.PromptChatApiPromptResponse'>,
    <class 'smarter.apps.prompt.contract.models.PromptChatApiErrorResponse'>,
    <class 'smarter.apps.prompt.contract.models.PromptChatApiProgressEvent'>,
    <class 'smarter.apps.prompt.contract.models.PromptChatApiProgressResult'>,
    <class 'smarter.apps.prompt.contract.models.PromptChatApiProviderRequestResponse'>,
)
smarter.apps.api.v1.contract.openapi.schemas.cli_schemas()[source]

Every schema of the document: the models’ schemas, a manifest of any kind, and the responses of the commands.

Returns:

The schemas, by name, and the SAM kinds.

Return type:

tuple[dict[str, JsonValue], list[str]]

smarter.apps.api.v1.contract.openapi.schemas.model_schemas()[source]

The JSON Schemas of the SAM models, the journal contract and the cli’s data, as the document’s components.

Returns:

The schemas, by name, and the name of each SAM kind’s schema, by kind. A kind’s schema is named after its model, e.g. SAMGuardrail, unless two models share a name.

Return type:

tuple[dict[str, JsonValue], dict[str, str]]

The cli api’s operations, under /api/v1/cli/: the commands of the smarter cli, as the SDKs send them.

Every command is a POST whose response is journaled: the journal’s envelope, beside the command’s data or message, and whose errors are the journal’s error response.

smarter.apps.api.v1.contract.openapi.cli.CLI_PREFIX = '/cli/'

The path of the cli api’s routes, relative to /api/v1.

smarter.apps.api.v1.contract.openapi.cli.CLI_TAGS = [OpenApiTag(name='manifests', description='Resources, and the manifests that declare them.'), OpenApiTag(name='deployment', description='Deployable resources, e.g. LLMClients.'), OpenApiTag(name='platform', description="The platform, and the api key's user.")]

The tags of the cli api’s commands, but its chat commands’, which are the chat api’s.

[
    OpenApiTag(name='manifests', description='Resources, and the manifests that declare them.'),
    OpenApiTag(name='deployment', description='Deployable resources, e.g. LLMClients.'),
    OpenApiTag(name='platform', description="The platform, and the api key's user."),
]
smarter.apps.api.v1.contract.openapi.cli.CLI_URLCONF = 'smarter.apps.api.v1.cli.urls'

The module of the cli api’s url patterns.

smarter.apps.api.v1.contract.openapi.cli.cli_path(command)[source]

The path of a cli command, relative to the server’s /api/v1.

Parameters:

command (str) – The command’s path, relative to CLI_PREFIX, e.g. get/{kind}/.

Returns:

e.g. /cli/get/{kind}/.

Return type:

str

smarter.apps.api.v1.contract.openapi.cli.cli_paths()[source]

The cli api’s paths, relative to the server’s /api/v1, by the url names of their routes.

Returns:

The paths, e.g. {"/cli/apply/": ...}.

Return type:

dict[str, OpenApiPathItem]

smarter.apps.api.v1.contract.openapi.cli.operation(operation_id, summary, description, tag, response, *, parameters=None, request_body=None, security=None)[source]

A cli command: an operation whose successful response is 200, and whose other responses are journaled errors.

Parameters:
  • operation_id (str) – The operation’s id, e.g. apply.

  • summary (str) – A one-line summary.

  • description (str) – A description.

  • tag (str) – The operation’s tag.

  • response (str) – The successful response’s schema, in components.schemas.

  • parameters (list[OpenApiParameter] | None) – The operation’s parameters.

  • request_body (OpenApiRequestBody | None) – The operation’s request body.

  • security (list[dict[str, list[str]]] | None) – The operation’s security, e.g. PUBLIC, or None for the document’s.

Returns:

The operation.

Return type:

OpenApiOperation

The chat api, under /api/v1/llm-clients/{id}/: what Smarter Chat and the SDKs call to chat with an LLMClient.

Its requests and responses are the Smarter Chat api contract’s, version 2 (smarter.apps.prompt.contract.models).

smarter.apps.api.v1.contract.openapi.chat.CHAT_TAG = OpenApiTag(name='chat', description='Chats with LLMClients.')

The document’s tag of the chat api.

smarter.apps.api.v1.contract.openapi.chat.TAG_CHAT = 'chat'

The tag of the chat api’s operations, and of the cli’s prompt commands.

smarter.apps.api.v1.contract.openapi.chat.chat_paths()[source]

The chat api’s paths, relative to the server’s /api/v1.

The prompt’s 200 response is JSON, or, for a client that accepts text/event-stream, a stream of Server-Sent Events: progress events, then one result event, whose response is the JSON that a non-streaming client receives. OpenAPI 3.1 can’t type the events of a stream, so the stream’s media type names their schemas in an x-smarter-events extension.

Returns:

The paths, e.g. {"/llm-clients/{id}/prompt/": ...}.

Return type:

dict[str, OpenApiPathItem]

Which routes of /api/v1 the document covers, and why it leaves out the others.

test_every_route_is_documented and test_every_family_is_covered hold the document to these tables: every route of a family in DOCUMENTED_URLCONFS must be in the document, or in UNDOCUMENTED_ROUTES, and every family that smarter.apps.api.v1.urls mounts must be in DOCUMENTED_URLCONFS, or in UNDOCUMENTED_URLCONFS.

smarter.apps.api.v1.contract.openapi.routes.CONNECTIONS_PREFIX = '/connections/'

its urlconf has no routes.

Type:

The path of the connections’ routes, a family that has none to document

smarter.apps.api.v1.contract.openapi.routes.DOCUMENTED_URLCONFS: dict[str, str] = {'/accounts/': 'smarter.apps.account.api.v1.urls', '/cli/': 'smarter.apps.api.v1.cli.urls', '/connections/': 'smarter.apps.connection.api.v1.urls', '/extensions/': 'smarter.apps.llmtool.extension.api.v1.urls', '/guardrails/': 'smarter.apps.guardrail.api.v1.urls', '/journal/': 'smarter.lib.journal.api.v1.urls', '/llm-clients/': 'smarter.apps.llmclient.api.v1.urls', '/llmhosts/': 'smarter.apps.llmhost.api.v1.urls', '/mcpclients/': 'smarter.apps.mcpclient.api.v1.urls', '/orchestrators/': 'smarter.apps.orchestrator.api.v1.urls', '/plugins/': 'smarter.apps.llmtool.api.v1.urls', '/prompts/': 'smarter.apps.prompt.api.v1.urls', '/providers/': 'smarter.apps.provider.api.v1.urls', '/proxy/': 'smarter.apps.proxy.api.v1.urls', '/secrets/': 'smarter.apps.secret.api.v1.urls', '/vectorsearches/': 'smarter.apps.vectorsearch.api.v1.urls', '/vectorstores/': 'smarter.apps.vectorstore.api.v1.urls'}

each one’s path, relative to /api/v1, and its urlconf.

The cli api’s, the connections’, and each of FAMILIES. Every route of these urlconfs must be in the document, or in UNDOCUMENTED_ROUTES.

{
    '/accounts/': 'smarter.apps.account.api.v1.urls',
    '/cli/': 'smarter.apps.api.v1.cli.urls',
    '/connections/': 'smarter.apps.connection.api.v1.urls',
    '/extensions/': 'smarter.apps.llmtool.extension.api.v1.urls',
    '/guardrails/': 'smarter.apps.guardrail.api.v1.urls',
    '/journal/': 'smarter.lib.journal.api.v1.urls',
    '/llm-clients/': 'smarter.apps.llmclient.api.v1.urls',
    '/llmhosts/': 'smarter.apps.llmhost.api.v1.urls',
    '/mcpclients/': 'smarter.apps.mcpclient.api.v1.urls',
    '/orchestrators/': 'smarter.apps.orchestrator.api.v1.urls',
    '/plugins/': 'smarter.apps.llmtool.api.v1.urls',
    '/prompts/': 'smarter.apps.prompt.api.v1.urls',
    '/providers/': 'smarter.apps.provider.api.v1.urls',
    '/proxy/': 'smarter.apps.proxy.api.v1.urls',
    '/secrets/': 'smarter.apps.secret.api.v1.urls',
    '/vectorsearches/': 'smarter.apps.vectorsearch.api.v1.urls',
    '/vectorstores/': 'smarter.apps.vectorstore.api.v1.urls',
}
Type:

The families of routes that the document covers

smarter.apps.api.v1.contract.openapi.routes.ID_FAMILIES = (ApiFamily(name='llmclient', resource='LLMClient', urlconf='smarter.apps.llmclient.api.v1.urls', description="The {plural}' REST reads.", resources=None, tag_name=None, mount='llm-clients'), ApiFamily(name='guardrail', resource='Guardrail', urlconf='smarter.apps.guardrail.api.v1.urls', description="The {plural}' REST reads, and their dry run.", resources=None, tag_name=None, mount=None), ApiFamily(name='secret', resource='Secret', urlconf='smarter.apps.secret.api.v1.urls', description="The {plural}' REST reads: their metadata, never their values.", resources=None, tag_name=None, mount=None), ApiFamily(name='mcpclient', resource='MCPClient', urlconf='smarter.apps.mcpclient.api.v1.urls', description="The {plural}' REST reads, their reconnection, and tool calls.", resources=None, tag_name=None, mount=None), ApiFamily(name='vectorstore', resource='vectorstore', urlconf='smarter.apps.vectorstore.api.v1.urls', description="The {plural}' REST reads, search, documents and maintenance. Served only when the platform enables {plural} (SMARTER_APP_VECTORSTORE_ENABLE).", resources=None, tag_name=None, mount=None), ApiFamily(name='llmhost', resource='LLMHost', urlconf='smarter.apps.llmhost.api.v1.urls', description="The {plural}' REST reads, model discovery, and deployment.", resources=None, tag_name=None, mount=None), ApiFamily(name='orchestrator', resource='Orchestrator', urlconf='smarter.apps.orchestrator.api.v1.urls', description="The {plural}' REST reads, for superusers, and their runs, for any user who may read them.", resources=None, tag_name=None, mount=None), ApiFamily(name='vectorsearch', resource='Vectorsearch', urlconf='smarter.apps.vectorsearch.api.v1.urls', description="The {plural}' REST reads, for superusers, and their runs, for any user who may read them.", resources=None, tag_name=None, mount=None))

The families whose routes take <int:<name>_id>, e.g. <int:guardrail_id>, beside <str:hashed_id>.

(
    ApiFamily(name='llmclient', resource='LLMClient', urlconf='smarter.apps.llmclient.api.v1.urls', description="The {plural}' REST reads.", resources=None, tag_name=None, mount='llm-clients'),
    ApiFamily(name='guardrail', resource='Guardrail', urlconf='smarter.apps.guardrail.api.v1.urls', description="The {plural}' REST reads, and their dry run.", resources=None, tag_name=None, mount=None),
    ApiFamily(name='secret', resource='Secret', urlconf='smarter.apps.secret.api.v1.urls', description="The {plural}' REST reads: their metadata, never their values.", resources=None, tag_name=None, mount=None),
    ApiFamily(name='mcpclient', resource='MCPClient', urlconf='smarter.apps.mcpclient.api.v1.urls', description="The {plural}' REST reads, their reconnection, and tool calls.", resources=None, tag_name=None, mount=None),
    ApiFamily(name='vectorstore', resource='vectorstore', urlconf='smarter.apps.vectorstore.api.v1.urls', description="The {plural}' REST reads, search, documents and maintenance. Served only when the platform enables {plural} (SMARTER_APP_VECTORSTORE_ENABLE).", resources=None, tag_name=None, mount=None),
    ApiFamily(name='llmhost', resource='LLMHost', urlconf='smarter.apps.llmhost.api.v1.urls', description="The {plural}' REST reads, model discovery, and deployment.", resources=None, tag_name=None, mount=None),
    ApiFamily(name='orchestrator', resource='Orchestrator', urlconf='smarter.apps.orchestrator.api.v1.urls', description="The {plural}' REST reads, for superusers, and their runs, for any user who may read them.", resources=None, tag_name=None, mount=None),
    ApiFamily(name='vectorsearch', resource='Vectorsearch', urlconf='smarter.apps.vectorsearch.api.v1.urls', description="The {plural}' REST reads, for superusers, and their runs, for any user who may read them.", resources=None, tag_name=None, mount=None),
)
smarter.apps.api.v1.contract.openapi.routes.PATH_PARAMETER_ALIASES: dict[str, str] = {'guardrail_id': 'id', 'hashed_id': 'id', 'llmclient_id': 'id', 'llmhost_id': 'id', 'mcpclient_id': 'id', 'orchestrator_id': 'id', 'pk': 'id', 'secret_id': 'id', 'vectorsearch_id': 'id', 'vectorstore_id': 'id'}

The document’s names of the routes’ path parameters, where they differ.

A resource’s routes take either its numeric id or its hashed id, e.g. <int:guardrail_id> and <str:hashed_id>, which the document describes as one {id}.

{
    'guardrail_id': 'id',
    'hashed_id': 'id',
    'llmclient_id': 'id',
    'llmhost_id': 'id',
    'mcpclient_id': 'id',
    'orchestrator_id': 'id',
    'pk': 'id',
    'secret_id': 'id',
    'vectorsearch_id': 'id',
    'vectorstore_id': 'id',
}
smarter.apps.api.v1.contract.openapi.routes.UNDOCUMENTED_ROUTES: dict[str, str] = {'/accounts/batch-create-users/': 'Creates users from a CSV file in the web console. Clients apply User manifests with the cli api.', '/llm-clients/{id}/prompt/config/': 'A legacy alias of /llm-clients/{id}/config/, for pages that installed an older Smarter Chat.', '/orchestrators/{id}/orchestrator/': 'Running an Orchestrator is not implemented yet: the route has no POST handler, and answers 405.', '/plugins/upload/': "A web console action, which clients replace with the cli api's manifests.", '/plugins/{plugin_id}/clone/{new_name}': "A web console action, which clients replace with the cli api's manifests.", '/prompts/passthrough/{provider_name}/': "A passthrough to an LLM provider's api, whose requests and responses are the provider's, not Smarter's.", '/prompts/smarter/{provider_name}/': "The chat api of an LLM provider through Smarter, whose requests and responses are the provider's, not Smarter's.", '/proxy/{name}/': "A Proxy's passthrough, whose requests and responses are its provider's api, not Smarter's.", '/proxy/{name}/{path}': "A Proxy's passthrough, whose requests and responses are its provider's api, not Smarter's."}

The paths of the routes of DOCUMENTED_URLCONFS that the document leaves out, and why.

{
    '/accounts/batch-create-users/': 'Creates users from a CSV file in the web console. Clients apply User manifests with the cli api.',
    '/llm-clients/{id}/prompt/config/': 'A legacy alias of /llm-clients/{id}/config/, for pages that installed an older Smarter Chat.',
    '/orchestrators/{id}/orchestrator/': 'Running an Orchestrator is not implemented yet: the route has no POST handler, and answers 405.',
    '/plugins/upload/': "A web console action, which clients replace with the cli api's manifests.",
    '/plugins/{plugin_id}/clone/{new_name}': "A web console action, which clients replace with the cli api's manifests.",
    '/prompts/passthrough/{provider_name}/': "A passthrough to an LLM provider's api, whose requests and responses are the provider's, not Smarter's.",
    '/prompts/smarter/{provider_name}/': "The chat api of an LLM provider through Smarter, whose requests and responses are the provider's, not Smarter's.",
    '/proxy/{name}/': "A Proxy's passthrough, whose requests and responses are its provider's api, not Smarter's.",
    '/proxy/{name}/{path}': "A Proxy's passthrough, whose requests and responses are its provider's api, not Smarter's.",
}
smarter.apps.api.v1.contract.openapi.routes.UNDOCUMENTED_URLCONFS: dict[str, str] = {'/demos/': "Fictional data for the platform's example resources, e.g. the Stackademy course catalogue that the Stackademy ApiPlugin queries. These are not part of the platform's api.", '/doodles/': "The sign-in page's doodle of the day and its artwork, smarter.apps.doodle, which only the page's own React app reads. These are not part of the platform's api.", '/mcp/': 'The MCPServer, smarter.apps.mcpserver: a JSON-RPC endpoint for its public tools and one for its staff-only tools, whose methods and messages the Model Context Protocol specification defines, not OpenAPI.', '/tests/': "Views that only the platform's own unit tests call."}

The families of routes under /api/v1 that the document leaves out, and why.

Every family that smarter.apps.api.v1.urls mounts must be in DOCUMENTED_URLCONFS or here.

{
    '/demos/': "Fictional data for the platform's example resources, e.g. the Stackademy course catalogue that the Stackademy ApiPlugin queries. These are not part of the platform's api.",
    '/doodles/': "The sign-in page's doodle of the day and its artwork, smarter.apps.doodle, which only the page's own React app reads. These are not part of the platform's api.",
    '/mcp/': 'The MCPServer, smarter.apps.mcpserver: a JSON-RPC endpoint for its public tools and one for its staff-only tools, whose methods and messages the Model Context Protocol specification defines, not OpenAPI.',
    '/tests/': "Views that only the platform's own unit tests call.",
}

The Smarter api’s OpenAPI document: its metadata, its tags, and every family’s paths, assembled.

manage.py export_api_contract writes it to openapi.json, with write_openapi().

smarter.apps.api.v1.contract.openapi.document.openapi_document()[source]

The Smarter api’s OpenAPI document.

Returns:

The document.

Return type:

OpenApiDocument

smarter.apps.api.v1.contract.openapi.document.openapi_json()[source]

The Smarter api’s OpenAPI document, as the text of openapi.json.

Returns:

The document, as indented JSON, with a final newline.

Return type:

str

smarter.apps.api.v1.contract.openapi.document.write_openapi(path='/home/runner/work/smarter/smarter/smarter/smarter/apps/api/v1/contract/openapi.json')[source]

Write the Smarter api’s OpenAPI document.

Parameters:

path (str) – The file to write. Defaults to openapi.json, beside this module.

Returns:

The path that was written.

Return type:

str

The REST api’s families of routes, one module per family.

Each module declares its family, an ApiFamily named after its Django app, and a <family>_paths() function that returns its operations. FAMILIES lists them in the order of the document’s tags.

smarter.apps.api.v1.contract.openapi.families.FAMILIES: tuple[ApiFamily, ...] = (ApiFamily(name='llmclient', resource='LLMClient', urlconf='smarter.apps.llmclient.api.v1.urls', description="The {plural}' REST reads.", resources=None, tag_name=None, mount='llm-clients'), ApiFamily(name='guardrail', resource='Guardrail', urlconf='smarter.apps.guardrail.api.v1.urls', description="The {plural}' REST reads, and their dry run.", resources=None, tag_name=None, mount=None), ApiFamily(name='secret', resource='Secret', urlconf='smarter.apps.secret.api.v1.urls', description="The {plural}' REST reads: their metadata, never their values.", resources=None, tag_name=None, mount=None), ApiFamily(name='mcpclient', resource='MCPClient', urlconf='smarter.apps.mcpclient.api.v1.urls', description="The {plural}' REST reads, their reconnection, and tool calls.", resources=None, tag_name=None, mount=None), ApiFamily(name='vectorstore', resource='vectorstore', urlconf='smarter.apps.vectorstore.api.v1.urls', description="The {plural}' REST reads, search, documents and maintenance. Served only when the platform enables {plural} (SMARTER_APP_VECTORSTORE_ENABLE).", resources=None, tag_name=None, mount=None), ApiFamily(name='llmhost', resource='LLMHost', urlconf='smarter.apps.llmhost.api.v1.urls', description="The {plural}' REST reads, model discovery, and deployment.", resources=None, tag_name=None, mount=None), ApiFamily(name='plugin', resource='plugin', urlconf='smarter.apps.llmtool.api.v1.urls', description="The {plural}' REST reads.", resources=None, tag_name=None, mount=None), ApiFamily(name='provider', resource='Provider', urlconf='smarter.apps.provider.api.v1.urls', description="The LLM {plural}' REST reads, and their models.", resources=None, tag_name=None, mount=None), ApiFamily(name='proxy', resource='Proxy', urlconf='smarter.apps.proxy.api.v1.urls', description='The {plural} that the user may use. Served only when the platform enables {plural} (SMARTER_APP_PROXY_ENABLE).', resources='Proxies', tag_name=None, mount='proxy'), ApiFamily(name='account', resource='account', urlconf='smarter.apps.account.api.v1.urls', description='The {plural}, their users and contacts. For superusers.', resources=None, tag_name=None, mount=None), ApiFamily(name='history', resource='chat session', urlconf='smarter.apps.prompt.api.v1.urls', description='The {plural}, and their tool calls and plugin usage.', resources=None, tag_name='history', mount='prompts'), ApiFamily(name='journal', resource='journal entry', urlconf='smarter.lib.journal.api.v1.urls', description='The Smarter Journal: a record of every journaled request to the Smarter api. For superusers.', resources=None, tag_name='journal', mount=None), ApiFamily(name='orchestrator', resource='Orchestrator', urlconf='smarter.apps.orchestrator.api.v1.urls', description="The {plural}' REST reads, for superusers, and their runs, for any user who may read them.", resources=None, tag_name=None, mount=None), ApiFamily(name='vectorsearch', resource='Vectorsearch', urlconf='smarter.apps.vectorsearch.api.v1.urls', description="The {plural}' REST reads, for superusers, and their runs, for any user who may read them.", resources=None, tag_name=None, mount=None), ApiFamily(name='extension', resource='extension', urlconf='smarter.apps.llmtool.extension.api.v1.urls', description="The {plural}: what every user's account may use, and their management by superusers.", resources=None, tag_name=None, mount=None))

Every family that the document covers, in the order of the document’s tags.

(
    ApiFamily(name='llmclient', resource='LLMClient', urlconf='smarter.apps.llmclient.api.v1.urls', description="The {plural}' REST reads.", resources=None, tag_name=None, mount='llm-clients'),
    ApiFamily(name='guardrail', resource='Guardrail', urlconf='smarter.apps.guardrail.api.v1.urls', description="The {plural}' REST reads, and their dry run.", resources=None, tag_name=None, mount=None),
    ApiFamily(name='secret', resource='Secret', urlconf='smarter.apps.secret.api.v1.urls', description="The {plural}' REST reads: their metadata, never their values.", resources=None, tag_name=None, mount=None),
    ApiFamily(name='mcpclient', resource='MCPClient', urlconf='smarter.apps.mcpclient.api.v1.urls', description="The {plural}' REST reads, their reconnection, and tool calls.", resources=None, tag_name=None, mount=None),
    ApiFamily(name='vectorstore', resource='vectorstore', urlconf='smarter.apps.vectorstore.api.v1.urls', description="The {plural}' REST reads, search, documents and maintenance. Served only when the platform enables {plural} (SMARTER_APP_VECTORSTORE_ENABLE).", resources=None, tag_name=None, mount=None),
    ApiFamily(name='llmhost', resource='LLMHost', urlconf='smarter.apps.llmhost.api.v1.urls', description="The {plural}' REST reads, model discovery, and deployment.", resources=None, tag_name=None, mount=None),
    ApiFamily(name='plugin', resource='plugin', urlconf='smarter.apps.llmtool.api.v1.urls', description="The {plural}' REST reads.", resources=None, tag_name=None, mount=None),
    ApiFamily(name='provider', resource='Provider', urlconf='smarter.apps.provider.api.v1.urls', description="The LLM {plural}' REST reads, and their models.", resources=None, tag_name=None, mount=None),
    ApiFamily(name='proxy', resource='Proxy', urlconf='smarter.apps.proxy.api.v1.urls', description='The {plural} that the user may use. Served only when the platform enables {plural} (SMARTER_APP_PROXY_ENABLE).', resources='Proxies', tag_name=None, mount='proxy'),
    ApiFamily(name='account', resource='account', urlconf='smarter.apps.account.api.v1.urls', description='The {plural}, their users and contacts. For superusers.', resources=None, tag_name=None, mount=None),
    ApiFamily(name='history', resource='chat session', urlconf='smarter.apps.prompt.api.v1.urls', description='The {plural}, and their tool calls and plugin usage.', resources=None, tag_name='history', mount='prompts'),
    ApiFamily(name='journal', resource='journal entry', urlconf='smarter.lib.journal.api.v1.urls', description='The Smarter Journal: a record of every journaled request to the Smarter api. For superusers.', resources=None, tag_name='journal', mount=None),
    ApiFamily(name='orchestrator', resource='Orchestrator', urlconf='smarter.apps.orchestrator.api.v1.urls', description="The {plural}' REST reads, for superusers, and their runs, for any user who may read them.", resources=None, tag_name=None, mount=None),
    ApiFamily(name='vectorsearch', resource='Vectorsearch', urlconf='smarter.apps.vectorsearch.api.v1.urls', description="The {plural}' REST reads, for superusers, and their runs, for any user who may read them.", resources=None, tag_name=None, mount=None),
    ApiFamily(name='extension', resource='extension', urlconf='smarter.apps.llmtool.extension.api.v1.urls', description="The {plural}: what every user's account may use, and their management by superusers.", resources=None, tag_name=None, mount=None),
)

The LLMClients’ REST reads, under /api/v1/llm-clients/.

Their chat api is in smarter.apps.api.v1.contract.openapi.chat.

smarter.apps.api.v1.contract.openapi.families.llmclient.LLMCLIENTS = ApiFamily(name='llmclient', resource='LLMClient', urlconf='smarter.apps.llmclient.api.v1.urls', description="The {plural}' REST reads.", resources=None, tag_name=None, mount='llm-clients')

its REST reads, and the chat api, whose routes it shares.

Type:

The LLMClients’ family

smarter.apps.api.v1.contract.openapi.families.llmclient.LLMCLIENT_ID_PARAMETER = OpenApiParameter(name='id', in_='path', description="The LLMClient's numeric id, e.g. 12, or its hashed id, e.g. rMTAwMDAxMgx.", required=True, schema_={'type': 'string'})

its numeric id or its hashed id.

Type:

The {id} of an LLMClient’s routes

smarter.apps.api.v1.contract.openapi.families.llmclient.llmclient_paths()[source]

The REST reads of the LLMClients, relative to the server’s /api/v1.

An LLMClient is read by its numeric id or its hashed id. Its related rows, by its numeric id only: their routes take no hashed id.

Returns:

The paths, e.g. {"/llm-clients/": ...}.

Return type:

dict[str, OpenApiPathItem]

The Guardrails’ REST reads, and the dry run of a Guardrail, under /api/v1/guardrails/.

smarter.apps.api.v1.contract.openapi.families.guardrail.GUARDRAILS = ApiFamily(name='guardrail', resource='Guardrail', urlconf='smarter.apps.guardrail.api.v1.urls', description="The {plural}' REST reads, and their dry run.", resources=None, tag_name=None, mount=None)

The Guardrails’ family.

smarter.apps.api.v1.contract.openapi.families.guardrail.guardrail_paths()[source]

The Guardrails’ REST reads, and the dry run of a Guardrail, relative to the server’s /api/v1.

Returns:

The paths, e.g. {"/guardrails/": ...}.

Return type:

dict[str, OpenApiPathItem]

The Secrets’ REST reads, under /api/v1/secrets/: their metadata, never their values.

smarter.apps.api.v1.contract.openapi.families.secret.SECRETS = ApiFamily(name='secret', resource='Secret', urlconf='smarter.apps.secret.api.v1.urls', description="The {plural}' REST reads: their metadata, never their values.", resources=None, tag_name=None, mount=None)

The Secrets’ family.

smarter.apps.api.v1.contract.openapi.families.secret.secret_paths()[source]

The Secrets’ REST reads, relative to the server’s /api/v1.

A Secret’s value is never returned.

Returns:

The paths, e.g. {"/secrets/": ...}.

Return type:

dict[str, OpenApiPathItem]

The MCPClients’ REST reads, their reconnection, and the call of a tool, under /api/v1/mcpclients/.

smarter.apps.api.v1.contract.openapi.families.mcpclient.MCPCLIENTS = ApiFamily(name='mcpclient', resource='MCPClient', urlconf='smarter.apps.mcpclient.api.v1.urls', description="The {plural}' REST reads, their reconnection, and tool calls.", resources=None, tag_name=None, mount=None)

The MCPClients’ family.

smarter.apps.api.v1.contract.openapi.families.mcpclient.mcpclient_paths()[source]

The MCPClients’ REST reads, their reconnection, and the call of a tool, relative to the server’s /api/v1.

Returns:

The paths, e.g. {"/mcpclients/": ...}.

Return type:

dict[str, OpenApiPathItem]

The vectorstores’ REST reads, search, documents and maintenance, under /api/v1/vectorstores/.

smarter.apps.api.v1.contract.openapi.families.vectorstore.VECTORSTORES = ApiFamily(name='vectorstore', resource='vectorstore', urlconf='smarter.apps.vectorstore.api.v1.urls', description="The {plural}' REST reads, search, documents and maintenance. Served only when the platform enables {plural} (SMARTER_APP_VECTORSTORE_ENABLE).", resources=None, tag_name=None, mount=None)

The vectorstores’ family.

Its resource is its app’s name: the descriptions write it in lowercase.

smarter.apps.api.v1.contract.openapi.families.vectorstore.vectorstore_paths()[source]

The vectorstores’ REST reads and maintenance, relative to the server’s /api/v1.

Reading and searching need read permission. Everything else needs ownership.

Returns:

The paths, e.g. {"/vectorstores/": ...}.

Return type:

dict[str, OpenApiPathItem]

The LLMHosts’ REST reads, model discovery and deployment, under /api/v1/llmhosts/.

smarter.apps.api.v1.contract.openapi.families.llmhost.LLMHOSTS = ApiFamily(name='llmhost', resource='LLMHost', urlconf='smarter.apps.llmhost.api.v1.urls', description="The {plural}' REST reads, model discovery, and deployment.", resources=None, tag_name=None, mount=None)

The LLMHosts’ family.

smarter.apps.api.v1.contract.openapi.families.llmhost.llmhost_paths()[source]

The LLMHosts’ REST reads, discovery and deployment, relative to the server’s /api/v1.

Returns:

The paths, e.g. {"/llmhosts/": ...}.

Return type:

dict[str, OpenApiPathItem]

The plugins’ REST reads, under /api/v1/plugins/: the llmtool app’s plugins.

smarter.apps.api.v1.contract.openapi.families.plugin.PLUGINS = ApiFamily(name='plugin', resource='plugin', urlconf='smarter.apps.llmtool.api.v1.urls', description="The {plural}' REST reads.", resources=None, tag_name=None, mount=None)

The plugins’ family.

The llmtool app serves it, but its operations are named after its resource.

smarter.apps.api.v1.contract.openapi.families.plugin.plugin_paths()[source]

The plugins’ REST reads, relative to the server’s /api/v1.

Returns:

The paths, e.g. {"/plugins/": ...}.

Return type:

dict[str, OpenApiPathItem]

The LLM Providers’ REST reads, and their models, under /api/v1/providers/.

smarter.apps.api.v1.contract.openapi.families.provider.PROVIDERS = ApiFamily(name='provider', resource='Provider', urlconf='smarter.apps.provider.api.v1.urls', description="The LLM {plural}' REST reads, and their models.", resources=None, tag_name=None, mount=None)

The Providers’ family.

smarter.apps.api.v1.contract.openapi.families.provider.provider_paths()[source]

The Providers’ REST reads, relative to the server’s /api/v1.

A Provider is read by its name.

Returns:

The paths, e.g. {"/providers/": ...}.

Return type:

dict[str, OpenApiPathItem]

The Proxies’ list, under /api/v1/proxy/.

Their passthroughs are the LLM providers’ own apis.

smarter.apps.api.v1.contract.openapi.families.proxy.PROXIES = ApiFamily(name='proxy', resource='Proxy', urlconf='smarter.apps.proxy.api.v1.urls', description='The {plural} that the user may use. Served only when the platform enables {plural} (SMARTER_APP_PROXY_ENABLE).', resources='Proxies', tag_name=None, mount='proxy')

The Proxies’ family, whose routes are mounted at its app’s name, in the singular.

Its plural is given: inflect adds only an s to a capitalized Proxy.

smarter.apps.api.v1.contract.openapi.families.proxy.proxy_paths()[source]

The Proxies’ list, relative to the server’s /api/v1.

Their passthroughs are the providers’ apis.

Returns:

The paths, e.g. {"/proxy/": ...}.

Return type:

dict[str, OpenApiPathItem]

The accounts’ REST reads, under /api/v1/accounts/, for superusers, and the user’s own token usage and data exports.

smarter.apps.api.v1.contract.openapi.families.account.ACCOUNTS = ApiFamily(name='account', resource='account', urlconf='smarter.apps.account.api.v1.urls', description='The {plural}, their users and contacts. For superusers.', resources=None, tag_name=None, mount=None)

The accounts’ family.

Its routes also serve the user’s own token usage and data exports, tagged TAG_USAGE.

smarter.apps.api.v1.contract.openapi.families.account.OWN_DATA = 'Requires an api key. Every user may call it, for their own data only.'

their token usage and data exports.

Type:

The note of the operations on the requesting user’s own data

smarter.apps.api.v1.contract.openapi.families.account.TAG_USAGE = 'usage'

The tag of the user’s own token usage and data exports, which are not an app’s family, but the account app’s.

smarter.apps.api.v1.contract.openapi.families.account.USAGE_TAG = OpenApiTag(name='usage', description="The user's own token usage and data exports.")

The document’s tag of the user’s own token usage and data exports.

smarter.apps.api.v1.contract.openapi.families.account.account_paths()[source]

The accounts’ REST reads, relative to the server’s /api/v1.

Only superusers may call them. Each of the four resources, the accounts, their users, the user profiles (each user’s membership of an account) and the account contacts, has a list and a retrieve by id.

Returns:

The paths, e.g. {"/accounts/": ...}.

Return type:

dict[str, OpenApiPathItem]

smarter.apps.api.v1.contract.openapi.families.account.usage_paths()[source]

The requesting user’s own token usage and data exports, relative to the server’s /api/v1.

They are under /accounts/, whose other reads are for superusers, but every user may call them.

Returns:

The paths, e.g. {"/accounts/usage/": ...}.

Return type:

dict[str, OpenApiPathItem]

The prompt history’s REST reads, under /api/v1/prompts/history/: the chat sessions, their tool calls and plugin usage.

smarter.apps.api.v1.contract.openapi.families.history.HISTORY = ApiFamily(name='history', resource='chat session', urlconf='smarter.apps.prompt.api.v1.urls', description='The {plural}, and their tool calls and plugin usage.', resources=None, tag_name='history', mount='prompts')

a feature of the prompt app, whose routes are under the app’s /prompts/.

Its operations’ ids and its tag are the feature’s name, history, not the app’s.

Type:

The prompt history’s family

smarter.apps.api.v1.contract.openapi.families.history.HISTORY_PERMISSION = "Requires an api key. The response includes only the chat sessions whose user the user may manage: their own, their account's users' for an account admin, and every one for a superuser."

The note of the prompt history’s reads.

smarter.apps.api.v1.contract.openapi.families.history.history_paths()[source]

The prompt history’s REST reads, relative to the server’s /api/v1, newest first.

Returns:

The paths, e.g. {"/prompts/history/prompt/": ...}.

Return type:

dict[str, OpenApiPathItem]

The Smarter Journal’s REST reads, under /api/v1/journal/: a record of every journaled request to the Smarter api.

smarter.apps.api.v1.contract.openapi.families.journal.JOURNAL = ApiFamily(name='journal', resource='journal entry', urlconf='smarter.lib.journal.api.v1.urls', description='The Smarter Journal: a record of every journaled request to the Smarter api. For superusers.', resources=None, tag_name='journal', mount=None)

The Smarter Journal’s family, whose tag, and so its routes, are its name, in the singular.

smarter.apps.api.v1.contract.openapi.families.journal.journal_paths()[source]

The Smarter Journal’s REST reads, relative to the server’s /api/v1.

Only superusers may call them.

Returns:

The paths, e.g. {"/journal/": ...}.

Return type:

dict[str, OpenApiPathItem]

The Orchestrators’ REST reads, under /api/v1/orchestrators/, and their runs.

The reads are for superusers. Any user may start a run of an Orchestrator that they may read, and read the runs that they started (ADR-037).

smarter.apps.api.v1.contract.openapi.families.orchestrator.ORCHESTRATORS = ApiFamily(name='orchestrator', resource='Orchestrator', urlconf='smarter.apps.orchestrator.api.v1.urls', description="The {plural}' REST reads, for superusers, and their runs, for any user who may read them.", resources=None, tag_name=None, mount=None)

The Orchestrators’ family.

smarter.apps.api.v1.contract.openapi.families.orchestrator.orchestrator_paths()[source]

The Orchestrators’ REST reads, relative to the server’s /api/v1.

Only superusers may call them.

Returns:

The paths, e.g. {"/orchestrators/": ...}.

Return type:

dict[str, OpenApiPathItem]

The Vectorsearches’ REST reads, for superusers, and the run of a Vectorsearch, under /api/v1/vectorsearches/.

smarter.apps.api.v1.contract.openapi.families.vectorsearch.VECTORSEARCHES = ApiFamily(name='vectorsearch', resource='Vectorsearch', urlconf='smarter.apps.vectorsearch.api.v1.urls', description="The {plural}' REST reads, for superusers, and their runs, for any user who may read them.", resources=None, tag_name=None, mount=None)

The Vectorsearches’ family.

smarter.apps.api.v1.contract.openapi.families.vectorsearch.vectorsearch_paths()[source]

The Vectorsearches’ REST reads, and the run of a Vectorsearch, relative to the server’s /api/v1.

Only superusers may read them. Any user who may read a Vectorsearch may run it.

Returns:

The paths, e.g. {"/vectorsearches/": ...}.

Return type:

dict[str, OpenApiPathItem]

The extensions’ REST reads and actions, under /api/v1/extensions/: what the web console’s Extensions pages do.

Every user may read the extensions that their account may use. Only superusers may act on them.

smarter.apps.api.v1.contract.openapi.families.extension.EXTENSIONS = ApiFamily(name='extension', resource='extension', urlconf='smarter.apps.llmtool.extension.api.v1.urls', description="The {plural}: what every user's account may use, and their management by superusers.", resources=None, tag_name=None, mount=None)

The extensions’ family.

Its resource is its name: the descriptions write it in lowercase.

smarter.apps.api.v1.contract.openapi.families.extension.EXTENSION_ACTION = 'Only superusers may call it: others get a 403.'

The note of the extensions’ actions.

smarter.apps.api.v1.contract.openapi.families.extension.EXTENSION_READ = "Requires an api key. A user who is not a superuser sees only the extensions that their account may use, and receives their settings, the accounts that may use them and the platform admin's Secrets as empty lists, and who installed each version as null."

The note of the extensions’ reads.

smarter.apps.api.v1.contract.openapi.families.extension.extension_paths()[source]

The extensions’ REST reads and actions, relative to the server’s /api/v1.

They are what the web console’s Extensions pages do. Every user may read the extensions that their account may use. Only superusers may act on them.

Returns:

The paths, e.g. {"/extensions/": ...}.

Return type:

dict[str, OpenApiPathItem]

The Smarter api’s OpenAPI document, GET /api/v1/openapi.json.

The document is the committed openapi.json of smarter.apps.api.v1.contract: the typed OpenAPI 3.1 contract of the cli api, the chat api and the REST reads, from which clients and SDKs are generated. The web console’s OpenAPI page renders it with Scalar, and /docs/openapi.json, its earlier address, redirects here.

It is public: the document describes the api, and holds no data.

class smarter.apps.api.v1.contract.views.ApiV1OpenApiJsonView(**kwargs)[source]

The Smarter api’s OpenAPI 3.1 document, as JSON.

get(request, *args, **kwargs)[source]

Return the document.

Parameters:

request (HttpRequest) – The request.

Returns:

The document, indented, as JSON.

smarter.apps.api.v1.contract.views.openapi_document(request)[source]

The committed OpenAPI document, whose first server is the platform that serves it.

The committed document’s servers are the default platform’s and a local one. This platform’s own /api/v1, relative to the document’s url, is added before them, so that a viewer’s requests, e.g. Scalar’s “Test Request”, go to the platform that the reader is on.

Parameters:

request (HttpRequest) – The request for the document.

Returns:

The document.

Return type:

dict[str, Any]

Pydantic models of the account data that the REST api’s responses include.

A resource that a user owns, e.g. an LLMClient or a plugin, is returned with its owner, as AccountApiUserProfile: the owner’s username and email, and their account’s number. It is the output of smarter.apps.account.serializers.UserProfileSerializer, which the REST api returned before it was modeled, and which clients already read.

The accounts’ REST api (/api/v1/accounts/), which only superusers may call, returns accounts (AccountApiAccountDetail), users (AccountApiUserDetail), user profiles (AccountApiProfile) and account contacts (AccountApiContact): the outputs of smarter.apps.account.serializers.AccountSerializer, UserSerializer and AccountContactSerializer, which clients already read.

The models forbid extra fields: the api returns exactly what they declare.

smarter.apps.account.contract.models.ACCOUNT_API_MODELS = (<class 'smarter.apps.account.contract.models.AccountApiAccountDetail'>, <class 'smarter.apps.account.contract.models.AccountApiUserDetail'>, <class 'smarter.apps.account.contract.models.AccountApiProfile'>, <class 'smarter.apps.account.contract.models.AccountApiContact'>)

The models whose JSON Schemas the Smarter api’s OpenAPI document includes.

(
    <class 'smarter.apps.account.contract.models.AccountApiAccountDetail'>,
    <class 'smarter.apps.account.contract.models.AccountApiUserDetail'>,
    <class 'smarter.apps.account.contract.models.AccountApiProfile'>,
    <class 'smarter.apps.account.contract.models.AccountApiContact'>,
)
class smarter.apps.account.contract.models.AccountApiAccount(*, accountNumber)[source]

Bases: AccountApiModel

An account, as the owner of a resource: a smarter.apps.account.models.Account’s number.

account_number: str
classmethod from_model(account)[source]

The contract’s model of an account.

Parameters:

account (Account) – The row.

Returns:

The model.

Return type:

AccountApiAccount

Raises:

ValueError – when the account has no account number.

model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

class smarter.apps.account.contract.models.AccountApiAccountDetail(*, id, hashedId, createdAt=None, updatedAt=None, name, description=None, version=None, tags=<factory>, annotations=None, accountNumber=None, isDefaultAccount, companyName, phoneNumber=None, address1=None, address2=None, city=None, state=None, postalCode=None, country=None, language=None, timezone=None, currency=None, isActive)[source]

Bases: AccountApiModel

An account: a smarter.apps.account.models.Account.

account_number: str | None
address1: str | None
address2: str | None
annotations: dict[str, str] | None
city: str | None
company_name: str
country: str | None
created_at: datetime | None
currency: str | None
description: str | None
classmethod from_model(account)[source]

The contract’s model of an account.

Parameters:

account (Account) – The row.

Returns:

The model.

Return type:

AccountApiAccountDetail

hashed_id: str
id: int
is_active: bool
is_default_account: bool
language: str | None
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
phone_number: str | None
postal_code: str | None
state: str | None
tags: list[str]
timezone: str | None
updated_at: datetime | None
version: str | None
class smarter.apps.account.contract.models.AccountApiContact(*, id, account, createdAt=None, updatedAt=None, firstName, lastName, email, phone=None, isPrimary, isTest, welcomed, welcomedAt=None, slackInvitedAt=None, unsubscribedAt=None)[source]

Bases: AccountApiModel

A contact of an account, who receives its notices: a smarter.apps.account.models.AccountContact.

account: AccountApiAccount
created_at: datetime | None
email: str
first_name: str
classmethod from_model(contact)[source]

The contract’s model of an account contact.

Parameters:

contact (AccountContact) – The row, whose account should be fetched with it.

Returns:

The model.

Return type:

AccountApiContact

id: int
is_primary: bool
is_test: bool
last_name: str
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

phone: str | None
slack_invited_at: datetime | None
unsubscribed_at: datetime | None
updated_at: datetime | None
welcomed: bool
welcomed_at: datetime | None
class smarter.apps.account.contract.models.AccountApiModel[source]

Bases: BaseModel

Base class of the account contract’s models.

The api’s JSON is camelCase, e.g. accountNumber. The models’ fields are snake_case, and their camelCase aliases are what they validate and dump.

model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

class smarter.apps.account.contract.models.AccountApiProfile(*, id, hashedId, createdAt=None, updatedAt=None, name, description=None, version=None, tags=<factory>, annotations=None, user, account, profileImageUrl=None, profileImage=None, isTest, isAccountAdmin=False)[source]

Bases: AccountApiModel

A user’s membership of an account: a smarter.apps.account.models.UserProfile.

account: AccountApiAccount
annotations: dict[str, str] | None
created_at: datetime | None
description: str | None
classmethod from_model(user_profile)[source]

The contract’s model of a user profile.

Parameters:

user_profile (UserProfile) – The row, whose user and account should be fetched with it.

Returns:

The model.

Return type:

AccountApiProfile

hashed_id: str
id: int
is_account_admin: bool
is_test: bool
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
profile_image: str | None
profile_image_url: str | None
tags: list[str]
updated_at: datetime | None
user: AccountApiUserDetail
version: str | None
class smarter.apps.account.contract.models.AccountApiUser(*, username, email=None)[source]

Bases: AccountApiModel

A user, as the owner of a resource: a django.contrib.auth.models.User’s username and email.

email: str | None
classmethod from_model(user)[source]

The contract’s model of a user.

Parameters:

user (User) – The row.

Returns:

The model.

Return type:

AccountApiUser

model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

username: str
class smarter.apps.account.contract.models.AccountApiUserDetail(*, id, username, firstName='', lastName='', email='', isStaff, isSuperuser)[source]

Bases: AccountApiModel

A user: a django.contrib.auth.models.User, without its password and permissions.

email: str
first_name: str
classmethod from_model(user)[source]

The contract’s model of a user.

Parameters:

user (User) – The row.

Returns:

The model.

Return type:

AccountApiUserDetail

id: int
is_staff: bool
is_superuser: bool
last_name: str
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

username: str
class smarter.apps.account.contract.models.AccountApiUserProfile(*, user, account)[source]

Bases: AccountApiModel

The owner of a resource: a smarter.apps.account.models.UserProfile’s user and account.

account: AccountApiAccount
classmethod from_model(user_profile)[source]

The contract’s model of a resource’s owner.

Parameters:

user_profile (UserProfile) – The row, whose user and account should be fetched with it.

Returns:

The model.

Return type:

AccountApiUserProfile

model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

user: AccountApiUser
smarter.apps.account.contract.models.MetaDataApiAnnotations = dict[str, str] | None

a map of keys to string values, as in Kubernetes, e.g.

{"acme.com/crm-account-id": "A-10042"}.

Type:

MetaDataModel.annotations

Pydantic models of the plugin data that the REST api’s responses include.

PluginApiPluginMeta is a plugin’s metadata, as the REST api returns it, e.g. in an LLMClient’s plugins. It is the output of smarter.apps.llmtool.serializers.PluginMetaSerializer, which the REST api returned before it was modeled, and which clients already read: the owner is nested, rather than its id.

The models forbid extra fields: the api returns exactly what they declare.

smarter.apps.llmtool.contract.models.PluginApiPluginClass

the choices of PluginMeta.plugin_class.

A test fails if the two differ.

Type:

A plugin’s class

alias of Literal[‘api’, ‘skill’, ‘sql’, ‘static’, ‘websearch’, ‘imagesearch’]

class smarter.apps.llmtool.contract.models.PluginApiPluginMeta(*, id, createdAt=None, updatedAt=None, name, userProfile, description=None, pluginClass, version=None, annotations=None, tags=<factory>, manifestUrl, ready, kind, canDelete, detailUrl=None)[source]

Bases: AccountApiModel

A plugin’s metadata: a smarter.apps.llmtool.models.PluginMeta.

annotations: dict[str, str] | None
can_delete: bool
created_at: datetime | None
description: str | None
detail_url: str | None
classmethod from_model(plugin_meta, user=None)[source]

The contract’s model of a plugin’s metadata.

Parameters:
  • plugin_meta (PluginMeta) – The row, whose user_profile and tags should be fetched with it.

  • user (object) – The requesting user, for can_delete. None may delete nothing.

Returns:

The model.

Return type:

PluginApiPluginMeta

id: int
kind: str
manifest_url: str
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
plugin_class: Literal['api', 'skill', 'sql', 'static', 'websearch', 'imagesearch']
ready: bool
tags: list[str]
updated_at: datetime | None
user_profile: AccountApiUserProfile
version: str | None

Pydantic models of the LLMClients’ REST api responses (/api/v1/llm-clients/).

The REST api’s views build their responses from these models, and the Smarter api’s OpenAPI document (smarter.apps.api.v1.contract.openapi) publishes their JSON Schemas. Each model is built from its row by from_model().

They describe the JSON that smarter.apps.llmclient.serializers produced before the api was modeled, which clients already read: camelCase keys, an LLMClient’s owner nested rather than its id, and an LLMClient’s related rows inline. Two values changed: canDelete is computed for the requesting user, where the serializers, called without a request, always said false, and an api key’s apiKey is its token’s public key_id, where it was the token’s digest.

The models forbid extra fields: the api returns exactly what they declare. Adding a field is backward compatible. Removing or renaming one is not.

smarter.apps.llmclient.contract.models.LLMCLIENT_API_MODELS = (<class 'smarter.apps.llmclient.contract.models.LLMClientApiLLMClient'>, <class 'smarter.apps.llmclient.contract.models.LLMClientApiPlugin'>, <class 'smarter.apps.llmclient.contract.models.LLMClientApiExtension'>, <class 'smarter.apps.llmclient.contract.models.LLMClientApiKey'>, <class 'smarter.apps.llmclient.contract.models.LLMClientApiCustomDomain'>)

The models whose JSON Schemas the Smarter api’s OpenAPI document includes.

Their dependencies are included with them.

(
    <class 'smarter.apps.llmclient.contract.models.LLMClientApiLLMClient'>,
    <class 'smarter.apps.llmclient.contract.models.LLMClientApiPlugin'>,
    <class 'smarter.apps.llmclient.contract.models.LLMClientApiExtension'>,
    <class 'smarter.apps.llmclient.contract.models.LLMClientApiKey'>,
    <class 'smarter.apps.llmclient.contract.models.LLMClientApiCustomDomain'>,
)
class smarter.apps.llmclient.contract.models.LLMClientApiCustomDomain(*, id, createdAt=None, updatedAt=None, name, description=None, version=None, annotations=None, userProfile, awsHostedZoneId, domainName, verificationStatus, verifiedAt=None, verificationMessage)[source]

Bases: LLMClientApiOrmModel

A custom domain of an LLMClient: a smarter.apps.llmclient.models.LLMClientCustomDomain.

annotations: dict[str, str] | None
aws_hosted_zone_id: str
description: str | None
domain_name: str
classmethod from_model(custom_domain)[source]

The contract’s model of a custom domain.

Parameters:

custom_domain (LLMClientCustomDomain) – The row.

Returns:

The model.

Return type:

LLMClientApiCustomDomain

model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
user_profile: int
verification_message: str
verification_status: Literal['Not Verified', 'Verifying', 'Verified', 'Failed']
verified_at: datetime | None
version: str | None
smarter.apps.llmclient.contract.models.LLMClientApiDnsVerificationStatus

The choices of LLMClient.dns_verification_status.

A test fails if the two differ.

alias of Literal[‘Verifying’, ‘Not Verified’, ‘Verified’, ‘Failed’]

class smarter.apps.llmclient.contract.models.LLMClientApiExtension(*, id, createdAt=None, updatedAt=None, name, extension, llmclient)[source]

Bases: LLMClientApiOrmModel

An extension of an LLMClient: a smarter.apps.llmclient.models.LLMClientExtensions.

extension: int
classmethod from_model(link)[source]

The contract’s model of an extension of an LLMClient.

Parameters:

link (LLMClientExtensions) – The row, whose extension should be fetched with it.

Returns:

The model.

Return type:

LLMClientApiExtension

llmclient: int
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
class smarter.apps.llmclient.contract.models.LLMClientApiGuardrailRef(*, id, name)[source]

Bases: AccountApiModel

A Guardrail of an LLMClient, in the LLMClient’s own response: the LLMClientGuardrails’ id, and the Guardrail’s name.

classmethod from_model(link)[source]

The contract’s reference to a Guardrail of an LLMClient.

Parameters:

link (LLMClientGuardrails) – The row, whose guardrail should be fetched with it.

Returns:

The model.

Return type:

LLMClientApiGuardrailRef

id: int
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
class smarter.apps.llmclient.contract.models.LLMClientApiKey(*, id, createdAt=None, updatedAt=None, llmclient, apiKey)[source]

Bases: LLMClientApiOrmModel

An api key of an LLMClient: a smarter.apps.llmclient.models.LLMClientAPIKey.

api_key: UUID
classmethod from_model(api_key)[source]

The contract’s model of an api key of an LLMClient.

Parameters:

api_key (LLMClientAPIKey) – The row, whose api_key should be fetched with it.

Returns:

The model.

Return type:

LLMClientApiKey

llmclient: int
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

class smarter.apps.llmclient.contract.models.LLMClientApiLLMClient(*, id, createdAt=None, updatedAt=None, hashedId, name, description=None, version=None, tags=<factory>, annotations=None, userProfile, canDelete, detailUrl=None, extensions, plugins, mcpclients, vectorsearches, guardrails, tools, customDomains, apiKeys, rfc1034CompliantName=None, defaultSystemRole=None, baseApiDomain=None, baseDefaultHost=None, defaultHost=None, defaultUrl=None, customHost=None, customUrl=None, sandboxHost=None, sandboxUrl=None, manifestUrl=None, hostname=None, url=None, urlLlmclient=None, urlChatConfig=None, urlChatapp=None, ready, isAuthenticationRequired, deployed=None, provider=None, defaultModel=None, defaultTemperature=None, defaultReasoningEffort=None, defaultMaxTokens=None, appName=None, appAssistant=None, appWelcomeMessage=None, appExamplePrompts=None, appPlaceholder=None, appInfoUrl=None, appFileAttachment=None, styles=None, allowedOrigins, staffOnly, dnsVerificationStatus=None, tlsCertificateIssuanceStatus=None, subdomain=None, customDomain=None)[source]

Bases: LLMClientApiOrmModel

An LLMClient: a smarter.apps.llmclient.models.LLMClient, with its related rows and its urls.

Its extensions, plugins, custom_domains and api_keys are inline, and its urls and hosts are computed, as the LLMClient’s properties compute them for the platform that serves the request.

allowed_origins: list[str]
annotations: dict[str, str] | None
api_keys: list[LLMClientApiKey]
app_assistant: str | None
app_example_prompts: list[str] | None
app_file_attachment: bool | None
app_info_url: str | None
app_name: str | None
app_placeholder: str | None
app_welcome_message: str | None
base_api_domain: str | None
base_default_host: str | None
can_delete: bool
custom_domain: int | None
custom_domains: list[LLMClientApiCustomDomain]
custom_host: str | None
custom_url: str | None
default_host: str | None
default_max_tokens: int | None
default_model: str | None
default_reasoning_effort: Literal['none', 'minimal', 'low', 'medium', 'high', 'xhigh'] | None
default_system_role: str | None
default_temperature: float | None
default_url: str | None
deployed: bool | None
description: str | None
detail_url: str | None
dns_verification_status: Literal['Verifying', 'Not Verified', 'Verified', 'Failed'] | None
extensions: list[LLMClientApiExtension]
classmethod from_model(llmclient, user=None)[source]

The contract’s model of an LLMClient.

Parameters:
  • llmclient (LLMClient) – The row, whose user_profile should be fetched with it.

  • user (object) – The requesting user, for can_delete. None may delete nothing.

Returns:

The model.

Return type:

LLMClientApiLLMClient

guardrails: list[LLMClientApiGuardrailRef]
hashed_id: str
hostname: str | None
is_authentication_required: bool
manifest_url: str | None
mcpclients: list[LLMClientApiMCPClientRef]
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
plugins: list[LLMClientApiPluginRef]
provider: str | None
ready: bool
rfc1034_compliant_name: str | None
sandbox_host: str | None
sandbox_url: str | None
staff_only: bool
styles: dict[str, JsonValue] | None
subdomain: int | None
tags: list[str]
tls_certificate_issuance_status: Literal['No Certificate', 'Requested', 'Issued', 'Failed'] | None
tools: list[LLMClientApiTool]
url: str | None
url_chat_config: str | None
url_chatapp: str | None
url_llmclient: str | None
user_profile: AccountApiUserProfile
vectorsearches: list[LLMClientApiVectorsearchRef]
version: str | None
class smarter.apps.llmclient.contract.models.LLMClientApiMCPClientRef(*, id, name)[source]

Bases: AccountApiModel

An MCPClient of an LLMClient, in the LLMClient’s own response: the LLMClientMCPClients’ id, and the MCPClient’s name.

classmethod from_model(link)[source]

The contract’s reference to an MCPClient of an LLMClient.

Parameters:

link (LLMClientMCPClients) – The row, whose mcpclient should be fetched with it.

Returns:

The model.

Return type:

LLMClientApiMCPClientRef

id: int
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
class smarter.apps.llmclient.contract.models.LLMClientApiOrmModel(*, id, createdAt=None, updatedAt=None)[source]

Bases: AccountApiModel

Base class of the models of LLMClient rows: their primary key and timestamps.

created_at: datetime | None
id: int
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

updated_at: datetime | None
class smarter.apps.llmclient.contract.models.LLMClientApiPlugin(*, id, createdAt=None, updatedAt=None, pluginMeta, llmclient)[source]

Bases: LLMClientApiOrmModel

A plugin of an LLMClient: a smarter.apps.llmclient.models.LLMClientPlugin, with the plugin’s metadata.

classmethod from_model(plugin, user=None)[source]

The contract’s model of a plugin of an LLMClient.

Parameters:
  • plugin (LLMClientPlugin) – The row, whose plugin_meta should be fetched with it.

  • user (object) – The requesting user, for the plugin’s canDelete.

Returns:

The model.

Return type:

LLMClientApiPlugin

llmclient: int
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

plugin_meta: PluginApiPluginMeta
class smarter.apps.llmclient.contract.models.LLMClientApiPluginRef(*, id, name)[source]

Bases: AccountApiModel

A plugin of an LLMClient, in the LLMClient’s own response: the LLMClientPlugin’s id, and the plugin’s name.

classmethod from_model(plugin)[source]

The contract’s reference to a plugin of an LLMClient.

Parameters:

plugin (LLMClientPlugin) – The row, whose plugin_meta should be fetched with it.

Returns:

The model.

Return type:

LLMClientApiPluginRef

id: int
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
smarter.apps.llmclient.contract.models.LLMClientApiTlsCertificateIssuanceStatus

The choices of LLMClient.tls_certificate_issuance_status.

A test fails if the two differ.

alias of Literal[‘No Certificate’, ‘Requested’, ‘Issued’, ‘Failed’]

class smarter.apps.llmclient.contract.models.LLMClientApiTool(*, id, name, kind)[source]

Bases: AccountApiModel

Something that an LLMClient adds to a prompt: an extension, plugin, MCPClient, Vectorsearch or guardrail.

id: int
kind: Literal['Extension', 'Plugin', 'MCPClient', 'Vectorsearch', 'Guardrail']
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
smarter.apps.llmclient.contract.models.LLMClientApiToolKind

an extension, or the linked resource’s manifest kind.

Type:

What adds a tool to an LLMClient’s prompts

alias of Literal[‘Extension’, ‘Plugin’, ‘MCPClient’, ‘Vectorsearch’, ‘Guardrail’]

smarter.apps.llmclient.contract.models.LLMClientApiVerificationStatus

The choices of LLMClientCustomDomain.verification_status.

A test fails if the two differ.

alias of Literal[‘Not Verified’, ‘Verifying’, ‘Verified’, ‘Failed’]

Pydantic models of the Guardrails’ REST api requests and responses (/api/v1/guardrails/).

The REST api’s views build their responses from these models, and the Smarter api’s OpenAPI document (smarter.apps.api.v1.contract.openapi) publishes their JSON Schemas.

GuardrailApiGuardrail is a Guardrail, as smarter.apps.guardrail.serializers.GuardrailSerializer returned it before the api was modeled, and GuardrailApiEvent an event, as GuardrailEventSerializer returned it. Clients already read them, so their shapes are kept: a Guardrail’s keys are camelCase, and an event’s snake_case. One value changed: a Guardrail’s canDelete is computed for the requesting user. The serializer was called without a request, so it was always false.

The models forbid extra fields: the api returns exactly what they declare.

smarter.apps.guardrail.contract.models.GUARDRAIL_API_MODELS = (<class 'smarter.apps.guardrail.contract.models.GuardrailApiGuardrail'>, <class 'smarter.apps.guardrail.contract.models.GuardrailApiEvents'>, <class 'smarter.apps.guardrail.contract.models.GuardrailApiEvaluateRequest'>, <class 'smarter.apps.guardrail.contract.models.GuardrailApiEvaluation'>)

The models whose JSON Schemas the Smarter api’s OpenAPI document includes.

Their dependencies are included with them.

(
    <class 'smarter.apps.guardrail.contract.models.GuardrailApiGuardrail'>,
    <class 'smarter.apps.guardrail.contract.models.GuardrailApiEvents'>,
    <class 'smarter.apps.guardrail.contract.models.GuardrailApiEvaluateRequest'>,
    <class 'smarter.apps.guardrail.contract.models.GuardrailApiEvaluation'>,
)
smarter.apps.guardrail.contract.models.GuardrailApiAction

The choices of Guardrail.action.

A test fails if the two differ.

alias of Literal[‘log’, ‘flag’, ‘redact’, ‘transform’, ‘block’, ‘escalate’]

smarter.apps.guardrail.contract.models.GuardrailApiCategory

The choices of Guardrail.category.

A test fails if the two differ.

alias of Literal[‘pii’, ‘secrets’, ‘prompt_injection’, ‘jailbreak’, ‘toxicity’, ‘self_harm’, ‘hallucination’, ‘off_topic’, ‘compliance’, ‘formatting’, ‘custom’]

class smarter.apps.guardrail.contract.models.GuardrailApiEvaluateRequest(*, text, stage='input')[source]

Bases: GuardrailApiSnakeModel

The request body of a dry run of a Guardrail on a text.

model_config = {'extra': 'forbid'}

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

stage: Literal['input', 'output']
text: str
class smarter.apps.guardrail.contract.models.GuardrailApiEvaluation(*, guardrail, stage, triggered, disposition, text, message=None, error=None, durationMs=None, findings)[source]

Bases: AccountApiModel

The result of a dry run of a Guardrail on a text.

It records no events.

disposition: PipelineDisposition
duration_ms: float | None
error: str | None
findings: list[GuardrailApiFinding]
guardrail: str
message: str | None
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

stage: Literal['input', 'output']
text: str
triggered: bool
class smarter.apps.guardrail.contract.models.GuardrailApiEvent(*, id, created_at=None, updated_at=None, guardrail=None, guardrail_name, llmclient=None, session_key=None, stage, category, strategy, action, mode, disposition, severity, confidence=None, excerpt=None, rationale=None, error=None, reviewed)[source]

Bases: GuardrailApiSnakeModel

A Guardrail’s event: a smarter.apps.guardrail.models.GuardrailEvent, a record of what it did to a prompt.

Its keys are snake_case: the serializer that the api used was not camelCase.

action: Literal['log', 'flag', 'redact', 'transform', 'block', 'escalate']
category: Literal['pii', 'secrets', 'prompt_injection', 'jailbreak', 'toxicity', 'self_harm', 'hallucination', 'off_topic', 'compliance', 'formatting', 'custom']
confidence: float | None
created_at: datetime | None
disposition: Literal['logged', 'flagged', 'redacted', 'transformed', 'blocked', 'escalated', 'monitored', 'error']
error: str | None
excerpt: str | None
classmethod from_model(event)[source]

The contract’s model of a Guardrail’s event.

Parameters:

event (GuardrailEvent) – The row, whose llmclient should be fetched with it.

Returns:

The model.

Return type:

GuardrailApiEvent

guardrail: int | None
guardrail_name: str
id: int
llmclient: str | None
mode: Literal['enforce', 'monitor']
model_config = {'extra': 'forbid'}

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

rationale: str | None
reviewed: bool
session_key: str | None
severity: int
stage: Literal['input', 'output', 'both']
strategy: Literal['regex', 'keyword', 'detector', 'semantic', 'moderation', 'llm_judge']
updated_at: datetime | None
smarter.apps.guardrail.contract.models.GuardrailApiEventDisposition

what a guardrail did.

A test fails if the two differ.

Type:

The choices of GuardrailEvent.disposition

alias of Literal[‘logged’, ‘flagged’, ‘redacted’, ‘transformed’, ‘blocked’, ‘escalated’, ‘monitored’, ‘error’]

class smarter.apps.guardrail.contract.models.GuardrailApiEvents(*, guardrail, events)[source]

Bases: GuardrailApiSnakeModel

The response of a Guardrail’s events: its name, and its latest events, newest first.

events: list[GuardrailApiEvent]
guardrail: str
model_config = {'extra': 'forbid'}

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

class smarter.apps.guardrail.contract.models.GuardrailApiFinding(*, confidence=None, rationale=None, matches)[source]

Bases: GuardrailApiSnakeModel

What a Guardrail found in a text.

confidence: float | None
matches: list[GuardrailMatch]
model_config = {'extra': 'forbid'}

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

rationale: str | None
class smarter.apps.guardrail.contract.models.GuardrailApiGuardrail(*, id, hashedId, createdAt=None, updatedAt=None, name, description=None, version=None, tags=<factory>, annotations=None, userProfile, canDelete, manifestUrl, detailUrl=None, ready, rfc1034CompliantName=None, stage, category, strategy, pattern=None, config=None, threshold=None, action, replacement=None, message=None, severity, mode, failClosed, priority, isActive)[source]

Bases: AccountApiModel

A Guardrail: a smarter.apps.guardrail.models.Guardrail.

action: Literal['log', 'flag', 'redact', 'transform', 'block', 'escalate']
annotations: dict[str, str] | None
can_delete: bool
category: Literal['pii', 'secrets', 'prompt_injection', 'jailbreak', 'toxicity', 'self_harm', 'hallucination', 'off_topic', 'compliance', 'formatting', 'custom']
config: dict[str, JsonValue] | None
created_at: datetime | None
description: str | None
detail_url: str | None
fail_closed: bool
classmethod from_model(guardrail, user=None)[source]

The contract’s model of a Guardrail.

Parameters:
  • guardrail (Guardrail) – The row, whose user_profile should be fetched with it.

  • user (object) – The requesting user, for can_delete. None may delete nothing.

Returns:

The model.

Return type:

GuardrailApiGuardrail

hashed_id: str
id: int
is_active: bool
manifest_url: str
message: str | None
mode: Literal['enforce', 'monitor']
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
pattern: str | None
priority: int
ready: bool
replacement: str | None
rfc1034_compliant_name: str | None
severity: int
stage: Literal['input', 'output', 'both']
strategy: Literal['regex', 'keyword', 'detector', 'semantic', 'moderation', 'llm_judge']
tags: list[str]
threshold: float | None
updated_at: datetime | None
user_profile: AccountApiUserProfile
version: str | None
smarter.apps.guardrail.contract.models.GuardrailApiMode

The choices of Guardrail.mode.

A test fails if the two differ.

alias of Literal[‘enforce’, ‘monitor’]

class smarter.apps.guardrail.contract.models.GuardrailApiSnakeModel[source]

Bases: BaseModel

Base class of the guardrail contract’s models whose keys are snake_case, as their api returned them.

model_config = {'extra': 'forbid'}

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

smarter.apps.guardrail.contract.models.GuardrailApiStage

The choices of Guardrail.stage.

A test fails if the two differ.

alias of Literal[‘input’, ‘output’, ‘both’]

smarter.apps.guardrail.contract.models.GuardrailApiStrategy

The choices of Guardrail.strategy.

A test fails if the two differ.

alias of Literal[‘regex’, ‘keyword’, ‘detector’, ‘semantic’, ‘moderation’, ‘llm_judge’]

Pydantic models of the Secrets’ REST api responses (/api/v1/secrets/).

A Secret’s response is its metadata. Its value is never returned.

SecretApiSecret is a Secret, as smarter.apps.secret.serializers.SecretSerializer returned it before the api was modeled, which clients already read. One value changed: its canDelete is computed for the requesting user. The serializer was called without a request, so it was always false.

smarter.apps.secret.contract.models.SECRET_API_MODELS = (<class 'smarter.apps.secret.contract.models.SecretApiSecret'>,)

The models whose JSON Schemas the Smarter api’s OpenAPI document includes.

(<class 'smarter.apps.secret.contract.models.SecretApiSecret'>, )
class smarter.apps.secret.contract.models.SecretApiSecret(*, id, createdAt=None, updatedAt=None, name, userProfile, description=None, version=None, annotations=None, tags=<factory>, manifestUrl=None, detailUrl=None, ready, expiresAt=None, lastAccessed=None, canDelete)[source]

Bases: AccountApiModel

A Secret’s metadata: a smarter.apps.secret.models.Secret, without its value.

annotations: dict[str, str] | None
can_delete: bool
created_at: datetime | None
description: str | None
detail_url: str | None
expires_at: datetime | None
classmethod from_model(secret, user=None)[source]

The contract’s model of a Secret.

Parameters:
  • secret (Secret) – The row, whose user_profile should be fetched with it.

  • user (object) – The requesting user, for can_delete. None may delete nothing.

Returns:

The model.

Return type:

SecretApiSecret

id: int
last_accessed: datetime | None
manifest_url: str | None
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
ready: bool
tags: list[str]
updated_at: datetime | None
user_profile: AccountApiUserProfile
version: str | None
class smarter.apps.secret.contract.models.SecretApiSecretRef(*, id, name, manifestUrl=None, detailUrl=None, ready, canDelete)[source]

Bases: AccountApiModel

A Secret, as another resource refers to it, e.g. a Provider’s api key: its name, never its value.

can_delete: bool
detail_url: str | None
classmethod from_model(secret, user=None)[source]

The contract’s reference to a Secret.

Parameters:
  • secret (Secret) – The row.

  • user (object) – The requesting user, for can_delete.

Returns:

The model.

Return type:

SecretApiSecretRef

id: int
manifest_url: str | None
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
ready: bool

Pydantic models of the MCPClients’ REST api responses (/api/v1/mcpclients/).

The REST api’s views build their responses from these models, and the Smarter api’s OpenAPI document (smarter.apps.api.v1.contract.openapi) publishes their JSON Schemas.

MCPClientApiMCPClient is an MCPClient, as smarter.apps.mcpclient.serializers.MCPClientSerializer returned it before the api was modeled, which clients already read. One value changed: its canDelete is computed for the requesting user. The other models replace the dicts that the views built by hand, with the same keys. lastConnected is now an ISO 8601 date-time ending in Z, where it ended in +00:00: the same instant.

The models forbid extra fields: the api returns exactly what they declare.

smarter.apps.mcpclient.contract.models.MCPCLIENT_API_MODELS = (<class 'smarter.apps.mcpclient.contract.models.MCPClientApiMCPClient'>, <class 'smarter.apps.mcpclient.contract.models.MCPClientApiStatus'>, <class 'smarter.apps.mcpclient.contract.models.MCPClientApiStatusError'>, <class 'smarter.apps.mcpclient.contract.models.MCPClientApiTools'>, <class 'smarter.apps.mcpclient.contract.models.MCPClientApiToolResult'>)

The models whose JSON Schemas the Smarter api’s OpenAPI document includes.

Their dependencies are included with them.

(
    <class 'smarter.apps.mcpclient.contract.models.MCPClientApiMCPClient'>,
    <class 'smarter.apps.mcpclient.contract.models.MCPClientApiStatus'>,
    <class 'smarter.apps.mcpclient.contract.models.MCPClientApiStatusError'>,
    <class 'smarter.apps.mcpclient.contract.models.MCPClientApiTools'>,
    <class 'smarter.apps.mcpclient.contract.models.MCPClientApiToolResult'>,
)
smarter.apps.mcpclient.contract.models.MCPClientApiAuthType

The choices of MCPClient.auth_type.

A test fails if the two differ.

alias of Literal[‘none’, ‘api_key’, ‘oauth2’, ‘bearer_token’]

smarter.apps.mcpclient.contract.models.MCPClientApiConnectionStatus

the result of the last connection.

A test fails if the two differ.

Type:

The choices of MCPClient.status

alias of Literal[‘unconfigured’, ‘connected’, ‘disconnected’, ‘error’]

class smarter.apps.mcpclient.contract.models.MCPClientApiMCPClient(*, id, hashedId, createdAt=None, updatedAt=None, name, description=None, version=None, tags=<factory>, annotations=None, userProfile, canDelete, credentials=None, manifestUrl, detailUrl=None, ready, rfc1034CompliantName=None, transport=None, endpointUrl=None, command=None, headers=None, timeout, authType, apiKeyHeader, allowedTools=None, allowedResources=None, includeInstructions, cacheTtl, isActive, status, priority, protocolVersion=None, serverName=None, serverVersion=None, tools=None, lastConnectedAt=None, lastError=None)[source]

Bases: AccountApiModel

An MCPClient: a smarter.apps.mcpclient.models.MCPClient.

Its credentials are their Secret’s name.

allowed_resources: list[str] | None
allowed_tools: list[str] | None
annotations: dict[str, str] | None
api_key_header: str
auth_type: Literal['none', 'api_key', 'oauth2', 'bearer_token']
cache_ttl: int
can_delete: bool
command: str | None
created_at: datetime | None
credentials: str | None
description: str | None
detail_url: str | None
endpoint_url: str | None
classmethod from_model(mcpclient, user=None)[source]

The contract’s model of an MCPClient.

Parameters:
  • mcpclient (MCPClient) – The row, whose user_profile and credentials should be fetched with it.

  • user (object) – The requesting user, for can_delete. None may delete nothing.

Returns:

The model.

Return type:

MCPClientApiMCPClient

hashed_id: str
headers: dict[str, JsonValue] | None
id: int
include_instructions: bool
is_active: bool
last_connected_at: datetime | None
last_error: str | None
manifest_url: str
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
priority: int
protocol_version: str | None
ready: bool
rfc1034_compliant_name: str | None
server_name: str | None
server_version: str | None
status: Literal['unconfigured', 'connected', 'disconnected', 'error']
tags: list[str]
timeout: int
tools: list[str] | None
transport: Literal['stdio', 'sse', 'http'] | None
updated_at: datetime | None
user_profile: AccountApiUserProfile
version: str | None
class smarter.apps.mcpclient.contract.models.MCPClientApiStatus(*, name, status, protocolVersion=None, serverName=None, serverVersion=None, lastConnected=None, lastError=None, tools)[source]

Bases: AccountApiModel

An MCPClient’s connection to its MCP server: the result of the last connection, and what the server reported.

classmethod from_model(mcpclient)[source]

The connection status of an MCPClient.

Parameters:

mcpclient (MCPClient) – The row.

Returns:

The model.

Return type:

MCPClientApiStatus

last_connected: datetime | None
last_error: str | None
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
protocol_version: str | None
server_name: str | None
server_version: str | None
status: Literal['unconfigured', 'connected', 'disconnected', 'error']
tools: list[str]
class smarter.apps.mcpclient.contract.models.MCPClientApiStatusError(*, name, status, protocolVersion=None, serverName=None, serverVersion=None, lastConnected=None, lastError=None, tools, detail)[source]

Bases: MCPClientApiStatus

A failed connection to an MCP server: the error, beside the MCPClient’s connection status.

detail: str
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

class smarter.apps.mcpclient.contract.models.MCPClientApiTool(*, name, title=None, description='', inputSchema, readOnly=None, destructive=None)[source]

Bases: AccountApiModel

A tool that an MCP server offers, and that the MCPClient allows.

description: str
destructive: bool | None
classmethod from_tool(tool)[source]

The contract’s model of a tool from an MCP server’s catalog.

Parameters:

tool (MCPToolInfo) – The tool.

Returns:

The model.

Return type:

MCPClientApiTool

input_schema: dict[str, JsonValue]
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
read_only: bool | None
title: str | None
class smarter.apps.mcpclient.contract.models.MCPClientApiToolResult(*, name, tool, isError, content)[source]

Bases: AccountApiModel

The result of a call of an MCPClient’s tool, as text for an LLM.

content: str
classmethod from_result(mcpclient, tool, result)[source]

The contract’s model of a tool call’s result.

Parameters:
Returns:

The model.

Return type:

MCPClientApiToolResult

is_error: bool
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
tool: str
class smarter.apps.mcpclient.contract.models.MCPClientApiTools(*, name, status, protocolVersion=None, serverName=None, serverVersion=None, lastConnected=None, lastError=None, instructions=None, tools)[source]

Bases: AccountApiModel

An MCPClient’s connection status, its server’s instructions, and the tools that it offers the LLM.

classmethod from_catalog(mcpclient, catalog, tools)[source]

The tools of an MCPClient, from its server’s catalog.

Parameters:
Returns:

The model.

Return type:

MCPClientApiTools

instructions: str | None
last_connected: datetime | None
last_error: str | None
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
protocol_version: str | None
server_name: str | None
server_version: str | None
status: Literal['unconfigured', 'connected', 'disconnected', 'error']
tools: list[MCPClientApiTool]
smarter.apps.mcpclient.contract.models.MCPClientApiTransport

The choices of MCPClient.transport.

A test fails if the two differ.

alias of Literal[‘stdio’, ‘sse’, ‘http’]

Pydantic models of the vectorstores’ REST api requests and responses (/api/v1/vectorstores/).

The REST api’s views build their responses from these models, and the Smarter api’s OpenAPI document (smarter.apps.api.v1.contract.openapi) publishes their JSON Schemas.

VectorstoreApiVectorstore, VectorstoreApiDocument and VectorstoreApiSnapshot are the rows, as smarter.apps.vectorstore.serializers returned them before the api was modeled, which clients already read. One value changed: a vectorstore’s canDelete is computed for the requesting user. The serializer was called without a request, so it was always false. The other models replace the dicts that the views built by hand, with the same keys.

The models forbid extra fields: the api returns exactly what they declare.

smarter.apps.vectorstore.contract.models.VECTORSTORE_API_MODELS = (<class 'smarter.apps.vectorstore.contract.models.VectorstoreApiVectorstore'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiStatus'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiDocuments'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiAddText'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiDocumentsAdded'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiDocumentDeleted'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiSearch'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiSearchResults'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiSnapshot'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiSnapshots'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiRestored'>)

The models whose JSON Schemas the Smarter api’s OpenAPI document includes.

Their dependencies are included with them.

(
    <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiVectorstore'>,
    <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiStatus'>,
    <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiDocuments'>,
    <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiAddText'>,
    <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiDocumentsAdded'>,
    <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiDocumentDeleted'>,
    <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiSearch'>,
    <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiSearchResults'>,
    <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiSnapshot'>,
    <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiSnapshots'>,
    <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiRestored'>,
)
class smarter.apps.vectorstore.contract.models.VectorstoreApiAddText(*, name=None, text=None, url=None, metadata=None)[source]

Bases: AccountApiModel

The JSON request body that adds a text, or the document at a url, to a vectorstore.

Files are multipart/form-data.

metadata: dict[str, JsonValue] | None
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str | None
text: str | None
url: str | None
smarter.apps.vectorstore.contract.models.VectorstoreApiBackend

The choices of VectorstoreMeta.backend.

A test fails if the two differ.

alias of Literal[‘qdrant’, ‘pinecone’]

class smarter.apps.vectorstore.contract.models.VectorstoreApiCondition(*, type, status, reason, message, lastTransitionTime=None)[source]

Bases: AccountApiModel

One of the things that a vectorstore’s database needs before it is ready, and whether it has it.

The same as the Vectorstore manifest’s status.conditions: see smarter.apps.vectorstore.manifest.models.vectorstore.status.SAMVectorstoreCondition.

classmethod from_condition(condition)[source]

The contract’s model of a condition.

Parameters:

condition (SAMVectorstoreCondition) – The condition, as the deploy recorded it.

Return type:

VectorstoreApiCondition

Returns:

The model.

last_transition_time: datetime | None
message: str
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

reason: str
status: Literal['True', 'False', 'Unknown']
type: Literal['Credentials', 'Volume', 'Server', 'Index']
class smarter.apps.vectorstore.contract.models.VectorstoreApiDocument(*, id, hashedId, createdAt=None, updatedAt=None, name, source, contentType, sha256, sizeBytes, metadata, status, statusMessage, chunkCount, loadedAt=None)[source]

Bases: AccountApiModel

A document of a vectorstore: a smarter.apps.vectorstore.models.VectorstoreDocument, without its content.

chunk_count: int
content_type: str
created_at: datetime | None
classmethod from_model(document)[source]

The contract’s model of a vectorstore’s document.

Parameters:

document (VectorstoreDocument) – The row.

Returns:

The model.

Return type:

VectorstoreApiDocument

hashed_id: str
id: int
loaded_at: datetime | None
metadata: dict[str, JsonValue]
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
sha256: str
size_bytes: int
source: Literal['upload', 'url', 'text', 'file']
status: Literal['pending', 'loading', 'loaded', 'failed', 'deleting']
status_message: str
updated_at: datetime | None
class smarter.apps.vectorstore.contract.models.VectorstoreApiDocumentDeleted(*, document, status)[source]

Bases: AccountApiModel

A document that is being removed, with its chunks.

document: str
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

status: Literal['pending', 'loading', 'loaded', 'failed', 'deleting']
smarter.apps.vectorstore.contract.models.VectorstoreApiDocumentSource

The choices of VectorstoreDocument.source.

A test fails if the two differ.

alias of Literal[‘upload’, ‘url’, ‘text’, ‘file’]

smarter.apps.vectorstore.contract.models.VectorstoreApiDocumentStatus

The choices of VectorstoreDocument.status.

A test fails if the two differ.

alias of Literal[‘pending’, ‘loading’, ‘loaded’, ‘failed’, ‘deleting’]

class smarter.apps.vectorstore.contract.models.VectorstoreApiDocuments(*, documents)[source]

Bases: AccountApiModel

A vectorstore’s documents, newest first.

documents: list[VectorstoreApiDocument]
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

class smarter.apps.vectorstore.contract.models.VectorstoreApiDocumentsAdded(*, documents, duplicates, queued, message)[source]

Bases: AccountApiModel

The documents that a request added, the ones that the vectorstore already had, and whether they’re queued.

documents: list[VectorstoreApiDocument]
duplicates: list[VectorstoreApiDocument]
classmethod from_result(result)[source]

The contract’s model of the documents that a request added.

Parameters:

result (DocumentsAdded) – What smarter.apps.vectorstore.service.VectorstoreService.add_documents() returned.

Return type:

VectorstoreApiDocumentsAdded

Returns:

The model.

message: str
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

queued: bool
smarter.apps.vectorstore.contract.models.VectorstoreApiHosting

The choices of VectorstoreMeta.hosting.

A test fails if the two differ.

alias of Literal[‘self_hosted’, ‘managed’]

smarter.apps.vectorstore.contract.models.VectorstoreApiMetric

The choices of VectorstoreMeta.metric.

A test fails if the two differ.

alias of Literal[‘cosine’, ‘euclidean’, ‘dotproduct’]

class smarter.apps.vectorstore.contract.models.VectorstoreApiRestored(*, vectorstore, restored, vectorCount)[source]

Bases: AccountApiModel

A vectorstore whose data was replaced with one of its snapshots.

model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

restored: str
vector_count: int
vectorstore: str
class smarter.apps.vectorstore.contract.models.VectorstoreApiSearch(*, query, k=4, searchType='similarity', scoreThreshold=None, fetchK=None, lambdaMult=None, filter=None)[source]

Bases: AccountApiModel

The request body of a search of a vectorstore.

fetch_k: int | None
filter: dict[str, JsonValue] | None
k: int
lambda_mult: float | None
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

query: str
score_threshold: float | None
search_type: Literal['similarity', 'similarity_score_threshold', 'mmr']
class smarter.apps.vectorstore.contract.models.VectorstoreApiSearchResult(*, id=None, text, metadata, score=None)[source]

Bases: AccountApiModel

A chunk that a search found.

classmethod from_result(result)[source]

The contract’s model of a search result.

Parameters:

result (SearchResult) – The result.

Returns:

The model.

Return type:

VectorstoreApiSearchResult

id: str | None
metadata: dict[str, JsonValue]
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

score: float | None
text: str
class smarter.apps.vectorstore.contract.models.VectorstoreApiSearchResults(*, vectorstore, results)[source]

Bases: AccountApiModel

The results of a search of a vectorstore, most similar first.

model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

results: list[VectorstoreApiSearchResult]
vectorstore: str
smarter.apps.vectorstore.contract.models.VectorstoreApiSearchType

smarter.apps.vectorstore.backends.base.SEARCH_TYPES.

A test fails if the two differ.

Type:

The search types

alias of Literal[‘similarity’, ‘similarity_score_threshold’, ‘mmr’]

class smarter.apps.vectorstore.contract.models.VectorstoreApiSnapshot(*, id, hashedId, createdAt=None, updatedAt=None, name, status, statusMessage, sizeBytes=None, vectorCount=None, scheduled)[source]

Bases: AccountApiModel

A snapshot of a vectorstore: a smarter.apps.vectorstore.models.VectorstoreSnapshot, a Qdrant snapshot or Pinecone backup.

created_at: datetime | None
classmethod from_model(snapshot)[source]

The contract’s model of a vectorstore’s snapshot.

Parameters:

snapshot (VectorstoreSnapshot) – The row.

Returns:

The model.

Return type:

VectorstoreApiSnapshot

hashed_id: str
id: int
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
scheduled: bool
size_bytes: int | None
status: Literal['creating', 'ready', 'failed']
status_message: str
updated_at: datetime | None
vector_count: int | None
smarter.apps.vectorstore.contract.models.VectorstoreApiSnapshotStatus

The choices of VectorstoreSnapshot.status.

A test fails if the two differ.

alias of Literal[‘creating’, ‘ready’, ‘failed’]

class smarter.apps.vectorstore.contract.models.VectorstoreApiSnapshots(*, snapshots)[source]

Bases: AccountApiModel

A vectorstore’s snapshots.

model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

snapshots: list[VectorstoreApiSnapshot]
class smarter.apps.vectorstore.contract.models.VectorstoreApiStatus(*, vectorstore, status, message, vectorCount, stats)[source]

Bases: AccountApiModel

A vectorstore’s status and statistics, checked now.

message: str
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

stats: dict[str, JsonValue]
status: Literal['pending', 'provisioning', 'ready', 'stopped', 'failed', 'deleting']
vector_count: int
vectorstore: str
smarter.apps.vectorstore.contract.models.VectorstoreApiStatusValue

The choices of VectorstoreMeta.status.

A test fails if the two differ.

alias of Literal[‘pending’, ‘provisioning’, ‘ready’, ‘stopped’, ‘failed’, ‘deleting’]

class smarter.apps.vectorstore.contract.models.VectorstoreApiVectorstore(*, id, hashedId, createdAt=None, updatedAt=None, name, description=None, version=None, tags=<factory>, annotations=None, userProfile, canDelete, connection=None, embeddingsProvider=None, apiKeySecret=None, documentCount, snapshotCount, manifestUrl, detailUrl=None, spec, backend, hosting, isActive, dimension, metric, deletionProtection, embeddingsModel, status, statusMessage, indexName, endpointUrl, vectorCount, stats, deployedAt=None, lastCheckedAt=None, lastSnapshotAt=None, lastMaintenanceAt=None, conditions=<factory>, attempt=None, maxAttempts=None, nextRetryAt=None, lastError=None)[source]

Bases: AccountApiModel

A vectorstore: a smarter.apps.vectorstore.models.VectorstoreMeta.

Its related rows are their names.

annotations: dict[str, str] | None
api_key_secret: str | None
attempt: int | None
backend: Literal['qdrant', 'pinecone']
can_delete: bool
conditions: list[VectorstoreApiCondition]
connection: str | None
created_at: datetime | None
deletion_protection: bool
deployed_at: datetime | None
description: str | None
detail_url: str | None
dimension: int
document_count: int
embeddings_model: str
embeddings_provider: str | None
endpoint_url: str
classmethod from_model(vectorstore, user=None)[source]

The contract’s model of a vectorstore.

Parameters:
  • vectorstore (VectorstoreMeta) – The row, whose user_profile should be fetched with it.

  • user (object) – The requesting user, for can_delete. None may delete nothing.

Returns:

The model.

Return type:

VectorstoreApiVectorstore

hashed_id: str
hosting: Literal['self_hosted', 'managed']
id: int
index_name: str
is_active: bool
last_checked_at: datetime | None
last_error: str | None
last_maintenance_at: datetime | None
last_snapshot_at: datetime | None
manifest_url: str
max_attempts: int | None
metric: Literal['cosine', 'euclidean', 'dotproduct']
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
next_retry_at: datetime | None
snapshot_count: int
spec: dict[str, JsonValue]
stats: dict[str, JsonValue]
status: Literal['pending', 'provisioning', 'ready', 'stopped', 'failed', 'deleting']
status_message: str
tags: list[str]
updated_at: datetime | None
user_profile: AccountApiUserProfile
vector_count: int
version: str | None

Pydantic models of the LLMHosts’ REST api responses (/api/v1/llmhosts/).

The REST api’s views build their responses from these models, and the Smarter api’s OpenAPI document (smarter.apps.api.v1.contract.openapi) publishes their JSON Schemas.

LLMHostApiLLMHost is an LLMHost, as smarter.apps.llmhost.serializers.LLMHostSerializer returned it before the api was modeled, which clients already read. One value changed: its canDelete is computed for the requesting user. The other models replace the dicts that the views and the LLMHost service built by hand, with the same keys. Their date-times now end in Z, where they ended in +00:00: the same instant. A catalog’s model keeps its snake_case keys.

The models forbid extra fields: the api returns exactly what they declare.

smarter.apps.llmhost.contract.models.LLMHOST_API_MODELS = (<class 'smarter.apps.llmhost.contract.models.LLMHostApiLLMHost'>, <class 'smarter.apps.llmhost.contract.models.LLMHostApiStatus'>, <class 'smarter.apps.llmhost.contract.models.LLMHostApiLogs'>, <class 'smarter.apps.llmhost.contract.models.LLMHostApiPlan'>, <class 'smarter.apps.llmhost.contract.models.LLMHostApiUndeployed'>, <class 'smarter.apps.llmhost.contract.models.LLMHostApiReport'>, <class 'smarter.apps.llmhost.contract.models.LLMHostApiDiscovery'>, <class 'smarter.apps.llmhost.contract.models.LLMHostApiDraftManifest'>)

The models whose JSON Schemas the Smarter api’s OpenAPI document includes.

Their dependencies are included with them.

(
    <class 'smarter.apps.llmhost.contract.models.LLMHostApiLLMHost'>,
    <class 'smarter.apps.llmhost.contract.models.LLMHostApiStatus'>,
    <class 'smarter.apps.llmhost.contract.models.LLMHostApiLogs'>,
    <class 'smarter.apps.llmhost.contract.models.LLMHostApiPlan'>,
    <class 'smarter.apps.llmhost.contract.models.LLMHostApiUndeployed'>,
    <class 'smarter.apps.llmhost.contract.models.LLMHostApiReport'>,
    <class 'smarter.apps.llmhost.contract.models.LLMHostApiDiscovery'>,
    <class 'smarter.apps.llmhost.contract.models.LLMHostApiDraftManifest'>,
)
class smarter.apps.llmhost.contract.models.LLMHostApiCatalogModel(*, catalog, source, repository, task, description=None, license=None, gated=False, architecture=None, parameter_count=None, context_window=None, quantization='none', downloads=None, likes=None, tags=<factory>, files=<factory>, manifest=None)[source]

Bases: BaseModel

A model, as a catalog, e.g. Hugging Face, describes it.

Its keys are snake_case, e.g. parameter_count, as the api returned them before it was modeled.

architecture: str | None
catalog: str
context_window: int | None
description: str | None
downloads: int | None
files: list[str]
classmethod from_model_info(model)[source]

The contract’s model of a catalog’s model.

Parameters:

model (ModelInfo) – The model.

Returns:

The model.

Return type:

LLMHostApiCatalogModel

gated: bool
license: str | None
likes: int | None
manifest: dict[str, JsonValue] | None
model_config = {'extra': 'forbid'}

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

parameter_count: int | None
quantization: str
repository: str
source: str
tags: list[str]
task: str
class smarter.apps.llmhost.contract.models.LLMHostApiDiscovery(*, models)[source]

Bases: AccountApiModel

The models of a catalog that match a search, most popular first.

model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

models: list[LLMHostApiCatalogModel]
class smarter.apps.llmhost.contract.models.LLMHostApiDraftManifest(*, manifest)[source]

Bases: AccountApiModel

A draft LLMHost manifest for a model, to review and apply.

manifest: dict[str, JsonValue]
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

smarter.apps.llmhost.contract.models.LLMHostApiFormat

The choices of LLMHost.api_format.

A test fails if the two differ.

alias of Literal[‘openai_compatible’, ‘huggingface’, ‘ollama_native’, ‘custom’]

smarter.apps.llmhost.contract.models.LLMHostApiInferenceEngine

The choices of LLMHost.inference_engine.

A test fails if the two differ.

alias of Literal[‘vllm’, ‘tgi’, ‘sglang’, ‘llama_cpp’, ‘ollama’, ‘tei’, ‘custom’]

class smarter.apps.llmhost.contract.models.LLMHostApiLLMHost(*, id, hashedId, createdAt=None, updatedAt=None, name, description=None, version=None, tags=<factory>, annotations=None, userProfile, canDelete, manifestUrl, detailUrl=None, spec, modelSource, modelRepository, modelRevision, modelTask, servedModelName, license, modelArchitecture, parameterCount=None, contextWindow=None, quantization, embeddingDimensions=None, supportsStreaming, supportsFunctionCalling, supportsVision, supportsReasoning, inferenceEngine, apiFormat, apiKeySecret=None, compute=None, gpuType, gpuCount, vramRequiredGb=None, replicas, costPerHour=None, status, statusMessage, isActive, readyReplicas, endpointUrl, publicUrl, healthCheckUrl, lastHealthCheckAt=None, lastHealthOk=None, deployedAt=None)[source]

Bases: AccountApiModel

A self-hosted LLM: a smarter.apps.llmhost.models.LLMHost.

annotations: dict[str, str] | None
api_format: Literal['openai_compatible', 'huggingface', 'ollama_native', 'custom']
api_key_secret: int | None
can_delete: bool
compute: int | None
context_window: int | None
cost_per_hour: str | None
created_at: datetime | None
deployed_at: datetime | None
description: str | None
detail_url: str | None
embedding_dimensions: int | None
endpoint_url: str
classmethod from_model(llmhost, user=None)[source]

The contract’s model of an LLMHost.

Parameters:
  • llmhost (LLMHost) – The row, whose user_profile should be fetched with it.

  • user (object) – The requesting user, for can_delete. None may delete nothing.

Returns:

The model.

Return type:

LLMHostApiLLMHost

gpu_count: int
gpu_type: str
hashed_id: str
health_check_url: str
id: int
inference_engine: Literal['vllm', 'tgi', 'sglang', 'llama_cpp', 'ollama', 'tei', 'custom']
is_active: bool
last_health_check_at: datetime | None
last_health_ok: bool | None
license: str
manifest_url: str
model_architecture: str
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

model_repository: str
model_revision: str
model_source: Literal['huggingface', 'ollama', 's3', 'url', 'pvc']
model_task: Literal['text-generation', 'embedding']
name: str
parameter_count: int | None
public_url: str
quantization: Literal['none', 'fp32', 'fp16', 'bf16', 'fp8', 'mxfp4', 'int8', 'int4', 'gguf', 'awq', 'gptq']
ready_replicas: int
replicas: int
served_model_name: str
spec: dict[str, JsonValue]
status: Literal['provisioning', 'pending', 'downloading', 'deploying', 'active', 'degraded', 'inactive', 'error']
status_message: str
supports_function_calling: bool
supports_reasoning: bool
supports_streaming: bool
supports_vision: bool
tags: list[str]
updated_at: datetime | None
user_profile: AccountApiUserProfile
version: str | None
vram_required_gb: int | None
class smarter.apps.llmhost.contract.models.LLMHostApiLogs(*, llmhost, logs)[source]

Bases: AccountApiModel

The inference server’s recent logs.

llmhost: str
logs: str
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

smarter.apps.llmhost.contract.models.LLMHostApiModelSource

The choices of LLMHost.model_source.

A test fails if the two differ.

alias of Literal[‘huggingface’, ‘ollama’, ‘s3’, ‘url’, ‘pvc’]

smarter.apps.llmhost.contract.models.LLMHostApiModelTask

The choices of LLMHost.model_task.

A test fails if the two differ.

alias of Literal[‘text-generation’, ‘embedding’]

class smarter.apps.llmhost.contract.models.LLMHostApiObservation(*, status, message='', replicas=0, readyReplicas=0, healthy=None, endpoint=None, publicUrl=None, pods=<factory>, checkedAt=None)[source]

Bases: AccountApiModel

What is known about an LLMHost, as of a status check.

checked_at: datetime | None
endpoint: str | None
classmethod from_observation(observation)[source]

The contract’s model of a status check.

Parameters:

observation (LLMHostObservation) – The observation.

Returns:

The model.

Return type:

LLMHostApiObservation

healthy: bool | None
message: str
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

pods: list[LLMHostApiPod]
public_url: str | None
ready_replicas: int
replicas: int
status: str
class smarter.apps.llmhost.contract.models.LLMHostApiPlan(*, llmhost, resources)[source]

Bases: AccountApiModel

The Kubernetes resources that a deployment would apply, with secrets redacted.

llmhost: str
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

resources: list[dict[str, JsonValue]]
class smarter.apps.llmhost.contract.models.LLMHostApiPod(*, name=None, phase=None, ready, restarts, downloading, reason=None)[source]

Bases: AccountApiModel

A pod of an LLMHost: its name, phase, readiness, restarts, and why it is not ready, if it isn’t.

downloading: bool
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str | None
phase: str | None
ready: bool
reason: str | None
restarts: int
smarter.apps.llmhost.contract.models.LLMHostApiQuantization

The choices of LLMHost.quantization.

A test fails if the two differ.

alias of Literal[‘none’, ‘fp32’, ‘fp16’, ‘bf16’, ‘fp8’, ‘mxfp4’, ‘int8’, ‘int4’, ‘gguf’, ‘awq’, ‘gptq’]

class smarter.apps.llmhost.contract.models.LLMHostApiReport(*, totals, byStatus, byEngine, llmhosts)[source]

Bases: AccountApiModel

A summary of LLMHosts: their count by status and engine, the GPUs they use, and their cost.

by_engine: dict[str, int]
by_status: dict[str, int]
llmhosts: list[LLMHostApiReportHost]
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

totals: LLMHostApiReportTotals
class smarter.apps.llmhost.contract.models.LLMHostApiReportHost(*, name, owner, status, engine, model, task, replicas, readyReplicas, compute=None, gpus, gpuType=None, endpoint=None, publicUrl=None, deployedAt=None, uptimeHours=None, costPerHour=None, estimatedCost=None)[source]

Bases: AccountApiModel

An LLMHost in a report: its status, model, GPUs and cost.

compute: str | None
cost_per_hour: str | None
deployed_at: datetime | None
endpoint: str | None
engine: str
estimated_cost: str | None
gpu_type: str | None
gpus: int
model: str
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
owner: str
public_url: str | None
ready_replicas: int
replicas: int
status: str
task: str
uptime_hours: float | None
class smarter.apps.llmhost.contract.models.LLMHostApiReportTotals(*, llmhosts, deployed, active, errors, gpus, costPerHour, estimatedCost)[source]

Bases: AccountApiModel

The totals of a report of LLMHosts.

active: int
cost_per_hour: str
deployed: int
errors: int
estimated_cost: str
gpus: int
llmhosts: int
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

class smarter.apps.llmhost.contract.models.LLMHostApiStatus(*, status, message='', replicas=0, readyReplicas=0, healthy=None, endpoint=None, publicUrl=None, pods=<factory>, checkedAt=None, llmhost)[source]

Bases: LLMHostApiObservation

An LLMHost’s status, checked now, or after a deployment: the observation, with the LLMHost’s name.

llmhost: str
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

smarter.apps.llmhost.contract.models.LLMHostApiStatusValue

The choices of LLMHost.status.

A test fails if the two differ.

alias of Literal[‘provisioning’, ‘pending’, ‘downloading’, ‘deploying’, ‘active’, ‘degraded’, ‘inactive’, ‘error’]

class smarter.apps.llmhost.contract.models.LLMHostApiUndeployed(*, llmhost, status, message)[source]

Bases: AccountApiModel

An LLMHost whose Kubernetes resources were destroyed.

llmhost: str
message: str
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

status: Literal['provisioning', 'pending', 'downloading', 'deploying', 'active', 'degraded', 'inactive', 'error']
smarter.apps.llmhost.contract.models.money(value, decimal_places=4)[source]

A decimal amount as the api returns it: a string with the field’s decimal places, e.g. "0.1768".

Parameters:
  • value (Decimal | None) – The amount, or None.

  • decimal_places (int) – The number of decimal places.

Returns:

The amount, or None.

Return type:

str | None

Pydantic models of the Providers’ REST api responses (/api/v1/providers/).

The REST api’s views build their responses from these models, and the Smarter api’s OpenAPI document (smarter.apps.api.v1.contract.openapi) publishes their JSON Schemas.

ProviderApiProvider and ProviderApiModel are the rows, as smarter.apps.provider.serializers returned them before the api was modeled, which clients already read: a Provider’s api key is its Secret’s name and status, never the key.

The models forbid extra fields: the api returns exactly what they declare.

smarter.apps.provider.contract.models.PROVIDER_API_MODELS = (<class 'smarter.apps.provider.contract.models.ProviderApiProvider'>, <class 'smarter.apps.provider.contract.models.ProviderApiModel'>)

The models whose JSON Schemas the Smarter api’s OpenAPI document includes.

(
    <class 'smarter.apps.provider.contract.models.ProviderApiProvider'>,
    <class 'smarter.apps.provider.contract.models.ProviderApiModel'>,
)
class smarter.apps.provider.contract.models.ProviderApiModel(*, id, provider, createdAt=None, updatedAt=None, name, description=None, isDefault, isActive, isDeprecated, isFlagged, isSuspended, maxCompletionTokens, temperature, topP, supportsTextInput, supportsTextGeneration, supportsTranslation, supportsSummarization, supportsStreaming, supportsTools, supportsImageInput, supportsAudioInput, supportsEmbedding, supportsFineTuning, supportsSearch, supportsCodeInterpreter, supportsImageGeneration, supportsAudioGeneration)[source]

Bases: AccountApiModel

A model of an LLM provider: a smarter.apps.provider.models.ProviderModel, with its provider.

created_at: datetime | None
description: str | None
classmethod from_model(provider_model, user=None)[source]

The contract’s model of a provider’s model.

Parameters:
  • provider_model (ProviderModel) – The row, whose provider should be fetched with it.

  • user (object) – The requesting user, for the provider’s can_delete.

Returns:

The model.

Return type:

ProviderApiModel

id: int
is_active: bool
is_default: bool
is_deprecated: bool
is_flagged: bool
is_suspended: bool
max_completion_tokens: int
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
provider: ProviderApiProvider
supports_audio_generation: bool
supports_audio_input: bool
supports_code_interpreter: bool
supports_embedding: bool
supports_fine_tuning: bool
supports_image_generation: bool
supports_image_input: bool
supports_streaming: bool
supports_summarization: bool
supports_text_generation: bool
supports_text_input: bool
supports_tools: bool
supports_translation: bool
temperature: float
top_p: float
updated_at: datetime | None
class smarter.apps.provider.contract.models.ProviderApiProvider(*, id, createdAt=None, updatedAt=None, name, userProfile, status, description=None, version=None, annotations=None, tags=<factory>, manifestUrl=None, detailUrl=None, ready, isDefault, isActive, isVerified, isFeatured, isDeprecated, isFlagged, isSuspended, baseUrl=None, apiKey=None, defaultModel=None, connectivityTestPath=None, logo=None, websiteUrl=None, ownershipRequested=None, contactEmail=None, contactEmailVerified=None, supportEmail=None, supportEmailVerified=None, docsUrl=None, termsOfServiceUrl=None, privacyPolicyUrl=None, isOfficialProvider, tosAccepted, tosAcceptedAt=None, tosAcceptedBy=None, rfc1034CompliantName=None, canDelete)[source]

Bases: AccountApiModel

An LLM provider: a smarter.apps.provider.models.Provider.

annotations: dict[str, str] | None
api_key: SecretApiSecretRef | None
base_url: str | None
can_delete: bool
connectivity_test_path: str | None
contact_email: str | None
contact_email_verified: datetime | None
created_at: datetime | None
default_model: str | None
description: str | None
detail_url: str | None
docs_url: str | None
classmethod from_model(provider, user=None)[source]

The contract’s model of a Provider.

Parameters:
  • provider (Provider) – The row, whose user_profile, api_key and tos_accepted_by should be fetched with it.

  • user (object) – The requesting user, for can_delete. None may delete nothing.

Returns:

The model.

Return type:

ProviderApiProvider

id: int
is_active: bool
is_default: bool
is_deprecated: bool
is_flagged: bool
is_official_provider: bool
is_suspended: bool
is_verified: bool
manifest_url: str | None
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
ownership_requested: str | None
privacy_policy_url: str | None
ready: bool
rfc1034_compliant_name: str | None
status: Literal['unverified', 'verifying', 'failed', 'verified', 'suspended', 'deprecated']
support_email: str | None
support_email_verified: datetime | None
tags: list[str]
terms_of_service_url: str | None
tos_accepted: bool
tos_accepted_at: datetime | None
tos_accepted_by: AccountApiUser | None
updated_at: datetime | None
user_profile: AccountApiUserProfile
version: str | None
website_url: str | None
smarter.apps.provider.contract.models.ProviderApiStatus

The choices of Provider.status.

A test fails if the two differ.

alias of Literal[‘unverified’, ‘verifying’, ‘failed’, ‘verified’, ‘suspended’, ‘deprecated’]

Pydantic models of the Proxies’ REST api responses (/api/v1/proxy/).

The list of the Proxies that the caller may use is built from ProxyApiProxies, with the keys that the view built by hand before the api was modeled. A Proxy’s passthrough (/api/v1/proxy/<name>/<path>) forwards the request to the provider’s api, and returns its response, as it is, so its requests and responses are the provider’s, not Smarter’s, and are not modeled.

smarter.apps.proxy.contract.models.PROXY_API_MODELS = (<class 'smarter.apps.proxy.contract.models.ProxyApiProxies'>,)

The models whose JSON Schemas the Smarter api’s OpenAPI document includes.

(<class 'smarter.apps.proxy.contract.models.ProxyApiProxies'>, )
class smarter.apps.proxy.contract.models.ProxyApiProxies(*, proxies)[source]

Bases: AccountApiModel

The Proxies that the caller may use, by name.

model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

proxies: list[ProxyApiProxy]
class smarter.apps.proxy.contract.models.ProxyApiProxy(*, name, description=None, provider, url, upstreamUrl, allowedPaths, isActive)[source]

Bases: AccountApiModel

A Proxy that the caller may use: its name, provider and urls.

allowed_paths: list[str]
description: str | None
classmethod from_model(proxy, request)[source]

The contract’s model of a Proxy.

Parameters:
  • proxy (Proxy) – The row, whose provider should be fetched with it.

  • request (HttpRequest) – The request, whose host makes the Proxy’s url absolute.

Returns:

The model.

Return type:

ProxyApiProxy

is_active: bool
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

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

name: str
provider: str
upstream_url: str
url: str

Pydantic models of the prompt history’s REST api responses (/api/v1/prompts/history/).

The prompt history is the chat sessions (PromptHistoryApiSession) of the users whose resources the requesting user may manage, the tool calls that the LLMs made in them (PromptHistoryApiToolCall), and the plugins that they used (PromptHistoryApiPluginUsage).

The models are the outputs of the serializers of smarter.apps.prompt.api.v1.serializers, which the REST api returned before it was modeled, and which clients already read. Their keys are snake_case, unlike the rest of the REST api’s, for the same reason. A plugin is a smarter.apps.llmtool.contract.models.PluginApiPluginMeta, in camelCase.

The models forbid extra fields: the api returns exactly what they declare.

smarter.apps.prompt.contract.history.PROMPT_HISTORY_API_MODELS = (<class 'smarter.apps.prompt.contract.history.PromptHistoryApiSession'>, <class 'smarter.apps.prompt.contract.history.PromptHistoryApiToolCall'>, <class 'smarter.apps.prompt.contract.history.PromptHistoryApiPluginUsage'>)

The models whose JSON Schemas the Smarter api’s OpenAPI document includes.

(
    <class 'smarter.apps.prompt.contract.history.PromptHistoryApiSession'>,
    <class 'smarter.apps.prompt.contract.history.PromptHistoryApiToolCall'>,
    <class 'smarter.apps.prompt.contract.history.PromptHistoryApiPluginUsage'>,
)
class smarter.apps.prompt.contract.history.PromptHistoryApiModel(*, id, created_at=None, updated_at=None)[source]

Bases: BaseModel

Base class of the prompt history’s models: the fields of a row, and a TimestampedModel’s.

created_at: datetime | None
id: int
model_config = {'extra': 'forbid'}

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

updated_at: datetime | None
class smarter.apps.prompt.contract.history.PromptHistoryApiPluginUsage(*, id, created_at=None, updated_at=None, prompt, plugin, input_text=None)[source]

Bases: PromptHistoryApiModel

A use of a plugin in a chat session: a smarter.apps.prompt.models.PromptPluginUsage.

classmethod from_model(row, user=None)[source]

The contract’s model of a use of a plugin.

Parameters:
  • row (PromptPluginUsage) – The row, whose prompt and plugin should be fetched with it.

  • user (object) – The requesting user, for the plugin’s canDelete. None may delete nothing.

Returns:

The model.

Return type:

PromptHistoryApiPluginUsage

input_text: str | None
model_config = {'extra': 'forbid'}

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

plugin: PluginApiPluginMeta
prompt: PromptHistoryApiSession
class smarter.apps.prompt.contract.history.PromptHistoryApiSession(*, id, created_at=None, updated_at=None, name='', description=None, version=None, annotations=None, session_key, ip_address, user_agent, url, user_profile, llmclient)[source]

Bases: PromptHistoryApiModel

A chat session: one conversation with an LLMClient, a smarter.apps.prompt.models.Prompt.

annotations: dict[str, str] | None
description: str | None
classmethod from_model(prompt)[source]

The contract’s model of a chat session.

Parameters:

prompt (Prompt) – The row.

Returns:

The model.

Return type:

PromptHistoryApiSession

ip_address: str
llmclient: int
model_config = {'extra': 'forbid'}

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

name: str
session_key: str
url: str
user_agent: str
user_profile: int
version: str | None
class smarter.apps.prompt.contract.history.PromptHistoryApiToolCall(*, id, created_at=None, updated_at=None, prompt, plugin=None, function_name=None, function_args=None, request=None, response=None)[source]

Bases: PromptHistoryApiModel

A tool call that the LLM made in a chat session: a smarter.apps.prompt.models.PromptToolCall.

classmethod from_model(row)[source]

The contract’s model of a tool call.

Parameters:

row (PromptToolCall) – The row, whose prompt should be fetched with it.

Returns:

The model.

Return type:

PromptHistoryApiToolCall

function_args: str | None
function_name: str | None
model_config = {'extra': 'forbid'}

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

plugin: int | None
prompt: PromptHistoryApiSession
request: JsonValue | None
response: JsonValue | None

A mixin of the REST api’s list views whose rows are built from api contract models.

The REST api’s responses are built from Pydantic models of their rows, e.g. smarter.apps.llmclient.contract.models, which the Smarter api’s OpenAPI document (smarter.apps.api.v1.contract.openapi) publishes. A list view that mixes in ContractListMixin sets contract_model, the model of one row, and its GET returns its queryset’s rows, each built by the model’s from_model().

class smarter.lib.drf.views.contract.ContractListMixin[source]

The list() of a DRF ListAPIView whose rows are built from contract_model.

A view whose rows need the request, e.g. for their canDelete, overrides item().

contract_model: type[BaseModel]

The contract model of one row.

It must have a from_model(row) classmethod.

item(row)[source]

Return the response’s item for a row: its contract model, dumped as JSON.

Parameters:

row – A row of the view’s queryset, a django.db.models.Model.

Return type:

JsonValue

Returns:

The row’s JSON.

list(request, *args, **kwargs)[source]

Return the rows of the view’s queryset, each built by item().

Parameters:

request (Request) – The request.

Return type:

Response

Returns:

The response, a JSON list.