API - Providers
Provider API view for the Dashboard prompt passthrough feature.
This module exposes a JSON API endpoint used by the prompt passthrough React
frontend to retrieve the LLM providers that the currently authenticated user
has read permission for. The provider list is serialised with
ProviderMiniSerializer and
returned as a JSON response.
- Classes:
- ProviderApiView: Authenticated API view that returns the list of accessible
LLM providers for the requesting user.
Example
Wire up the view in your URL configuration:
from smarter.apps.dashboard.views.passthrough.api.providers import ProviderApiView
urlpatterns = [
path("providers/", ProviderApiView.as_view(), name="api_providers"),
]
- class smarter.apps.dashboard.views.passthrough.api.providers.ProviderApiView(*args, **kwargs)[source]
Bases:
SmarterViewAuthenticated JSON API view that returns LLM providers accessible to the requesting user.
Extends
SmarterAuthenticatedNeverCachedWebViewto enforce authentication and prevent response caching.On a
POSTrequest the view resolves the authenticated user viaget_resolved_user(), queriesProviderfor all records the user has read permission for, and returns them serialised as a JSON object.Response shape:
{ "providers": [ { "id": 1, "name": "OpenAI", "base_url": "https://api.openai.com/v1" } ] }
Additional provider objects may appear in the
providersarray.- dispatch(request, *args, **kwargs)
- post(request, *args, **kwargs)[source]
Handle POST requests to retrieve LLM providers accessible to the authenticated user.
- Parameters:
request (
HttpRequest) – The incoming HTTP POST request from the client.args – Additional positional arguments forwarded by the URL dispatcher.
kwargs – Additional keyword arguments forwarded by the URL dispatcher.
- Returns:
A JSON response containing the list of accessible LLM providers.
- Return type: