All AI Studio API requests require authentication via an API access token (Bearer <token>.) Requests without a valid token will return a 401 Unauthorized response.
To authenticate a request using the access token (Bearer Token), you would first need to generate the token (if you have not already done so) steps detailed below and then include it in the request via the Authorization header. Replace <token> with your valid token.
Authorization: Bearer <token>
Classic Sidebar
Generating an API access token
1
Sign in to your AI Studio account.
Start by signing in to your AI Studio account.
Once signed in, click the More dropdown located above the Go Online toggle, if it is not already open.
After the dropdown opens, choose the Developers option and wait for the developers tab to load.
2
Generating the token
Once the Developers screen has fully loaded, select the API Access Token tab.
After the tab loads, click Generate API Token.
If the only option you see is Revoke API Token, then the token has already been generated.
In that case, simply click the copy icon next to the existing or newly generated token.