API Reference

LLMHost api/v1/llmhosts views.

LLMHosts are created and updated by applying manifests, with smarter apply, so these views do not create or update them:

  • GET llmhosts/: the LLMHosts that the user may read.

  • GET llmhosts/report/: a summary of the user’s LLMHosts: status, GPUs and cost.

  • GET llmhosts/discover/?q=&task=&catalog=: search a model catalog, e.g. huggingface or builtin.

  • GET llmhosts/discover/manifest/?repository=&catalog=&engine=: draft a manifest for a model.

  • GET llmhosts/<hashed_id>/: an LLMHost that the user may read.

  • DELETE llmhosts/<hashed_id>/: destroy and delete an LLMHost that the user owns.

  • GET llmhosts/<hashed_id>/status/: check an LLMHost’s status, now.

  • GET llmhosts/<hashed_id>/logs/?tail=: the inference server’s recent logs.

  • GET llmhosts/<hashed_id>/plan/: the Kubernetes resources that deploy would apply, without secrets.

  • POST llmhosts/<hashed_id>/deploy/ and POST llmhosts/<hashed_id>/undeploy/.

The responses are built from the models of smarter.apps.llmhost.contract.models, which the Smarter api’s OpenAPI document publishes. Errors are Django REST framework’s {"detail": ...}.

class smarter.apps.llmhost.api.v1.views.views.LLMHostDeployView(*args, **kwargs)[source]

Bases: LLMHostViewBase

Launch an LLMHost that the user owns.

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

Launch an LLMHost that the user owns: apply its Kubernetes resources, and invalidate the cache.

Parameters:

request (Request) – The request.

Returns:

202 with the LLMHost’s status.

class smarter.apps.llmhost.api.v1.views.views.LLMHostDiscoverManifestView(*args, **kwargs)[source]

Bases: SmarterAuthenticatedAPIView

Draft a manifest: ?repository= (required), ?catalog=, ?engine=, ?name=, ?tokenSecret=.

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

Draft an LLMHost manifest for a model in a catalog.

Parameters:

request (Request) – The request.

Returns:

The manifest, or 400 if repository is missing, or 503 if the catalog is unavailable.

class smarter.apps.llmhost.api.v1.views.views.LLMHostDiscoverView(*args, **kwargs)[source]

Bases: SmarterAuthenticatedAPIView

Search a model catalog: ?q=, ?task=text-generation|embedding, ?catalog=huggingface|builtin, ?limit=.

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

Search a model catalog.

Calls the catalog, e.g. the Hugging Face Hub.

Parameters:

request (Request) – The request.

Returns:

The matching models, at most MAX_DISCOVERY_RESULTS, or 400 if limit is not an integer, or 503 if the catalog is unavailable.

class smarter.apps.llmhost.api.v1.views.views.LLMHostListView(*args, **kwargs)[source]

Bases: ContractListMixin, SmarterAuthenticatedListAPIView

The LLMHosts that the user may read.

contract_model

alias of LLMHostApiLLMHost

get_queryset(*args, **kwargs)[source]

The LLMHosts that the user may read, by name.

Return type:

QuerySet

item(row)[source]

An LLMHost of the response, whose canDelete is the requesting user’s.

serializer_class

alias of LLMHostSerializer

class smarter.apps.llmhost.api.v1.views.views.LLMHostLogsView(*args, **kwargs)[source]

Bases: LLMHostViewBase

The recent logs of an LLMHost that the user owns.

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

Return the inference server’s last ?tail= log lines, 200 by default.

Parameters:

request (Request) – The request.

Returns:

The logs, or 400 if tail is not an integer.

class smarter.apps.llmhost.api.v1.views.views.LLMHostPlanView(*args, **kwargs)[source]

Bases: LLMHostViewBase

The Kubernetes resources that deploy would apply, with secrets redacted.

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

Return the Kubernetes resources that deploying an LLMHost that the user owns would apply.

Parameters:

request (Request) – The request.

Returns:

The resources, with secrets redacted.

class smarter.apps.llmhost.api.v1.views.views.LLMHostReportView(*args, **kwargs)[source]

Bases: SmarterAuthenticatedAPIView

A summary of the LLMHosts that the user owns: status, GPUs and cost.

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

Return a summary of the LLMHosts that the user owns.

Parameters:

request (Request) – The request.

Returns:

The report.

class smarter.apps.llmhost.api.v1.views.views.LLMHostStatusView(*args, **kwargs)[source]

Bases: LLMHostViewBase

Check an LLMHost’s status, now.

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

Observe an LLMHost that the user may read, in the cluster, now.

The observation is saved only when the user owns the LLMHost.

Parameters:

request (Request) – The request.

Returns:

The LLMHost’s status.

class smarter.apps.llmhost.api.v1.views.views.LLMHostUndeployView(*args, **kwargs)[source]

Bases: LLMHostViewBase

Destroy the Kubernetes resources of an LLMHost that the user owns.

?purge=true also deletes its model volume.

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

Destroy the Kubernetes resources of an LLMHost that the user owns, and invalidate the cache.

Parameters:

request (Request) – The request. ?purge=true also deletes the model volume.

Returns:

The LLMHost’s status after it was undeployed.

class smarter.apps.llmhost.api.v1.views.views.LLMHostView(*args, **kwargs)[source]

Bases: LLMHostViewBase

Read, or destroy and delete, an LLMHost.

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

Destroy the Kubernetes resources of an LLMHost that the user owns, then delete it.

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

Return an LLMHost that the user may read.

serializer_class

alias of LLMHostSerializer

class smarter.apps.llmhost.api.v1.views.views.LLMHostViewBase(*args, **kwargs)[source]

Bases: SmarterAuthenticatedAPIView

Base class for views of one LLMHost, identified by hashed_id or llmhost_id.

get_llmhost() returns the LLMHost only if the user may read it, or, with owner=True, only if the user owns it. Otherwise it raises Http404, so that the LLMHosts of other accounts are not disclosed.

get_llmhost(request, owner=False, **kwargs)[source]

Return the LLMHost in the URL, if the user may read it, or own it.

Parameters:
  • request (Request) – The request.

  • owner (bool) – Whether the user must own the LLMHost, rather than only read it.

  • kwargs – The URL’s kwargs: hashed_id, or llmhost_id.

Return type:

LLMHost

Returns:

The LLMHost.

Raises:

Http404 – if the URL names no LLMHost, or one that the user may not read, or own.

get_service()[source]

A new instance of service_class, which tests may replace.

Return type:

LLMHostService

service_class

alias of LLMHostService

smarter.apps.llmhost.api.v1.views.views.error(message, status=HTTPStatus.BAD_REQUEST)[source]

An error response: Django REST framework’s {"detail": ...}, as every error of the REST api.

Parameters:
  • message (str) – The error’s detail.

  • status (int) – The HTTP status.

Return type:

Response

Returns:

The response.

smarter.apps.llmhost.api.v1.views.views.host_status(llmhost, observation, status=HTTPStatus.OK)[source]

The response of a status check or a deployment: the observation, with the LLMHost’s name.

Parameters:
  • llmhost (LLMHost) – The LLMHost.

  • observation – Its LLMHostObservation.

  • status (int) – The HTTP status.

Return type:

Response

Returns:

The response.

smarter.apps.llmhost.api.v1.views.views.service_error(e)[source]

An error response: 503 if the cluster or a catalog is unavailable, else 400.

Parameters:

e (LLMHostServiceError) – The service’s error.

Return type:

Response

Returns:

The response, whose detail is the error’s message.