Skip to main content

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:

  1. By gcloud CLI
    • Install gcloud CLI.
    • Run gcloud auth application-default login to authenticate.
  2. 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_CREDENTIALS environment variable to the path of the key file.

Launch

  • Note: svbridge-config.json will be created in the current directory.
  1. You can run uvx simple-vertex-bridge to launch the bridge directly from pypi.
  2. Or clone this repo and enter and run uv sync, then activate venv and run python 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 /models endpoint (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

simple_vertex_bridge-0.3.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

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

simple_vertex_bridge-0.3.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file simple_vertex_bridge-0.3.0.tar.gz.

File metadata

  • Download URL: simple_vertex_bridge-0.3.0.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

Hashes for simple_vertex_bridge-0.3.0.tar.gz
Algorithm Hash digest
SHA256 dfb7554ae510d96e64a48bbb81edb1da4dcb3e210a19c373469102bafa843953
MD5 ee64e42bb3ded91c8bd1a37381154295
BLAKE2b-256 6732cdf056e486eebf5645a472dff2a5a53ef21cc0701f70f5bb9e2240cb19d2

See more details on using hashes here.

File details

Details for the file simple_vertex_bridge-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_vertex_bridge-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f4b10b633bcfc57d8c46d88f4208dfd07309f5727482019097108f1f6bdc97fe
MD5 9add800fea23212e5aa16e71eb6ff8dc
BLAKE2b-256 4776685c7958e89986caed979bca3ec36635eeeba190965e41276b8e727e1d98

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