Gemini代理
·
使用Google GenAI库调用Gemini 2.5 Pro模型生成文本。代码示例展示了如何设置HTTP选项(包括自定义API基地址),初始化客户端(需提供API密钥),并通过简单提示"hello"获取模型响应。最后打印生成的文本内容。该流程适用于集成Gemini大模型的基础API调用场景。
from google import genai
from google.genai.types import HttpOptions
http_options: Optional[HttpOptions] = HttpOptions(base_url="https://api.xxxx.com")
client = genai.Client(api_key="iskey", http_options=http_options)
prompt = "hello"
response = client.models.generate_content(model="gemini-2.5-pro", contents=prompt)
print(response.text)
更多推荐
所有评论(0)