Const
Constants for the Proxy app.
- smarter.apps.proxy.const.BUILTIN_PROXY_PATH = '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/proxy/data/proxy'
The built-in Proxy manifests, which
manage.py add_builtin_proxiesapplies.
- smarter.apps.proxy.const.CREDENTIAL_HEADERS = ('authorization', 'x-api-key', 'x-goog-api-key', 'api-key')
The request headers in which callers may send their Smarter API key, in the order in which.
they are checked. Each is how a popular SDK sends its API key, so that callers can use the provider’s own SDK, with a Smarter API key:
Authorization: Bearer <key>: OpenAI, and OpenAI-compatible SDKs.Authorization: Token <key>, as for the rest of the Smarter API, also works.x-api-key: Anthropic.x-goog-api-key: Google Gemini.api-key: Azure OpenAI.
None of them is forwarded to the provider.
('authorization', 'x-api-key', 'x-goog-api-key', 'api-key')
- smarter.apps.proxy.const.DEFAULT_TIMEOUT = 120
Seconds.
LLM responses, especially long completions, can be slow.
- smarter.apps.proxy.const.DROPPED_REQUEST_HEADERS = ('connection', 'keep-alive', 'proxy-authenticate', 'proxy-authorization', 'te', 'trailer', 'trailers', 'transfer-encoding', 'upgrade', 'authorization', 'x-api-key', 'x-goog-api-key', 'api-key', 'host', 'content-length', 'cookie', 'forwarded', 'x-forwarded-for', 'x-forwarded-host', 'x-forwarded-proto', 'x-forwarded-port', 'x-real-ip', 'x-csrftoken', 'accept-encoding')
hop-by-hop headers, the caller’s.
credentials, Smarter’s cookies, and the caller’s address.
accept-encodingis dropped so that the provider’s response is decoded before it is returned, which lets Smarter read its token usage.( 'connection', 'keep-alive', 'proxy-authenticate', 'proxy-authorization', 'te', 'trailer', 'trailers', 'transfer-encoding', 'upgrade', 'authorization', 'x-api-key', 'x-goog-api-key', 'api-key', 'host', 'content-length', 'cookie', 'forwarded', 'x-forwarded-for', 'x-forwarded-host', 'x-forwarded-proto', 'x-forwarded-port', 'x-real-ip', 'x-csrftoken', 'accept-encoding', )
- Type:
The request headers that are not forwarded to the provider
- smarter.apps.proxy.const.DROPPED_RESPONSE_HEADERS = ('connection', 'keep-alive', 'proxy-authenticate', 'proxy-authorization', 'te', 'trailer', 'trailers', 'transfer-encoding', 'upgrade', 'content-length', 'content-encoding', 'set-cookie', 'alt-svc', 'strict-transport-security')
The response headers that are not returned to the caller.
( 'connection', 'keep-alive', 'proxy-authenticate', 'proxy-authorization', 'te', 'trailer', 'trailers', 'transfer-encoding', 'upgrade', 'content-length', 'content-encoding', 'set-cookie', 'alt-svc', 'strict-transport-security', )
- smarter.apps.proxy.const.HOP_BY_HOP_HEADERS = ('connection', 'keep-alive', 'proxy-authenticate', 'proxy-authorization', 'te', 'trailer', 'trailers', 'transfer-encoding', 'upgrade')
Headers that apply to one connection, and that a proxy must not forward.
See RFC 9110, section 7.6.1.
( 'connection', 'keep-alive', 'proxy-authenticate', 'proxy-authorization', 'te', 'trailer', 'trailers', 'transfer-encoding', 'upgrade', )
- smarter.apps.proxy.const.RESERVED_HEADERS = ('api-key', 'authorization', 'connection', 'content-length', 'cookie', 'forwarded', 'host', 'keep-alive', 'proxy-authenticate', 'proxy-authorization', 'te', 'trailer', 'trailers', 'transfer-encoding', 'upgrade', 'x-api-key', 'x-csrftoken', 'x-forwarded-for', 'x-forwarded-host', 'x-forwarded-port', 'x-forwarded-proto', 'x-goog-api-key', 'x-real-ip')
Headers that a Proxy manifest’s
spec.headersmay not set.( 'api-key', 'authorization', 'connection', 'content-length', 'cookie', 'forwarded', 'host', 'keep-alive', 'proxy-authenticate', 'proxy-authorization', 'te', 'trailer', 'trailers', 'transfer-encoding', 'upgrade', 'x-api-key', 'x-csrftoken', 'x-forwarded-for', 'x-forwarded-host', 'x-forwarded-port', 'x-forwarded-proto', 'x-goog-api-key', 'x-real-ip', )