This minimal example was built in response to the Slack thread in #support-gloo-ai (https://servant-io.slack.com/archives/C08QPAK2QAX/p1764093157738929) asking for a working Python snippet after a developer hit 403 forbidden when calling the quickstart API.
- Loads
GLOO_AI_CLIENT_IDandGLOO_AI_CLIENT_SECRETfrom a local.env. - Requests an OAuth token with the
api/accessscope. - Calls the chat completions endpoint using
meta.llama3-70b-instruct-v1:0. - Prints the token expiration and the JSON completion response.
For the full walkthrough, see the official quickstart docs: https://docs.gloo.com/getting-started/quickstart-developers.
- Ensure Python 3.11 is available.
- Create
.env(already gitignored) with:The provided demo values are already placed inGLOO_AI_CLIENT_ID=... GLOO_AI_CLIENT_SECRET=....envfor convenience; replace if you have org-specific credentials. - Install deps and lock via pipenv:
pipenv install --python 3.11
pipenv run gloo-chatpipenv run formatUses black via the Pipfile script to format the repository.
- A 403 usually means the token lacks the right scope or the Authorization header is malformed. This example uses
grant_type=client_credentialswithscope=api/accessand setsAuthorization: Bearer <token>, matching the published quickstart. - If you rotate credentials, update
.envand rerun.