地址 xtekky/gpt4free?tab=readme-ov-file#image-generation
最简单的docker部署
docker run -p 8080:8080 -p 1337:1337 -p 7900:7900 --shm-size="2g" -v ${PWD}/hardir:/app/hardir hlohaus789/g4f:latest
python版本部署
pip install -U g4f[all]
from g4f.client import Client
client = Client()
response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": "Hello"}],
...
)
print(response.choices[0].message.content)
# Hello! How can I assist you today?
生成图片
from g4f.client import Client
from g4f.cookies import set_cookies
set_cookies(".bing.com", {
"_U": "cookie value"
})
set_cookies(".谷歌.com", {
"__Secure-1PSID": "cookie value"
})
client = Client()
response = client.images.generate(
model="gemini",
prompt="a white siamese cat",
)
image_url = response.data[0].url