Passthrough Chat
This module contains passthrough views for interacting directly with the LLM.
provider backend API.
- class smarter.apps.prompt.api.v1.views.passthrough.PassthroughChatViewSet(**kwargs)[source]
Bases:
SmarterAuthenticatedNeverCachedWebViewHandle POST requests to the passthrough endpoint for direct LLM provider API access.
path: /api/v1/prompts/passthrough/{provider_name}/
This endpoint allows authenticated users to send arbitrary prompt dicts to the underlying LLM provider (such as OpenAI). The request body should be a JSON object containing any valid parameters accepted by the provider’s prompt completion API.
- Parameters:
request (rest_framework.request.ASGIRequest) – The HTTP request object, expected to have a JSON body with prompt completion parameters.
args – Additional positional arguments (unused).
kwargs – Additional keyword arguments. May include ‘provider’ to select the LLM provider.
- Returns:
A JSON response containing the provider’s prompt completion result, or an error message.
- Return type:
SmarterJournaledJsonResponse | SmarterJournaledJsonErrorResponse | SmarterHttpResponseBadRequest | SmarterHttpResponseForbidden | SmarterHttpResponseNotFound
- Signals:
chat_started: Sent before the prompt completion request is made.chat_completion_request: Sent with the prompt data before calling the provider.chat_completion_response: Sent after a successful response from the provider.chat_finished: Sent after the prompt completion process is finished.chat_response_failure: Sent if an exception occurs during the provider call.
- Raises:
SmarterHttpResponseForbidden – If the user is not authenticated.
SmarterHttpResponseNotFound – If the specified provider is not found.
SmarterHttpResponseBadRequest – If the request body is invalid.
SmarterJournaledJsonErrorResponse – If the provider API call fails.
See also
The OpenAI API documentation for prompt completions: https://developers.openai.com/api/reference/overview/prompt/create
openai.types.prompt.chat_completion.ChatCompletion
- handler: OpenAICompatiblePassthroughProtocol