API Reference

The Proxy passthrough endpoint, /api/v1/proxy/<name>/<path>, and the list of the Proxies that a caller may use, /api/v1/proxy/. They are enabled when SMARTER_ENABLE_PROXY is true, which is the default.

Proxy api/v1/proxy views: the Proxy passthrough.

  • GET proxy/: the Proxies that the caller may use.

  • <METHOD> proxy/<name>/<path>: forward the request to the Proxy’s provider, at <baseUrl><path>, with the provider’s API key, and return the provider’s response.

The caller authenticates with a Smarter API key, in any of the headers that LLM SDKs use. See smarter.apps.proxy.authentication.

class smarter.apps.proxy.api.v1.views.ProxyListView(**kwargs)[source]

Bases: ProxyApiViewBase

The Proxies that the caller may use, with their URLs.

get(request, *args, **kwargs)[source]
class smarter.apps.proxy.api.v1.views.ProxyPassthroughView(**kwargs)[source]

Bases: ProxyApiViewBase

Forward a request to a Proxy’s provider, and return its response, as it is.

Errors of Smarter’s own, e.g. an unknown Proxy, are JSON, in the shape that the OpenAI and Anthropic SDKs report: {"error": {"message": ..., "type": "smarter_proxy_error", "code": ...}}.

delete(request, name, path='', *args, **kwargs)[source]
get(request, name, path='', *args, **kwargs)[source]
http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options']
passthrough(request, name, path='')[source]
Return type:

HttpResponseBase

patch(request, name, path='', *args, **kwargs)[source]
post(request, name, path='', *args, **kwargs)[source]
put(request, name, path='', *args, **kwargs)[source]

URL configuration for the Proxy passthrough.

These are mounted at /api/v1/proxy/, if SMARTER_ENABLE_PROXY is true. See smarter.apps.proxy.api.v1.views.

class smarter.apps.proxy.api.v1.urls.ProxyApiV1ReverseViews[source]

Bases: object

Reverse view names for the Proxy passthrough.

Example

from django.urls import reverse
url = reverse(
    f"{ProxyApiV1ReverseViews.namespace}:{ProxyApiV1ReverseViews.passthrough}",
    kwargs={"name": "openai", "path": "chat/completions"},
)
list_view = 'proxy_list_view'
namespace = 'api:v1:proxy'
passthrough = 'proxy_passthrough_view'
passthrough_root = 'proxy_passthrough_view_root'