Skip to content
smol.Docs

    Open console

    Authenticate your backend

    Choose an endpoint credential or an Application, keep its secret on your server, and exchange it for an OAuth access token.

    Endpoint credential Application
    Best for One backend calling one endpoint A separately named consumer, independent grants or several endpoints
    Create it Inference → your endpoint → Connect Applications → create an application
    Before calling inference The endpoint must be ready Grant the Application inference access to a ready endpoint
    Context during inference Context Spaces shared by that endpoint Endpoint-shared spaces and the Application’s own granted spaces
    Read or write content through the platform API No Grant the Application direct access to the space

    Save the client ID and one-time client secret to your backend secret manager. An ID identifies the caller; it is not a secret and is not sufficient to make a request. Endpoint credentials are not cloud-provider credentials.

    In the environment that runs your backend, set SMOL_CLIENT_ID, SMOL_CLIENT_SECRET and SMOL_TOKEN_URL using the values for this credential and environment. The token URL is the complete HTTPS token endpoint, not the sign-in page. In a trusted server shell with Bash, cURL and Python 3:

    Terminal window
    set -o pipefail
    if SMOL_ACCESS_TOKEN="$(
    printf '%s' "$SMOL_CLIENT_SECRET" |
    curl --fail --silent --show-error --proto '=https' --max-time 20 \
    --data-urlencode 'grant_type=client_credentials' \
    --data-urlencode 'scope=smol:invoke' \
    --data-urlencode "client_id=$SMOL_CLIENT_ID" \
    --data-urlencode 'client_secret@-' \
    "$SMOL_TOKEN_URL" |
    python3 -c 'import json,sys; t=json.load(sys.stdin)["access_token"]; assert isinstance(t,str) and t; sys.stdout.write(t)'
    )"; then
    export SMOL_ACCESS_TOKEN
    else
    unset SMOL_ACCESS_TOKEN
    printf '%s\n' 'Token exchange failed. Do not send the inference request.' >&2
    fi

    The response is an OAuth token response: use access_token in the Authorization: Bearer … header, and use expires_in to decide when to obtain another token in a long-running service. Never send the client secret in an inference request, put a token in a URL, or expose either in browser JavaScript. Do not enable shell tracing.

    Changing access. Rotate a secret when updating a backend: store the new one once, update the backend, then test with a fresh token. Rotation is not an immediate recall of an already-issued token. Revoke the credential or remove the relevant grant when the caller should no longer have access. New authorization is checked server-side; a revocation cannot unsend already-dispatched work.

    Continue with your first completion, or read and write context without an inference endpoint.