googleapis / googleapis/python-aiplatform

Add support for custom headers in vertexai.init function

Offen
#3,526 0 Kommentare 8 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
api: vertex-ai
Vorherrschende Sprache
Python
Sterne
905
Forks
465
Ø Merge
1 T. 13 Std.
Gemergte PRs (30 T.)
44

Beschreibung

**Is your feature request related to a problem? Please describe.**
I cannot find option for adding custom headers to VertexAI Gemini API.

**Describe the solution you'd like**
I'm trying to implement proxy between end client and VertexAI Gemini API. In my implementation custom HTTP headers are must have requirement. I would like to ask for adding option to vertexai.init or any other place to add HTTP headers, similar as it is in genai gemini library.
**Describe alternatives you've considered**
Actually there are no alternatives. Headers are must have.
**Additional context**
Example for custom headers in google.generativeai (https://github.com/google/generative-ai-python)
```
import google.generativeai as genai
genai.configure(
api_key="mytoken",
transport="rest",
client_options={
"api_endpoint": "https://my/custom/proxy"
},
default_metadata=tuple(my_headers.items()),
)
```

My proposal for vertexai.init:
```
import vertexai
from vertexai.generative_models import GenerativeModel
vertexai.init(
api_endpoint="https://my/custom/proxy",
api_transport="rest",
default_metadata=tuple(my_headers.items()), # New argument
)

multimodal_model = GenerativeModel("gemini-1.0-pro-vision")
response = multimodal_model.generate_content(
[
"How are you",
]
)
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.