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]
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]
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]
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]

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.

You may want to override this if you need to provide different querysets depending on the incoming request.

(Eg. return a list of items that is specific to the user)

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]
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]
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]
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]
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]
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.

Return type:

LLMHost

get_service()[source]
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.

Return type:

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.

Return type:

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.

Return type:

Response