mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-15 14:51:19 -08:00
Add GeminiPro API provider
Set min version for undetected-chromedriver Add api_key to the new client
This commit is contained in:
parent
51b4aaae05
commit
51264fe20c
11 changed files with 223 additions and 68 deletions
|
|
@ -37,12 +37,16 @@ client = Client(
|
|||
)
|
||||
```
|
||||
|
||||
You also have the option to define a proxy in the client for all outgoing requests:
|
||||
## Configuration
|
||||
|
||||
You can set an "api_key" for your provider in client.
|
||||
And you also have the option to define a proxy for all outgoing requests:
|
||||
|
||||
```python
|
||||
from g4f.client import Client
|
||||
|
||||
client = Client(
|
||||
api_key="...",
|
||||
proxies="http://user:pass@host",
|
||||
...
|
||||
)
|
||||
|
|
@ -74,7 +78,7 @@ stream = client.chat.completions.create(
|
|||
)
|
||||
for chunk in stream:
|
||||
if chunk.choices[0].delta.content:
|
||||
print(chunk.choices[0].delta.content, end="")
|
||||
print(chunk.choices[0].delta.content or "", end="")
|
||||
```
|
||||
|
||||
**Image Generation:**
|
||||
|
|
@ -109,7 +113,28 @@ image_url = response.data[0].url
|
|||
|
||||
Original / Variant:
|
||||
|
||||
[](/docs/client.md)
|
||||
[](/docs/client.md)
|
||||
[](/docs/client.md) [](/docs/client.md)
|
||||
|
||||
#### Advanced example using GeminiProVision
|
||||
|
||||
```python
|
||||
from g4f.client import Client
|
||||
from g4f.Provider.GeminiPro import GeminiPro
|
||||
|
||||
client = Client(
|
||||
api_key="...",
|
||||
provider=GeminiPro
|
||||
)
|
||||
response = client.chat.completions.create(
|
||||
model="gemini-pro-vision",
|
||||
messages=[{"role": "user", "content": "What are on this image?"}],
|
||||
image=open("docs/cat.jpeg", "rb")
|
||||
)
|
||||
print(response.choices[0].message.content)
|
||||
```
|
||||
**Question:** What are on this image?
|
||||
```
|
||||
A cat is sitting on a window sill looking at a bird outside the window.
|
||||
```
|
||||
|
||||
[Return to Home](/)
|
||||
Loading…
Add table
Add a link
Reference in a new issue