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.1.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.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

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

Hashes for simple_vertex_bridge-0.3.1.tar.gz
Algorithm Hash digest
SHA256 7fa0611e35be361c877d0345f77f990fc4ee30a696a0ad44865d895b55b73508
MD5 5795c19e544edc811b7c71ebb50f1cb6
BLAKE2b-256 22950aa35755627e7b889127100a91c6f637cb4cfdcbe04a48a5dca03f6e835a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for simple_vertex_bridge-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 edec5beb1705ea42ae5c2d00282010d73ce8216366468e00fb40a038a3537711
MD5 33cd5b180ca62b6d9e88a09eb12e4ae1
BLAKE2b-256 4b9dc329f886bd1a3955a6e473e1cd0055ea3552959f27cae7537a0692d6bc45

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