googleapis / googleapis/python-aiplatform

Add support for custom headers in vertexai.init function

未关闭
#3,526 0 条评论 8 个 reaction 已指派 0 人 在 GitHub 查看
api: vertex-ai
主要语言
Python
星标
905
派生
465
平均合并
1 天 13 小时
30 天内合并 PR
44

描述

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

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。