Package: g4f
Written by@xtekky& maintained by@hlohausBy using this repository or any code related to it, you agree to thelegal notice. The author isnot responsible for the usage of this repository nor endorses it, nor is the author responsible for any copies, forks, re-uploads made by other users, or anything else related to GPT4Free. This is the author's only account and repository. To prevent impersonation or irresponsible actions, please comply with the GNU GPL license this Repository uses.[!Warning]"gpt4free"serves as aPoC(proof of concept), demonstrating the development of an API package with multi-provider requests, with features like timeouts, load balance and flow control.[!Note]Lastet version:Stats:pipinstall-Ug4fdockerpullhlohaus789/g4f🆕 What's NewGuide: How do I use my smartphone📱to run g4f?/docs/guides/phoneNew: How can AI help me 💁with writing code?/docs/guides/help_meJoin our Telegram Channel:t.me/g4f_channelJoin our Discord Group:discord.gg/XfybzPXPH5🔻 Site TakedownIs your site on this repository and you want to take it down? Send an email totakedown@g4f.aiwith proof it is yours and it will be removed as fast as possible. To prevent reproduction please secure your API ;)🚀  Feedback and TodoYou can always leave some feedback here:https://forms.gle/FeWV9RLEedfdkmFN6As per the survey, here is a list of improvements to comeUpdate the repository to include the new openai library syntax (ex:Openai()class) | completed, useg4f.client.ClientGolang implementation🚧 Improve Documentation (in /docs & Guides, Howtos, & Do video tutorials)Improve the provider status list & updatesTutorials on how to reverse sites to write your own wrapper (PoC only ofc)Improve the Bing wrapper. (might write a new wrapper in golang as it is very fast)Write a standard provider performance test to improve the stabilityPotential support and development of local models🚧 Improve compatibility and error handling📚 Table of Contents🆕 What's New📚 Table of Contents🛠️ Getting StartedDocker containerQuick startUse pythonPrerequisitesInstall using PyPI package:Install from source:Install using Docker:💡 UsageText GenerationImage GenerationWeb UIInterference APIConfiguration🚀 Providers and ModelsGPT-4GPT-3.5OtherModels🔗 Related GPT4Free Projects🤝 ContributeHow do i create a new Provider?How can AI help me with writing code?🙌 Contributors©️ Copyright⭐ Star History📄 License🛠️ Getting StartedDocker containerQuick start:Download and install DockerPull latest image and run the container:dockerpullhlohaus789/g4f
dockerrun-p8080:8080-p1337:1337-p7900:7900--shm-size="2g"hlohaus789/g4f:latestOpen the included client on:http://localhost:8080/chat/or set the API base in your client to:http://localhost:1337/v1(Optional) If you need to log in to a provider, you can view the desktop from the container here:http://localhost:7900/?autoconnect=1&resize=scale&password=secret.Use your smartphone:Run the Web UI on Your Smartphone:/docs/guides/phoneUse pythonPrerequisites:Download and install Python(Version 3.10+ is recommended).Install Google Chromefor providers with webdriverInstall using PyPI package:pip install -U g4f[all]How do I install only parts or do disable parts?
Use partial requirements:/docs/requirementsInstall from source:How do I load the project using git and installing the project requirements?
Read this tutorial and follow it step by step:/docs/gitInstall using Docker:How do I build and run composer image from source?
Use docker-compose:/docs/docker💡 UsageText Generationfromg4f.clientimportClientclient=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?Image Generationfromg4f.clientimportClientclient=Client()response=client.images.generate(model="gemini",prompt="a white siamese cat",...)image_url=response.data[0].urlFull Documentation for Python APINew Client API like the OpenAI Python library:/docs/clientLegacy API with python modules:/docs/legacyWeb UITo start the web interface, type the following codes in python:fromg4f.guiimportrun_guirun_gui()or execute the following command:python-mg4f.cligui-port8080-debugInterference APIYou can use the Interference API to serve other OpenAI integrations with G4F.See:/docs/interferenceConfigurationCookies / Access TokenFor generating images with Bing and for the OpenAI Chat  you need cookies or a token from your browser session. From Bing you need the "_U" cookie and from OpenAI you need the "access_token". You can pass the cookies / the access token in the create function or you use theset_cookiessetter before you run G4F:fromg4f.cookiesimportset_cookiesset_cookies(".bing.com",{"_U":"cookie value"})set_cookies("chat.openai.com",{"access_token":"token value"})set_cookies(".google.com",{"__Secure-1PSID":"cookie value"})...Alternatively, G4F reads the cookies withbrowser_cookie3from your browser
or it starts a browser instance with seleniumwebdriverfor logging in.Using ProxyIf you want to hide or change your IP address for the providers, you can set a proxy globally via an environment variable:On macOS and Linux:exportG4F_PROXY="http://host:port"On Windows:setG4F_PROXY=http://host:port🚀 Providers and ModelsGPT-4WebsiteProviderGPT-3.5GPT-4StreamStatusAuthbing.comg4f.Provider.Bing❌✔️✔️❌liaobots.siteg4f.Provider.Liaobots✔️✔️✔️❌chat.openai.comg4f.Provider.OpenaiChat✔️✔️✔️✔️raycast.comg4f.Provider.Raycast✔️✔️✔️✔️you.comg4f.Provider.You✔️✔️✔️❌chat.geekgpt.orgg4f.Provider.GeekGpt✔️✔️✔️❌GPT-3.5WebsiteProviderGPT-3.5GPT-4StreamStatusAuthchat3.aiyunos.topg4f.Provider.AItianhuSpace✔️❌✔️❌aichatonline.orgg4f.Provider.AiChatOnline✔️❌✔️❌openchat.teamg4f.Provider.Aura✔️❌✔️❌chatbase.cog4f.Provider.ChatBase✔️❌✔️❌chatforai.storeg4f.Provider.ChatForAi✔️❌✔️❌chatgpt.aig4f.Provider.ChatgptAi✔️❌✔️❌chat.chatgptdemo.netg4f.Provider.ChatgptDemo✔️❌✔️❌chatgpt-free.ccg4f.Provider.ChatgptNext✔️❌✔️❌chat.3211000.xyzg4f.Provider.Chatxyz✔️❌✔️❌gptalk.netg4f.Provider.GPTalk✔️❌✔️❌gpt6.aig4f.Provider.Gpt6✔️❌✔️❌gptchatly.comg4f.Provider.GptChatly✔️❌❌❌ai18.gptforlove.comg4f.Provider.GptForLove✔️❌✔️❌gptgo.aig4f.Provider.GptGo✔️❌✔️❌gpttalk.rug4f.Provider.GptTalkRu✔️❌✔️❌koala.shg4f.Provider.Koala✔️❌✔️❌app.myshell.aig4f.Provider.MyShell✔️❌✔️❌onlinegpt.orgg4f.Provider.OnlineGpt✔️❌✔️❌perplexity.aig4f.Provider.PerplexityAi✔️❌✔️❌poe.comg4f.Provider.Poe✔️❌✔️✔️talkai.infog4f.Provider.TalkAi✔️❌✔️❌aitianhu.comg4f.Provider.AItianhu✔️❌✔️❌e.aiask.meg4f.Provider.AiAsk✔️❌✔️❌chatgpt.bestim.orgg4f.Provider.Bestim✔️❌✔️❌chatanywhere.cng4f.Provider.ChatAnywhere✔️❌✔️❌chatgpt4online.orgg4f.Provider.Chatgpt4Online✔️❌✔️❌chat.chatgptdemo.aig4f.Provider.ChatgptDemoAi✔️❌✔️❌chatgptfree.aig4f.Provider.ChatgptFree✔️❌❌❌chatgptlogin.aig4f.Provider.ChatgptLogin✔️❌✔️❌chatgptx.deg4f.Provider.ChatgptX✔️❌✔️❌chat-shared2.zhile.iog4f.Provider.FakeGpt✔️❌✔️❌freegpts1.aifree.siteg4f.Provider.FreeGpt✔️❌✔️❌gptgod.siteg4f.Provider.GptGod✔️❌✔️❌hashnode.comg4f.Provider.Hashnode✔️❌✔️❌sdk.vercel.aig4f.Provider.Vercel✔️❌✔️❌chat.ylokh.xyzg4f.Provider.Ylokh✔️❌✔️❌OtherWebsiteProviderGPT-3.5GPT-4StreamStatusAuthbard.google.comg4f.Provider.Bard❌❌❌✔️deepinfra.comg4f.Provider.DeepInfra❌❌✔️❌gemini.google.comg4f.Provider.Gemini❌❌✔️✔️ai.google.devg4f.Provider.GeminiPro❌❌✔️❌gemini-chatbot-sigma.vercel.appg4f.Provider.GeminiProChat✔️❌✔️❌huggingface.cog4f.Provider.HuggingChat❌❌✔️❌llama2.aig4f.Provider.Llama2❌❌✔️❌labs.perplexity.aig4f.Provider.PerplexityLabs❌❌✔️❌phind.comg4f.Provider.Phind❌❌✔️❌pi.aig4f.Provider.Pi❌❌✔️❌beta.theb.aig4f.Provider.Theb✔️✔️✔️❌free.chatgpt.org.ukg4f.Provider.FreeChatgpt✔️✔️✔️❌theb.aig4f.Provider.ThebApi❌❌❌✔️open-assistant.iog4f.Provider.OpenAssistant❌❌✔️✔️ModelsModelBase ProviderProviderWebsitegpt-3.5-turboOpenAI5+ Providersopenai.comgpt-4OpenAI2+ Providersopenai.comgpt-4-turboOpenAIg4f.Provider.Bingopenai.comLlama-2-7b-chat-hfMeta2+ Providersllama.meta.comLlama-2-13b-chat-hfMeta2+ Providersllama.meta.comLlama-2-70b-chat-hfMeta4+ Providersllama.meta.comCodeLlama-34b-Instruct-hfMeta3+ Providersllama.meta.comCodeLlama-70b-Instruct-hfMetag4f.Provider.DeepInfrallama.meta.comMixtral-8x7B-Instruct-v0.1Huggingface3+ Providershuggingface.coMistral-7B-Instruct-v0.1Huggingface3+ Providershuggingface.codolphin-2.6-mixtral-8x7bHuggingfaceg4f.Provider.DeepInfrahuggingface.colzlv_70b_fp16_hfHuggingfaceg4f.Provider.DeepInfrahuggingface.coairoboros-70bHuggingfaceg4f.Provider.DeepInfrahuggingface.coairoboros-l2-70b-gpt4-1.4.1Huggingfaceg4f.Provider.DeepInfrahuggingface.coopenchat_3.5Huggingface2+ Providershuggingface.cogeminiGoogleg4f.Provider.Geminigemini.google.comgemini-proGoogle2+ Providersgemini.google.comclaude-v2Anthropic2+ Providersanthropic.compiInflectiong4f.Provider.Piinflection.ai🔗 Related GPT4Free Projects🎁 Projects⭐ Stars📚 Forks🛎 Issues📬 Pull requestsgpt4freegpt4free-tsFree AI API's & Potential Providers ListChatGPT-CloneChatGpt Discord BotNyx-Bot (Discord)LangChain gpt4freeChatGpt Telegram BotChatGpt Line BotAction Translate ReadmeLangchain Document GPTpython-tgpt🤝 ContributeWe welcome contributions from the community. Whether you're adding new providers or features, or simply fixing typos and making small improvements, your input is valued. Creating a pull request is all it takes – our co-pilot will handle the code review process. Once all changes have been addressed, we'll merge the pull request into the main branch and release the updates at a later time.Guide: How do i create a new Provider?Read:/docs/guides/create_providerGuide: How can AI help me with writing code?Read:/docs/guides/help_me🙌 ContributorsA list of all contributors is availablehereTheVercel.pyfile contains code fromvercel-llm-apiby@ading2210, which is licensed under theGNU GPL v3Top 1 Contributor:@hlohaus©️ CopyrightThis program is licensed under theGNU GPL v3xtekky/gpt4free: Copyright (C) 2023 xtekky

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.⭐ Star History📄 LicenseThis project is licensed underGNU_GPL_v3.0.(🔼 Back to top)