Skip to main content

Helper for authenticating with VertexAI

Project description

VertexAuth

This is a helper library for accessing Google Vertex AI models

To use it, get a Gcloud Service Account Key File (SAKF), then create a vertexauth "superkey" file like so:

import vertexauth
path=vertexauth.create_superkey_file(SAKF_path='/path/to/gcloud/service_auth_key_file.json',
                                     region='us-east5',
                                     save_as_default=True)

This puts the SAKF and region info into a single file in your .config dir.

Then later, you can create a claudette client or AnthropicVertex client object like so:

import vertexauth, vertexauth.anthropic, vertexauth.claudette, claudette

# AnthropicVertex
anthropic_client = vertexauth.anthropic.get_anthropic_client()
# claudette.Client
claudette_client = vertexauth.claudette.get_claudette_client()
cl_chat = claudette.Chat(cli=claudette_client)
cl_chat("Hi, there!")
# just access the vals
val_dict = vertexauth.load_vertex_vals()

The main functions also let you pass a superkey path.

Also, they can read an env var, VERTEXAUTH_SUPERKEY, which contains a superkey embedded in one string. This lets you share it and use it like a normal API key, except that it will be about 3,000 characters long. Use create_superkey_env_value to create such embedded value.

Huh, what's a Service Account Key File?

You probably wish you could just lay hands on a single API key value, like with other APIs. Me too.

But afaict the closest you can get to this with Google Vertex AI is to generate a "Service Account Key File" (SAKF), a json file with embedded credentials. And even once you have this, you need to supply it along with other coordinated pieces of information (like project ID and region) in order to make an API request against a model. So it's a bit of a hassle., and that's what this helps with.

But how do I get this blessed Service Account Key File from Google

It's not pretty. Here's approximately what you need to do:

  • Go to Google Cloud console
  • Select a project
  • Go to APIs & Services
  • Go to Enabled APIs and Services
  • Select "Vertex AI API" from the list and ensure that it is Enabled"
  • Within that panel, select "Quotas and System Limits"
    • In the filter control, enter the property name "Online prediction requests per base model per minute per region per base_model" to find that row.
    • Scope to a particular region (e.g., "us-east5") and and base_model (e.g., "anthropic-claude-3-5-sonnet-v2")
    • Use "Edit Quota" to ensure that you have a non-zero quote for it
  • Also, within that panel, select "Credentials"
    • Click "+ Create Credentials"
    • Select "Service Account"
    • Enter a name like "vertexaiserviceaccount" etc for the account,
    • For permissions, give it the "Vertex AI Service Agent" role.
    • Go to keys, select "Add key" and select "JSON"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vertexauth-0.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vertexauth-0.1.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file vertexauth-0.1.0.tar.gz.

File metadata

  • Download URL: vertexauth-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.11.0 Darwin/23.6.0

File hashes

Hashes for vertexauth-0.1.0.tar.gz
Algorithm Hash digest
SHA256 019e63d22aee9bcc45a6c14c0a4ca5e9c7d6b4d0a363ab37e9edbc71110927b4
MD5 111579c96957c6d0c9a38a03482963ce
BLAKE2b-256 797a3e836be7b37e08c4d98c97ea7e9ea6ed2072616c4e828ec6359eff2d650c

See more details on using hashes here.

File details

Details for the file vertexauth-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: vertexauth-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.11.0 Darwin/23.6.0

File hashes

Hashes for vertexauth-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a66d0aa830a4715890f4265eeff37fe72378d9f46a36f07f79c8423fc26763a
MD5 c6236b104275e783095164a039150eb6
BLAKE2b-256 f5c818fea530b58bd2874048e1152abc3d0260649bdb1ebe196d39e29741eb40

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page