xtekky/gpt4

地址 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

然后访问 http://localhost:8080/chat/ 或者作为一个api服务 http://localhost:1337/v1

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
posted @ 2024-10-15 16:00  朝阳1  阅读(7)  评论(0编辑  收藏  举报