googleapis / googleapis/python-aiplatform

Add support for custom headers in vertexai.init function

Aperta
#3,526 0 commenti 8 reazioni 0 assegnatari Vedi su GitHub
api: vertex-ai
Lingua principale
Python
Stelle
905
Fork
465
Merge medio
1g 13h
PR unite (30g)
44

Descrizione

**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",
]
)
```

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.