Skip to main content
Sign in with a SuperGrok subscription instead of an API key and run an agent through xAIResponses. The device flow prints a URL and a code; approve the sign-in in the browser and the token is stored encrypted and refreshed automatically across restarts.
oauth_device_login.py

Run the Example

1

Set up your virtual environment

2

Install dependencies

3

Export your xAI API key

4

Run the example

Save the code above as oauth_device_login.py, then run:
Full source: cookbook/90_models/xai/oauth_device_login.py