Authentication
Authentication of the Proxy passthrough’s callers, with a Smarter API key.
A Proxy’s callers use the provider’s own SDK, with the Proxy’s URL as its base URL, and a
Smarter API key in place of the provider’s. Each SDK sends its API key in its own header, so
SmarterProxyAuthentication reads the Smarter API key from any of them. See
CREDENTIAL_HEADERS.
from openai import OpenAI
client = OpenAI(
base_url="https://platform.smarter.sh/api/v1/proxy/openai/",
api_key="<your Smarter API key>",
)
- class smarter.apps.proxy.authentication.SmarterProxyAuthentication[source]
Bases:
BaseAuthenticationAuthenticate a Proxy’s caller by a Smarter API key, in any of the headers that LLM SDKs use.
The key is verified by
SmarterTokenAuthentication, as for the rest of the Smarter API: it must exist, and be active.- authenticate(request)[source]
Authenticate the request by the Smarter API key in its headers.
- Parameters:
request (
Request) – The request.- Return type:
- Returns:
The user and token, or None when the request carries no API key, so that other authenticators may try.
- Raises:
AuthenticationFailed – when the key does not exist or is inactive.