A simple Vertex AI proxy that automatically refresh tokens for you.
Project description
Simple Vertex Bridge
A simple Vertex AI proxy that automatically refresh tokens for you.
Feature
- OpenAI style chat completion API with token attached
- OpenAI style model list API
- Automatically refresh tokens
- Stream output
- Reused h2 connection
Usage
Prerequisites
- Install uv.
Authentication
There are two ways to authenticate:
- By gcloud CLI
- Install gcloud CLI.
- Run
gcloud auth application-default loginto authenticate.
- By service account key
- Create a service account key in the Google Cloud Console, according to this documentation.
- Download the json key file.
- Set the
GOOGLE_APPLICATION_CREDENTIALSenvironment variable to the path of the key file.
Launch
- Note:
svbridge-config.jsonwill be created in the current directory.
- You can run
uvx simple-vertex-bridgeto launch the bridge directly from pypi. - Or clone this repo and enter and run
uv sync, then activate venv and runpython svbridge.py.
Now your API is ready
- Model List:
http://localhost:8086/v1/models, v1 can be omitted. - API Endpoint:
http://localhost:8086/v1/chat/completions, v1 can be omitted. - API Key: Default is anything (if you specify a key, you must use it), will be replaced with Vertex AI token.
CLI Arguments
The bridge uses a configuration file svbridge-config.json located in the current working directory. It's created automatically on the first run if it doesn't exist.
You can override the configuration using command-line arguments when launching the bridge. These arguments will also update the configuration file.
-p [PORT],--port [PORT]: Port to listen on (default: 8086).-b [BIND],--bind [BIND]: Host address to bind to (default: localhost).-k [KEY],--key [KEY]: Specify the API key required for authentication. If not set (default), any key will be accepted.--auto-refresh/--no-auto-refresh: Enable/disable automatic background refresh of the Vertex token (default: enabled).--filter-model-names/--no-filter-model-names: Enable/disable filtering of common model names in the/modelsendpoint (default: enabled).-h,--help: Show help message.
Example:
# Run publicly on port 8848 and set key 'svb-cRztHvmE50'
python svbridge.py -p 8848 -b 0.0.0.0 -k svb-cRztHvmE50
License
The Unlicense.
TBH I dont care what you do with this code, just dont sue me if it breaks something. uwu
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simple_vertex_bridge-0.3.1.tar.gz.
File metadata
- Download URL: simple_vertex_bridge-0.3.1.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fa0611e35be361c877d0345f77f990fc4ee30a696a0ad44865d895b55b73508
|
|
| MD5 |
5795c19e544edc811b7c71ebb50f1cb6
|
|
| BLAKE2b-256 |
22950aa35755627e7b889127100a91c6f637cb4cfdcbe04a48a5dca03f6e835a
|
File details
Details for the file simple_vertex_bridge-0.3.1-py3-none-any.whl.
File metadata
- Download URL: simple_vertex_bridge-0.3.1-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
edec5beb1705ea42ae5c2d00282010d73ce8216366468e00fb40a038a3537711
|
|
| MD5 |
33cd5b180ca62b6d9e88a09eb12e4ae1
|
|
| BLAKE2b-256 |
4b9dc329f886bd1a3955a6e473e1cd0055ea3552959f27cae7537a0692d6bc45
|