Learn how to use g4f in your projects
g4f
is very similar to the OpenAI Python Sdk, the g4f completion syntax was made to work exactly like the sdk with some ClassNames being different.Client
Classv1
library of the OpenAi sdk, g4f is initialised with the g4f.client.Client
class.
Client
class accepts several arguments, you can set a default provider there. More on the Provider
structure of g4f
further down.
Client(...)
Class Argumentsclient
object to create chat completions. Here again, client.chat.completions.create
works like the OpenAI sdk, with the same parameters.
create(...)
basic Paramsg4f.Provider.ProviderName
. Different working providers are outlined in the g4f README.create
will return a generator.g4f
with streaming Response, you can do this with stream=True
in the client.chat.completions.create
method.