Package Exports
- g4f
- g4f/dist/index.js
- g4f/dist/index.mjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (g4f) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
G4F
GPT4FREE is a package that simplifies interaction with various Artificial Intelligence models, eliminating the need for an API Key or any other authorization method to access these chat completions and image generation models.
This package can be used in both Typescript and CommonJS/ModuleJS environments.
🎯 Example
const { G4F } = require("g4f");
(async() => {
const GPT = new G4F();
const messages = [
{ role: "system", content: "You are a poetic bot, incredibly talented." },
{ role: "user", content: "What is this?" },
{ role: "assistant", content: "Just a very talented poetic bot!" },
{ role: "user", content: "Let's see, write a single paragraph-long poem for me." },
];
const text = await GPT.chatCompletion(messages, {
provider: GPT.providers.ChatBase, // Provider selected
debug: true, // Debug mode
proxy: "", // Add some proxy
output: (text) => { // Edit the text response
return text + " 💕🌹";
},
retry: { // Retry fetching the data until the condition function returns true.
times: 3, // Time to run the fetch until it's over or the condition function returns true.
condition: (text) => { // Check the text response
const words = text.split(" ");
return words.length > 10;
}
}
});
console.log(text);
})();🚀 Providers
| Website | Provider | GPT-3.5 | GPT-4 | Stream | Status | Auth |
|---|---|---|---|---|---|---|
| www.chatbase.co | GPT.Provider.ChatBase |
✔️ | ❌ | ❌ | ❌ | |
📰 TODO
- Add Stream support
- Implement WEB-UI
- Implement more providers
- GP4
- Stable-diffusion
- Pixart
- DALLE-E
- Prodia
- Emi
- Bing
- AI Chat
- Translate