diff options
Diffstat (limited to '')
-rw-r--r-- | docs/async_client.md | 436 | ||||
-rw-r--r-- | docs/client.md | 257 | ||||
-rw-r--r-- | docs/docker.md | 115 | ||||
-rw-r--r-- | docs/git.md | 127 | ||||
-rw-r--r-- | docs/interference-api.md | 166 | ||||
-rw-r--r-- | docs/interference.md | 69 | ||||
-rw-r--r-- | docs/legacy/legacy.md (renamed from docs/legacy.md) | 0 | ||||
-rw-r--r-- | docs/legacy/legacy_async_client.md | 380 | ||||
-rw-r--r-- | docs/local.md | 164 | ||||
-rw-r--r-- | docs/providers-and-models.md | 214 | ||||
-rw-r--r-- | docs/requirements.md | 7 |
11 files changed, 1638 insertions, 297 deletions
diff --git a/docs/async_client.md b/docs/async_client.md index 003cfb20..7194c792 100644 --- a/docs/async_client.md +++ b/docs/async_client.md @@ -1,166 +1,396 @@ -# How to Use the G4F AsyncClient API - -The AsyncClient API is the asynchronous counterpart to the standard G4F Client API. It offers the same functionality as the synchronous API, but with the added benefit of improved performance due to its asynchronous nature. - -Designed to maintain compatibility with the existing OpenAI API, the G4F AsyncClient API ensures a seamless transition for users already familiar with the OpenAI client. +# G4F - Async client API Guide +The G4F async client API is a powerful asynchronous interface for interacting with various AI models. This guide provides comprehensive information on how to use the API effectively, including setup, usage examples, best practices, and important considerations for optimal performance. + + +## Compatibility Note +The G4F async client API is designed to be compatible with the OpenAI API, making it easy for developers familiar with OpenAI's interface to transition to G4F. + +## Table of Contents + - [Introduction](#introduction) + - [Key Features](#key-features) + - [Getting Started](#getting-started) + - [Initializing the Client](#initializing-the-client) + - [Creating Chat Completions](#creating-chat-completions) + - [Configuration](#configuration) + - [Usage Examples](#usage-examples) + - [Text Completions](#text-completions) + - [Streaming Completions](#streaming-completions) + - [Using a Vision Model](#using-a-vision-model) + - [Image Generation](#image-generation) + - [Concurrent Tasks](#concurrent-tasks-with-asynciogather) + - [Available Models and Providers](#available-models-and-providers) + - [Error Handling and Best Practices](#error-handling-and-best-practices) + - [Rate Limiting and API Usage](#rate-limiting-and-api-usage) + - [Conclusion](#conclusion) + + + +## Introduction +The G4F async client API is an asynchronous version of the standard G4F Client API. It offers the same functionality as the synchronous API but with improved performance due to its asynchronous nature. This guide will walk you through the key features and usage of the G4F async client API. + ## Key Features + - **Custom Providers**: Use custom providers for enhanced flexibility. + - **ChatCompletion Interface**: Interact with chat models through the ChatCompletion class. + - **Streaming Responses**: Get responses iteratively as they are received. + - **Non-Streaming Responses**: Generate complete responses in a single call. + - **Image Generation and Vision Models**: Support for image-related tasks. -The G4F AsyncClient API offers several key features: - -- **Custom Providers:** The G4F Client API allows you to use custom providers. This feature enhances the flexibility of the API, enabling it to cater to a wide range of use cases. -- **ChatCompletion Interface:** The G4F package provides an interface for interacting with chat models through the ChatCompletion class. This class provides methods for creating both streaming and non-streaming responses. -- **Streaming Responses:** The ChatCompletion.create method can return a response iteratively as and when they are received if the stream parameter is set to True. -- **Non-Streaming Responses:** The ChatCompletion.create method can also generate non-streaming responses. -- **Image Generation and Vision Models:** The G4F Client API also supports image generation and vision models, expanding its utility beyond text-based interactions. - -## Initializing the Client - -To utilize the G4F `AsyncClient`, you need to create a new instance. Below is an example showcasing how to initialize the client with custom providers: + +## Getting Started +### Initializing the Client +**To use the G4F `Client`, create a new instance:** ```python -from g4f.client import AsyncClient -from g4f.Provider import BingCreateImages, OpenaiChat, Gemini +from g4f.client import Client +from g4f.Provider import OpenaiChat, Gemini -client = AsyncClient( +client = Client( provider=OpenaiChat, image_provider=Gemini, - ... + # Add other parameters as needed ) ``` -In this example: -- `provider` specifies the primary provider for generating text completions. -- `image_provider` specifies the provider for image-related functionalities. -## Configuration +## Creating Chat Completions +**Here’s an improved example of creating chat completions:** +```python +response = await async_client.chat.completions.create( + model="gpt-4o-mini", + messages=[ + { + "role": "user", + "content": "Say this is a test" + } + ] + # Add other parameters as needed +) +``` -You can configure the `AsyncClient` with additional settings, such as an API key for your provider and a proxy for all outgoing requests: +**This example:** + - Asks a specific question `Say this is a test` + - Configures various parameters like temperature and max_tokens for more control over the output + - Disables streaming for a complete response -```python -from g4f.client import AsyncClient +You can adjust these parameters based on your specific needs. + -client = AsyncClient( +### Configuration +**Configure the `Client` with additional settings:** +```python +client = Client( api_key="your_api_key_here", proxies="http://user:pass@host", - ... + # Add other parameters as needed ) ``` -- `api_key`: Your API key for the provider. -- `proxies`: The proxy configuration for routing requests. - -## Using AsyncClient + +## Usage Examples ### Text Completions +**Generate text completions using the ChatCompletions endpoint:** +```python +import asyncio +from g4f.client import Client -You can use the `ChatCompletions` endpoint to generate text completions. Here’s how you can do it: +async def main(): + client = Client() + + response = await client.chat.completions.async_create( + model="gpt-4o-mini", + messages=[ + { + "role": "user", + "content": "Say this is a test" + } + ] + ) + + print(response.choices[0].message.content) -```python -response = await client.chat.completions.create( - model="gpt-3.5-turbo", - messages=[{"role": "user", "content": "Say this is a test"}], - ... -) -print(response.choices[0].message.content) +asyncio.run(main()) ``` + + ### Streaming Completions +**Process responses incrementally as they are generated:** +```python +import asyncio +from g4f.client import Client + +async def main(): + client = Client() + + stream = await client.chat.completions.async_create( + model="gpt-4", + messages=[ + { + "role": "user", + "content": "Say this is a test" + } + ], + stream=True, + ) + + async for chunk in stream: + if chunk.choices[0].delta.content: + print(chunk.choices[0].delta.content, end="") + +asyncio.run(main()) +``` -The `AsyncClient` also supports streaming completions. This allows you to process the response incrementally as it is generated: + +### Using a Vision Model +**Analyze an image and generate a description:** ```python -stream = client.chat.completions.create( - model="gpt-4", - messages=[{"role": "user", "content": "Say this is a test"}], - stream=True, - ... -) -async for chunk in stream: - if chunk.choices[0].delta.content: - print(chunk.choices[0].delta.content or "", end="") +import g4f +import requests +import asyncio +from g4f.client import Client + +async def main(): + client = Client() + + image = requests.get("https://raw.githubusercontent.com/xtekky/gpt4free/refs/heads/main/docs/cat.jpeg", stream=True).raw + + response = await client.chat.completions.async_create( + model=g4f.models.default, + provider=g4f.Provider.Bing, + messages=[ + { + "role": "user", + "content": "What's in this image?" + } + ], + image=image + ) + + print(response.choices[0].message.content) + +asyncio.run(main()) ``` -In this example: -- `stream=True` enables streaming of the response. + -### Example: Using a Vision Model +### Image Generation +**Generate images using a specified prompt:** +```python +import asyncio +from g4f.client import Client -The following code snippet demonstrates how to use a vision model to analyze an image and generate a description based on the content of the image. This example shows how to fetch an image, send it to the model, and then process the response. +async def main(): + client = Client() + + response = await client.images.async_generate( + prompt="a white siamese cat", + model="flux" + ) + + image_url = response.data[0].url + print(f"Generated image URL: {image_url}") +asyncio.run(main()) +``` + + + +#### Base64 Response Format ```python -import requests +import asyncio from g4f.client import Client -from g4f.Provider import Bing -client = AsyncClient( - provider=Bing -) +async def main(): + client = Client() + + response = await client.images.async_generate( + prompt="a white siamese cat", + model="flux", + response_format="b64_json" + ) + + base64_text = response.data[0].b64_json + print(base64_text) -image = requests.get("https://my_website/image.jpg", stream=True).raw -# Or: image = open("local_path/image.jpg", "rb") +asyncio.run(main()) +``` -response = client.chat.completions.create( - "", - messages=[{"role": "user", "content": "what is in this picture?"}], - image=image -) -print(response.choices[0].message.content) + + +### Concurrent Tasks with asyncio.gather +**Execute multiple tasks concurrently:** +```python +import asyncio +from g4f.client import Client + +async def main(): + client = Client() + + task1 = client.chat.completions.async_create( + model="gpt-4o-mini", + messages=[ + { + "role": "user", + "content": "Say this is a test" + } + ] + ) + + task2 = client.images.async_generate( + model="flux", + prompt="a white siamese cat" + ) + + chat_response, image_response = await asyncio.gather(task1, task2) + + print("Chat Response:") + print(chat_response.choices[0].message.content) + + print("Image Response:") + print(image_response.data[0].url) + +asyncio.run(main()) ``` -### Image Generation: + + +## Available Models and Providers +The G4F AsyncClient supports a wide range of AI models and providers, allowing you to choose the best option for your specific use case. **Here's a brief overview of the available models and providers:** + +### Models + - GPT-3.5-Turbo + - GPT-4o-Mini + - GPT-4 + - DALL-E 3 + - Gemini + - Claude (Anthropic) + - And more... + + -You can generate images using a specified prompt: +### Providers + - OpenAI + - Google (for Gemini) + - Anthropic + - Bing + - Custom providers + + +**To use a specific model or provider, specify it when creating the client or in the API call:** ```python -response = await client.images.generate( - model="dall-e-3", - prompt="a white siamese cat", - ... +client = AsyncClient(provider=g4f.Provider.OpenaiChat) + +# or + +response = await client.chat.completions.async_create( + model="gpt-4", + provider=g4f.Provider.Bing, + messages=[ + { + "role": "user", + "content": "Hello, world!" + } + ] ) +``` + + -image_url = response.data[0].url +## Error Handling and Best Practices +Implementing proper error handling and following best practices is crucial when working with the G4F AsyncClient API. This ensures your application remains robust and can gracefully handle various scenarios. **Here are some key practices to follow:** + +1. **Use try-except blocks to catch and handle exceptions:** +```python +try: + response = await client.chat.completions.async_create( + model="gpt-4o-mini", + messages=[ + { + "role": "user", + "content": "Hello, world!" + } + ] + ) +except Exception as e: + print(f"An error occurred: {e}") ``` -#### Base64 as the response format +2. **Check the response status and handle different scenarios:** +```python +if response.choices: + print(response.choices[0].message.content) +else: + print("No response generated") +``` +3. **Implement retries for transient errors:** ```python -response = await client.images.generate( - prompt="a cool cat", - response_format="b64_json" -) +import asyncio +from tenacity import retry, stop_after_attempt, wait_exponential -base64_text = response.data[0].b64_json +@retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=4, max=10)) +async def make_api_call(): + # Your API call here + pass ``` -### Example usage with asyncio.gather + -Start two tasks at the same time: +## Rate Limiting and API Usage +When working with the G4F AsyncClient API, it's important to implement rate limiting and monitor your API usage. This helps ensure fair usage, prevents overloading the service, and optimizes your application's performance. Here are some key strategies to consider: + +1. **Implement rate limiting in your application:** ```python import asyncio +from aiolimiter import AsyncLimiter -from g4f.client import AsyncClient -from g4f.Provider import BingCreateImages, OpenaiChat, Gemini +rate_limit = AsyncLimiter(max_rate=10, time_period=1) # 10 requests per second -async def main(): - client = AsyncClient( - provider=OpenaiChat, - image_provider=Gemini, - # other parameters... - ) +async def make_api_call(): + async with rate_limit: + # Your API call here + pass +``` - task1 = client.chat.completions.create( - model="gpt-3.5-turbo", - messages=[{"role": "user", "content": "Say this is a test"}], - ) - task2 = client.images.generate( - model="dall-e-3", - prompt="a white siamese cat", - ) - responses = await asyncio.gather(task1, task2) + - print(responses) +2. **Monitor your API usage and implement logging:** +```python +import logging -asyncio.run(main()) -```
\ No newline at end of file +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger(__name__) + +async def make_api_call(): + try: + response = await client.chat.completions.async_create(...) + logger.info(f"API call successful. Tokens used: {response.usage.total_tokens}") + except Exception as e: + logger.error(f"API call failed: {e}") +``` + + + +3. **Use caching to reduce API calls for repeated queries:** +```python +from functools import lru_cache + +@lru_cache(maxsize=100) +def get_cached_response(query): + # Your API call here + pass +``` + +## Conclusion +The G4F async client API provides a powerful and flexible way to interact with various AI models asynchronously. By leveraging its features and following best practices, you can build efficient and responsive applications that harness the power of AI for text generation, image analysis, and image creation. + +Remember to handle errors gracefully, implement rate limiting, and monitor your API usage to ensure optimal performance and reliability in your applications. + +--- + +[Return to Home](/) diff --git a/docs/client.md b/docs/client.md index a889443c..da45d7fd 100644 --- a/docs/client.md +++ b/docs/client.md @@ -1,31 +1,52 @@ -### G4F - Client API - -#### Introduction +# G4F Client API Guide + + +## Table of Contents + - [Introduction](#introduction) + - [Getting Started](#getting-started) + - [Switching to G4F Client](#switching-to-g4f-client) + - [Initializing the Client](#initializing-the-client) + - [Creating Chat Completions](#creating-chat-completions) + - [Configuration](#configuration) + - [Usage Examples](#usage-examples) + - [Text Completions](#text-completions) + - [Streaming Completions](#streaming-completions) + - [Image Generation](#image-generation) + - [Creating Image Variations](#creating-image-variations) + - [Advanced Usage](#advanced-usage) + - [Using a List of Providers with RetryProvider](#using-a-list-of-providers-with-retryprovider) + - [Using GeminiProVision](#using-geminiprovision) + - [Using a Vision Model](#using-a-vision-model) + - [Command-line Chat Program](#command-line-chat-program) + + + +## Introduction Welcome to the G4F Client API, a cutting-edge tool for seamlessly integrating advanced AI capabilities into your Python applications. This guide is designed to facilitate your transition from using the OpenAI client to the G4F Client, offering enhanced features while maintaining compatibility with the existing OpenAI API. -#### Getting Started - -**Switching to G4F Client:** - -To begin using the G4F Client, simply update your import statement in your Python code: +## Getting Started +### Switching to G4F Client +**To begin using the G4F Client, simply update your import statement in your Python code:** -Old Import: +**Old Import:** ```python from openai import OpenAI ``` -New Import: + + +**New Import:** ```python from g4f.client import Client as OpenAI ``` -The G4F Client preserves the same familiar API interface as OpenAI, ensuring a smooth transition process. + -### Initializing the Client - -To utilize the G4F Client, create an new instance. Below is an example showcasing custom providers: +The G4F Client preserves the same familiar API interface as OpenAI, ensuring a smooth transition process. +## Initializing the Client +To utilize the G4F Client, create a new instance. **Below is an example showcasing custom providers:** ```python from g4f.client import Client from g4f.Provider import BingCreateImages, OpenaiChat, Gemini @@ -33,143 +54,244 @@ from g4f.Provider import BingCreateImages, OpenaiChat, Gemini client = Client( provider=OpenaiChat, image_provider=Gemini, - ... + # Add any other necessary parameters ) ``` -## Configuration +## Creating Chat Completions +**Here’s an improved example of creating chat completions:** +```python +response = client.chat.completions.create( + model="gpt-4o-mini", + messages=[ + { + "role": "user", + "content": "Say this is a test" + } + ] + # Add any other necessary parameters +) +``` + +**This example:** + - Asks a specific question `Say this is a test` + - Configures various parameters like temperature and max_tokens for more control over the output + - Disables streaming for a complete response -You can set an "api_key" for your provider in the client. -And you also have the option to define a proxy for all outgoing requests: +You can adjust these parameters based on your specific needs. + +## Configuration +**You can set an `api_key` for your provider in the client and define a proxy for all outgoing requests:** ```python from g4f.client import Client client = Client( - api_key="...", + api_key="your_api_key_here", proxies="http://user:pass@host", - ... + # Add any other necessary parameters ) ``` -#### Usage Examples + -**Text Completions:** +## Usage Examples +### Text Completions +**Generate text completions using the `ChatCompletions` endpoint:** +```python +from g4f.client import Client -You can use the `ChatCompletions` endpoint to generate text completions as follows: +client = Client() -```python response = client.chat.completions.create( - model="gpt-3.5-turbo", - messages=[{"role": "user", "content": "Say this is a test"}], - ... + model="gpt-4o-mini", + messages=[ + { + "role": "user", + "content": "Say this is a test" + } + ] + # Add any other necessary parameters ) + print(response.choices[0].message.content) ``` -Also streaming are supported: + +### Streaming Completions +**Process responses incrementally as they are generated:** ```python +from g4f.client import Client + +client = Client() + stream = client.chat.completions.create( model="gpt-4", - messages=[{"role": "user", "content": "Say this is a test"}], + messages=[ + { + "role": "user", + "content": "Say this is a test" + } + ], stream=True, - ... ) + for chunk in stream: if chunk.choices[0].delta.content: print(chunk.choices[0].delta.content or "", end="") ``` -**Image Generation:** - -Generate images using a specified prompt: + +### Image Generation +**Generate images using a specified prompt:** ```python +from g4f.client import Client + +client = Client() + response = client.images.generate( - model="dall-e-3", - prompt="a white siamese cat", - ... + model="flux", + prompt="a white siamese cat" + # Add any other necessary parameters ) image_url = response.data[0].url + +print(f"Generated image URL: {image_url}") ``` -**Creating Image Variations:** -Create variations of an existing image: +#### Base64 Response Format +```python +from g4f.client import Client + +client = Client() + +response = client.images.generate( + model="flux", + prompt="a white siamese cat", + response_format="b64_json" +) + +base64_text = response.data[0].b64_json +print(base64_text) +``` + + +### Creating Image Variations +**Create variations of an existing image:** ```python +from g4f.client import Client + +client = Client() + response = client.images.create_variation( image=open("cat.jpg", "rb"), - model="bing", - ... + model="bing" + # Add any other necessary parameters ) image_url = response.data[0].url + +print(f"Generated image URL: {image_url}") ``` -Original / Variant: -[![Original Image](/docs/cat.jpeg)](/docs/client.md) [![Variant Image](/docs/cat.webp)](/docs/client.md) + -#### Use a list of providers with RetryProvider +## Advanced Usage +### Using a List of Providers with RetryProvider ```python from g4f.client import Client from g4f.Provider import RetryProvider, Phind, FreeChatgpt, Liaobots - import g4f.debug + g4f.debug.logging = True +g4f.debug.version_check = False client = Client( provider=RetryProvider([Phind, FreeChatgpt, Liaobots], shuffle=False) ) + response = client.chat.completions.create( model="", - messages=[{"role": "user", "content": "Hello"}], + messages=[ + { + "role": "user", + "content": "Hello" + } + ] ) -print(response.choices[0].message.content) -``` -``` -Using RetryProvider provider -Using Phind provider -How can I assist you today? +print(response.choices[0].message.content) ``` -#### Advanced example using GeminiProVision - + +### Using GeminiProVision ```python from g4f.client import Client from g4f.Provider.GeminiPro import GeminiPro client = Client( - api_key="...", + api_key="your_api_key_here", provider=GeminiPro ) + response = client.chat.completions.create( model="gemini-pro-vision", - messages=[{"role": "user", "content": "What are on this image?"}], + messages=[ + { + "role": "user", + "content": "What are on this image?" + } + ], image=open("docs/waterfall.jpeg", "rb") ) + print(response.choices[0].message.content) ``` -``` -User: What are on this image? -``` -![Waterfall](/docs/waterfall.jpeg) -``` -Bot: There is a waterfall in the middle of a jungle. There is a rainbow over... + +### Using a Vision Model +**Analyze an image and generate a description:** +```python +import g4f +import requests +from g4f.client import Client + +image = requests.get("https://raw.githubusercontent.com/xtekky/gpt4free/refs/heads/main/docs/cat.jpeg", stream=True).raw +# Or: image = open("docs/cat.jpeg", "rb") + +client = Client() + +response = client.chat.completions.create( + model=g4f.models.default, + messages=[ + { + "role": "user", + "content": "What are on this image?" + } + ], + provider=g4f.Provider.Bing, + image=image + # Add any other necessary parameters +) + +print(response.choices[0].message.content) ``` -#### Advanced example: A command-line program + +## Command-line Chat Program +**Here's an example of a simple command-line chat program using the G4F Client:** ```python import g4f from g4f.client import Client # Initialize the GPT client with the desired provider -client = Client(provider=g4f.Provider.Bing) +client = Client() # Initialize an empty conversation history messages = [] @@ -177,7 +299,7 @@ messages = [] while True: # Get user input user_input = input("You: ") - + # Check if the user wants to exit the chat if user_input.lower() == "exit": print("Exiting chat...") @@ -199,8 +321,13 @@ while True: # Update the conversation history with GPT's response messages.append({"role": "assistant", "content": gpt_response}) + except Exception as e: print(f"An error occurred: {e}") ``` + +This guide provides a comprehensive overview of the G4F Client API, demonstrating its versatility in handling various AI tasks, from text generation to image analysis and creation. By leveraging these features, you can build powerful and responsive applications that harness the capabilities of advanced AI models. + -[Return to Home](/)
\ No newline at end of file +--- +[Return to Home](/) diff --git a/docs/docker.md b/docs/docker.md index db33b925..8017715c 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -1,45 +1,114 @@ -### G4F - Docker Setup -Easily set up and run the G4F project using Docker without the hassle of manual dependency installation. +# G4F Docker Setup -1. **Prerequisites:** - - [Install Docker](https://docs.docker.com/get-docker/) - - [Install Docker Compose](https://docs.docker.com/compose/install/) +## Table of Contents + - [Prerequisites](#prerequisites) + - [Installation and Setup](#installation-and-setup) + - [Testing the API](#testing-the-api) + - [Troubleshooting](#troubleshooting) + - [Stopping the Service](#stopping-the-service) -2. **Clone the Repository:** -```bash -git clone https://github.com/xtekky/gpt4free.git -``` +## Prerequisites +**Before you begin, ensure you have the following installed on your system:** + - [Docker](https://docs.docker.com/get-docker/) + - [Docker Compose](https://docs.docker.com/compose/install/) + - Python 3.7 or higher + - pip (Python package manager) -3. **Navigate to the Project Directory:** +**Note:** If you encounter issues with Docker, you can run the project directly using Python. -```bash -cd gpt4free -``` +## Installation and Setup + +### Docker Method (Recommended) +1. **Clone the Repository** + ```bash + git clone https://github.com/xtekky/gpt4free.git + cd gpt4free + ``` + +2. **Build and Run with Docker Compose** + ```bash + docker-compose up --build + ``` + +3. **Access the API** + The server will be accessible at `http://localhost:1337` + +### Non-Docker Method +If you encounter issues with Docker, you can run the project directly using Python: + +1. **Clone the Repository** + ```bash + git clone https://github.com/xtekky/gpt4free.git + cd gpt4free + ``` + +2. **Install Dependencies** + ```bash + pip install -r requirements.txt + ``` -4. **Build the Docker Image:** +3. **Run the Server** + ```bash + python -m g4f.api.run + ``` +4. **Access the API** + The server will be accessible at `http://localhost:1337` + +## Testing the API +**You can test the API using curl or by creating a simple Python script:** +### Using curl ```bash -docker pull selenium/node-chrome -docker-compose build +curl -X POST -H "Content-Type: application/json" -d '{"prompt": "What is the capital of France?"}' http://localhost:1337/chat/completions ``` -5. **Start the Service:** +### Using Python +**Create a file named `test_g4f.py` with the following content:** +```python +import requests + +url = "http://localhost:1337/v1/chat/completions" +body = { + "model": "gpt-4o-mini", + "stream": False, + "messages": [ + {"role": "assistant", "content": "What can you do?"} + ] +} + +json_response = requests.post(url, json=body).json().get('choices', []) + +for choice in json_response: + print(choice.get('message', {}).get('content', '')) +``` +**Run the script:** ```bash -docker-compose up +python test_g4f.py ``` -Your server will now be accessible at `http://localhost:1337`. Interact with the API or run tests as usual. +## Troubleshooting +- If you encounter issues with Docker, try running the project directly using Python as described in the Non-Docker Method. +- Ensure that you have the necessary permissions to run Docker commands. You might need to use `sudo` or add your user to the `docker` group. +- If the server doesn't start, check the logs for any error messages and ensure all dependencies are correctly installed. -To stop the Docker containers, simply run: +**_For more detailed information on API endpoints and usage, refer to the [G4F API documentation](docs/interference-api.md)._** + + +## Stopping the Service + +### Docker Method +**To stop the Docker containers, use the following command:** ```bash docker-compose down ``` -> [!Note] -> Changes made to local files reflect in the Docker container due to volume mapping in `docker-compose.yml`. However, if you add or remove dependencies, rebuild the Docker image using `docker-compose build`. +### Non-Docker Method +If you're running the server directly with Python, you can stop it by pressing Ctrl+C in the terminal where it's running. + +--- -[Return to Home](/)
\ No newline at end of file +[Return to Home](/) diff --git a/docs/git.md b/docs/git.md index 89137ffc..ff6c8091 100644 --- a/docs/git.md +++ b/docs/git.md @@ -1,66 +1,129 @@ -### G4F - Installation Guide -Follow these steps to install G4F from the source code: +# G4F - Git Installation Guide -1. **Clone the Repository:** +This guide provides step-by-step instructions for installing G4F from the source code using Git. -```bash -git clone https://github.com/xtekky/gpt4free.git -``` -2. **Navigate to the Project Directory:** +## Table of Contents -```bash -cd gpt4free -``` +1. [Prerequisites](#prerequisites) +2. [Installation Steps](#installation-steps) + 1. [Clone the Repository](#1-clone-the-repository) + 2. [Navigate to the Project Directory](#2-navigate-to-the-project-directory) + 3. [Set Up a Python Virtual Environment](#3-set-up-a-python-virtual-environment-recommended) + 4. [Activate the Virtual Environment](#4-activate-the-virtual-environment) + 5. [Install Dependencies](#5-install-dependencies) + 6. [Verify Installation](#6-verify-installation) +3. [Usage](#usage) +4. [Troubleshooting](#troubleshooting) +5. [Additional Resources](#additional-resources) -3. **(Optional) Create a Python Virtual Environment:** +--- -It's recommended to isolate your project dependencies. You can follow the [Python official documentation](https://docs.python.org/3/tutorial/venv.html) for virtual environments. +## Prerequisites -```bash -python3 -m venv venv -``` +Before you begin, ensure you have the following installed on your system: +- Git +- Python 3.7 or higher +- pip (Python package installer) -4. **Activate the Virtual Environment:** - -- On Windows: +## Installation Steps +### 1. Clone the Repository +**Open your terminal and run the following command to clone the G4F repository:** ```bash -.\venv\Scripts\activate +git clone https://github.com/xtekky/gpt4free.git ``` -- On macOS and Linux: +### 2. Navigate to the Project Directory +**Change to the project directory:** +```bash +cd gpt4free +``` +### 3. Set Up a Python Virtual Environment (Recommended) +**It's best practice to use a virtual environment to manage project dependencies:** ```bash -source venv/bin/activate +python3 -m venv venv ``` -5. **Install Minimum Requirements:** +### 4. Activate the Virtual Environment +**Activate the virtual environment based on your operating system:** +- **Windows:** + ```bash + .\venv\Scripts\activate + ``` -Install the minimum required packages: +- **macOS and Linux:** + ```bash + source venv/bin/activate + ``` +### 5. Install Dependencies +**You have two options for installing dependencies:** + +#### Option A: Install Minimum Requirements +**For a lightweight installation, use:** ```bash pip install -r requirements-min.txt ``` -6. **Or Install All Packages from `requirements.txt`:** - -If you prefer, you can install all packages listed in `requirements.txt`: - +#### Option B: Install All Packages +**For a full installation with all features, use:** ```bash pip install -r requirements.txt ``` -7. **Start Using the Repository:** - +### 6. Verify Installation You can now create Python scripts and utilize the G4F functionalities. Here's a basic example: -Create a `test.py` file in the root folder and start using the repository: - +**Create a `g4f-test.py` file in the root folder and start using the repository:** ```python import g4f # Your code here ``` -[Return to Home](/)
\ No newline at end of file +## Usage +**After installation, you can start using G4F in your Python scripts. Here's a basic example:** +```python +import g4f + +# Your G4F code here +# For example: +from g4f.client import Client + +client = Client() + +response = client.chat.completions.create( + model="gpt-4o-mini", + messages=[ + { + "role": "user", + "content": "Say this is a test" + } + ] + # Add any other necessary parameters +) + +print(response.choices[0].message.content) +``` + +## Troubleshooting +**If you encounter any issues during installation or usage:** + 1. Ensure all prerequisites are correctly installed. + 2. Check that you're in the correct directory and the virtual environment is activated. + 3. Try reinstalling the dependencies. + 4. Consult the [G4F documentation](https://github.com/xtekky/gpt4free) for more detailed information. + +## Additional Resources + - [G4F GitHub Repository](https://github.com/xtekky/gpt4free) + - [Python Virtual Environments Guide](https://docs.python.org/3/tutorial/venv.html) + - [pip Documentation](https://pip.pypa.io/en/stable/) + +--- + +**_For more information or support, please visit the [G4F GitHub Issues page](https://github.com/xtekky/gpt4free/issues)._** + + +--- +[Return to Home](/) diff --git a/docs/interference-api.md b/docs/interference-api.md new file mode 100644 index 00000000..a6999345 --- /dev/null +++ b/docs/interference-api.md @@ -0,0 +1,166 @@ +# G4F - Interference API Usage Guide + + +## Table of Contents + - [Introduction](#introduction) + - [Running the Interference API](#running-the-interference-api) + - [From PyPI Package](#from-pypi-package) + - [From Repository](#from-repository) + - [Using the Interference API](#using-the-interference-api) + - [Basic Usage](#basic-usage) + - [With OpenAI Library](#with-openai-library) + - [With Requests Library](#with-requests-library) + - [Key Points](#key-points) + - [Conclusion](#conclusion) + + +## Introduction +The G4F Interference API is a powerful tool that allows you to serve other OpenAI integrations using G4F (Gpt4free). It acts as a proxy, translating requests intended for the OpenAI API into requests compatible with G4F providers. This guide will walk you through the process of setting up, running, and using the Interference API effectively. + + +## Running the Interference API +**You can run the Interference API in two ways:** using the PyPI package or from the repository. + + +### From PyPI Package +**To run the Interference API directly from the G4F PyPI package, use the following Python code:** + +```python +from g4f.api import run_api + +run_api() +``` + + +### From Repository +**If you prefer to run the Interference API from the cloned repository, you have two options:** + +1. **Using the command line:** +```bash +g4f api +``` + +2. **Using Python:** +```bash +python -m g4f.api.run +``` + +**Once running, the API will be accessible at:** `http://localhost:1337/v1` + +**(Advanced) Bind to custom port:** +```bash +python -m g4f.cli api --bind "0.0.0.0:2400" +``` + +## Using the Interference API + +### Basic Usage +**You can interact with the Interference API using curl commands for both text and image generation:** + +**For text generation:** +```bash +curl -X POST "http://localhost:1337/v1/chat/completions" \ + -H "Content-Type: application/json" \ + -d '{ + "messages": [ + { + "role": "user", + "content": "Hello" + } + ], + "model": "gpt-4o-mini" + }' +``` + +**For image generation:** +1. **url:** +```bash +curl -X POST "http://localhost:1337/v1/images/generate" \ + -H "Content-Type: application/json" \ + -d '{ + "prompt": "a white siamese cat", + "model": "flux", + "response_format": "url" + }' +``` + +2. **b64_json** +```bash +curl -X POST "http://localhost:1337/v1/images/generate" \ + -H "Content-Type: application/json" \ + -d '{ + "prompt": "a white siamese cat", + "model": "flux", + "response_format": "b64_json" + }' +``` + + +### With OpenAI Library + +**You can use the Interference API with the OpenAI Python library by changing the `base_url`:** +```python +from openai import OpenAI + +client = OpenAI( + api_key="", + base_url="http://localhost:1337/v1" +) + +response = client.chat.completions.create( + model="gpt-4o-mini", + messages=[{"role": "user", "content": "Write a poem about a tree"}], + stream=True, +) + +if isinstance(response, dict): + # Not streaming + print(response.choices[0].message.content) +else: + # Streaming + for token in response: + content = token.choices[0].delta.content + if content is not None: + print(content, end="", flush=True) + +``` + + +### With Requests Library + +**You can also send requests directly to the Interference API using the `requests` library:** +```python +import requests + +url = "http://localhost:1337/v1/chat/completions" + +body = { + "model": "gpt-4o-mini", + "stream": False, + "messages": [ + {"role": "assistant", "content": "What can you do?"} + ] +} + +json_response = requests.post(url, json=body).json().get('choices', []) + +for choice in json_response: + print(choice.get('message', {}).get('content', '')) + +``` + +## Key Points + - The Interference API translates OpenAI API requests into G4F provider requests. + - It can be run from either the PyPI package or the cloned repository. + - The API supports usage with the OpenAI Python library by changing the `base_url`. + - Direct requests can be sent to the API endpoints using libraries like `requests`. + - Both text and image generation are supported. + + +## Conclusion +The G4F Interference API provides a seamless way to integrate G4F with existing OpenAI-based applications and tools. By following this guide, you should now be able to set up, run, and use the Interference API effectively. Whether you're using it for text generation, image creation, or as a drop-in replacement for OpenAI in your projects, the Interference API offers flexibility and power for your AI-driven applications. + + +--- + +[Return to Home](/) diff --git a/docs/interference.md b/docs/interference.md deleted file mode 100644 index b140f66a..00000000 --- a/docs/interference.md +++ /dev/null @@ -1,69 +0,0 @@ -### Interference openai-proxy API - -#### Run interference API from PyPi package - -```python -from g4f.api import run_api - -run_api() -``` - -#### Run interference API from repo - -Run server: - -```sh -g4f api -``` - -or - -```sh -python -m g4f.api.run -``` - -```python -from openai import OpenAI - -client = OpenAI( - api_key="", - # Change the API base URL to the local interference API - base_url="http://localhost:1337/v1" -) - - response = client.chat.completions.create( - model="gpt-3.5-turbo", - messages=[{"role": "user", "content": "write a poem about a tree"}], - stream=True, - ) - - if isinstance(response, dict): - # Not streaming - print(response.choices[0].message.content) - else: - # Streaming - for token in response: - content = token.choices[0].delta.content - if content is not None: - print(content, end="", flush=True) -``` - -#### API usage (POST) -Send the POST request to /v1/chat/completions with body containing the `model` method. This example uses python with requests library: -```python -import requests -url = "http://localhost:1337/v1/chat/completions" -body = { - "model": "gpt-3.5-turbo-16k", - "stream": False, - "messages": [ - {"role": "assistant", "content": "What can you do?"} - ] -} -json_response = requests.post(url, json=body).json().get('choices', []) - -for choice in json_response: - print(choice.get('message', {}).get('content', '')) -``` - -[Return to Home](/)
\ No newline at end of file diff --git a/docs/legacy.md b/docs/legacy/legacy.md index d5cd5a36..d5cd5a36 100644 --- a/docs/legacy.md +++ b/docs/legacy/legacy.md diff --git a/docs/legacy/legacy_async_client.md b/docs/legacy/legacy_async_client.md new file mode 100644 index 00000000..5ddc2671 --- /dev/null +++ b/docs/legacy/legacy_async_client.md @@ -0,0 +1,380 @@ +# G4F - Legacy AsyncClient API Guide + +**IMPORTANT: This guide refers to the old implementation of AsyncClient. The new version of G4F now supports both synchronous and asynchronous operations through a unified interface. Please refer to the [new AsyncClient documentation](https://github.com/xtekky/gpt4free/blob/main/docs/async_client.md) for the latest information.** + +This guide provides comprehensive information on how to use the G4F AsyncClient API, including setup, usage examples, best practices, and important considerations for optimal performance. + +## Compatibility Note +The G4F AsyncClient API is designed to be compatible with the OpenAI API, making it easy for developers familiar with OpenAI's interface to transition to G4F. However, please note that this is the old version, and you should migrate to the new implementation for better support and features. + +## Table of Contents + - [Introduction](#introduction) + - [Key Features](#key-features) + - [Getting Started](#getting-started) + - [Initializing the Client](#initializing-the-client) + - [Creating Chat Completions](#creating-chat-completions) + - [Configuration](#configuration) + - [Usage Examples](#usage-examples) + - [Text Completions](#text-completions) + - [Streaming Completions](#streaming-completions) + - [Using a Vision Model](#using-a-vision-model) + - [Image Generation](#image-generation) + - [Concurrent Tasks](#concurrent-tasks-with-asynciogather) + - [Available Models and Providers](#available-models-and-providers) + - [Error Handling and Best Practices](#error-handling-and-best-practices) + - [Rate Limiting and API Usage](#rate-limiting-and-api-usage) + - [Conclusion](#conclusion) + +## Introduction +This is the old version: The G4F AsyncClient API is an asynchronous version of the standard G4F Client API. It offers the same functionality as the synchronous API but with improved performance due to its asynchronous nature. This guide will walk you through the key features and usage of the G4F AsyncClient API. + +## Key Features + - **Custom Providers**: Use custom providers for enhanced flexibility. + - **ChatCompletion Interface**: Interact with chat models through the ChatCompletion class. + - **Streaming Responses**: Get responses iteratively as they are received. + - **Non-Streaming Responses**: Generate complete responses in a single call. + - **Image Generation and Vision Models**: Support for image-related tasks. + +## Getting Started +**To ignore DeprecationWarnings related to the AsyncClient, you can use the following code:*** +```python +import warnings + +# Ignore DeprecationWarning for AsyncClient +warnings.filterwarnings("ignore", category=DeprecationWarning, module="g4f.client") +``` + +### Initializing the Client +**To use the G4F `Client`, create a new instance:** +```python +from g4f.client import AsyncClient +from g4f.Provider import OpenaiChat, Gemini + +client = AsyncClient( + provider=OpenaiChat, + image_provider=Gemini, + # Add other parameters as needed +) +``` + +## Creating Chat Completions +**Here's an improved example of creating chat completions:** +```python +response = await async_client.chat.completions.create( + model="gpt-3.5-turbo", + messages=[ + { + "role": "user", + "content": "Say this is a test" + } + ] + # Add other parameters as needed +) +``` + +**This example:** + - Asks a specific question `Say this is a test` + - Configures various parameters like temperature and max_tokens for more control over the output + - Disables streaming for a complete response + +You can adjust these parameters based on your specific needs. + +### Configuration +**Configure the `AsyncClient` with additional settings:** +```python +client = Client( + api_key="your_api_key_here", + proxies="http://user:pass@host", + # Add other parameters as needed +) +``` + +## Usage Examples +### Text Completions +**Generate text completions using the ChatCompletions endpoint:** +```python +import asyncio +import warnings +from g4f.client import AsyncClient + +# Ігноруємо DeprecationWarning +warnings.filterwarnings("ignore", category=DeprecationWarning) + +async def main(): + client = AsyncClient() + + response = await client.chat.completions.async_create( + model="gpt-3.5-turbo", + messages=[ + { + "role": "user", + "content": "Say this is a test" + } + ] + ) + + print(response.choices[0].message.content) + +asyncio.run(main()) +``` + +### Streaming Completions +**Process responses incrementally as they are generated:** +```python +import asyncio +from g4f.client import AsyncClient + +async def main(): + client = AsyncClient() + + stream = await client.chat.completions.async_create( + model="gpt-4", + messages=[ + { + "role": "user", + "content": "Say this is a test" + } + ], + stream=True, + ) + + async for chunk in stream: + if chunk.choices[0].delta.content: + print(chunk.choices[0].delta.content, end="") + +asyncio.run(main()) +``` + +### Using a Vision Model +**Analyze an image and generate a description:** +```python +import g4f +import requests +import asyncio +from g4f.client import AsyncClient + +async def main(): + client = AsyncClient() + + image = requests.get("https://raw.githubusercontent.com/xtekky/gpt4free/refs/heads/main/docs/cat.jpeg", stream=True).raw + + response = await client.chat.completions.async_create( + model=g4f.models.default, + provider=g4f.Provider.Bing, + messages=[ + { + "role": "user", + "content": "What's in this image?" + } + ], + image=image + ) + + print(response.choices[0].message.content) + +asyncio.run(main()) +``` + +### Image Generation +**Generate images using a specified prompt:** +```python +import asyncio +from g4f.client import AsyncClient + +async def main(): + client = AsyncClient() + + response = await client.images.async_generate( + prompt="a white siamese cat", + model="flux" + ) + + image_url = response.data[0].url + print(f"Generated image URL: {image_url}") + +asyncio.run(main()) +``` + +#### Base64 Response Format +```python +import asyncio +from g4f.client import AsyncClient + +async def main(): + client = AsyncClient() + + response = await client.images.async_generate( + prompt="a white siamese cat", + model="flux", + response_format="b64_json" + ) + + base64_text = response.data[0].b64_json + print(base64_text) + +asyncio.run(main()) +``` + +### Concurrent Tasks with asyncio.gather +**Execute multiple tasks concurrently:** +```python +import asyncio +import warnings +from g4f.client import AsyncClient + +# Ignore DeprecationWarning for AsyncClient +warnings.filterwarnings("ignore", category=DeprecationWarning, module="g4f.client") + +async def main(): + client = AsyncClient() + + task1 = client.chat.completions.async_create( + model="gpt-3.5-turbo", + messages=[ + { + "role": "user", + "content": "Say this is a test" + } + ] + ) + + task2 = client.images.async_generate( + model="flux", + prompt="a white siamese cat" + ) + + chat_response, image_response = await asyncio.gather(task1, task2) + + print("Chat Response:") + print(chat_response.choices[0].message.content) + + print("Image Response:") + print(image_response.data[0].url) + +asyncio.run(main()) +``` + +## Available Models and Providers +This is the old version: The G4F AsyncClient supports a wide range of AI models and providers, allowing you to choose the best option for your specific use case. +**Here's a brief overview of the available models and providers:** + +### Models + - GPT-3.5-Turbo + - GPT-4 + - DALL-E 3 + - Gemini + - Claude (Anthropic) + - And more... + +### Providers + - OpenAI + - Google (for Gemini) + - Anthropic + - Bing + - Custom providers + +**To use a specific model or provider, specify it when creating the client or in the API call:** +```python +client = AsyncClient(provider=g4f.Provider.OpenaiChat) + +# or + +response = await client.chat.completions.async_create( + model="gpt-4", + provider=g4f.Provider.Bing, + messages=[ + { + "role": "user", + "content": "Hello, world!" + } + ] +) +``` + +## Error Handling and Best Practices +Implementing proper error handling and following best practices is crucial when working with the G4F AsyncClient API. This ensures your application remains robust and can gracefully handle various scenarios. **Here are some key practices to follow:** + +1. **Use try-except blocks to catch and handle exceptions:** +```python +try: + response = await client.chat.completions.async_create( + model="gpt-3.5-turbo", + messages=[ + { + "role": "user", + "content": "Hello, world!" + } + ] + ) +except Exception as e: + print(f"An error occurred: {e}") +``` + +2. **Check the response status and handle different scenarios:** +```python +if response.choices: + print(response.choices[0].message.content) +else: + print("No response generated") +``` + +3. **Implement retries for transient errors:** +```python +import asyncio +from tenacity import retry, stop_after_attempt, wait_exponential + +@retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=4, max=10)) +async def make_api_call(): + # Your API call here + pass +``` + +## Rate Limiting and API Usage +This is the old version: When working with the G4F AsyncClient API, it's important to implement rate limiting and monitor your API usage. This helps ensure fair usage, prevents overloading the service, and optimizes your application's performance. **Here are some key strategies to consider:** + +1. **Implement rate limiting in your application:** +```python +import asyncio +from aiolimiter import AsyncLimiter + +rate_limit = AsyncLimiter(max_rate=10, time_period=1) # 10 requests per second + +async def make_api_call(): + async with rate_limit: + # Your API call here + pass +``` + +2. **Monitor your API usage and implement logging:** +```python +import logging + +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger(__name__) + +async def make_api_call(): + try: + response = await client.chat.completions.async_create(...) + logger.info(f"API call successful. Tokens used: {response.usage.total_tokens}") + except Exception as e: + logger.error(f"API call failed: {e}") +``` + +3. **Use caching to reduce API calls for repeated queries:** +```python +from functools import lru_cache + +@lru_cache(maxsize=100) +def get_cached_response(query): + # Your API call here + pass +``` + +## Conclusion +This is the old version: The G4F AsyncClient API provides a powerful and flexible way to interact with various AI models asynchronously. By leveraging its features and following best practices, you can build efficient and responsive applications that harness the power of AI for text generation, image analysis, and image creation. + +Remember to handle errors gracefully, implement rate limiting, and monitor your API usage to ensure optimal performance and reliability in your applications. + +--- + +[Return to Home](/) diff --git a/docs/local.md b/docs/local.md new file mode 100644 index 00000000..2cedd1a9 --- /dev/null +++ b/docs/local.md @@ -0,0 +1,164 @@ + +### G4F - Local Usage Guide + + +### Table of Contents +1. [Introduction](#introduction) +2. [Required Dependencies](#required-dependencies) +3. [Basic Usage Example](#basic-usage-example) +4. [Supported Models](#supported-models) +5. [Performance Considerations](#performance-considerations) +6. [Troubleshooting](#troubleshooting) + +#### Introduction +This guide explains how to use g4f to run language models locally. G4F (GPT4Free) allows you to interact with various language models on your local machine, providing a flexible and private solution for natural language processing tasks. + +## Usage + +#### Local inference +How to use g4f to run language models locally + +#### Required dependencies +**Make sure to install the required dependencies by running:** +```bash +pip install g4f[local] +``` +or +```bash +pip install -U gpt4all +``` + + + +#### Basic usage example +```python +from g4f.local import LocalClient + +client = LocalClient() +response = client.chat.completions.create( + model = 'orca-mini-3b', + messages = [{"role": "user", "content": "hi"}], + stream = True +) + +for token in response: + print(token.choices[0].delta.content or "") +``` + +Upon first use, there will be a prompt asking you if you wish to download the model. If you respond with `y`, g4f will go ahead and download the model for you. + +You can also manually place supported models into `./g4f/local/models/` + + +**You can get a list of the current supported models by running:** +```python +from g4f.local import LocalClient + +client = LocalClient() +client.list_models() +``` + +```json +{ + "mistral-7b": { + "path": "mistral-7b-openorca.gguf2.Q4_0.gguf", + "ram": "8", + "prompt": "<|im_start|>user\n%1<|im_end|>\n<|im_start|>assistant\n", + "system": "<|im_start|>system\nYou are MistralOrca, a large language model trained by Alignment Lab AI. For multi-step problems, write out your reasoning for each step.\n<|im_end|>" + }, + "mistral-7b-instruct": { + "path": "mistral-7b-instruct-v0.1.Q4_0.gguf", + "ram": "8", + "prompt": "[INST] %1 [/INST]", + "system": None + }, + "gpt4all-falcon": { + "path": "gpt4all-falcon-newbpe-q4_0.gguf", + "ram": "8", + "prompt": "### Instruction:\n%1\n### Response:\n", + "system": None + }, + "orca-2": { + "path": "orca-2-13b.Q4_0.gguf", + "ram": "16", + "prompt": None, + "system": None + }, + "wizardlm-13b": { + "path": "wizardlm-13b-v1.2.Q4_0.gguf", + "ram": "16", + "prompt": None, + "system": None + }, + "nous-hermes-llama2": { + "path": "nous-hermes-llama2-13b.Q4_0.gguf", + "ram": "16", + "prompt": "### Instruction:\n%1\n### Response:\n", + "system": None + }, + "gpt4all-13b-snoozy": { + "path": "gpt4all-13b-snoozy-q4_0.gguf", + "ram": "16", + "prompt": None, + "system": None + }, + "mpt-7b-chat": { + "path": "mpt-7b-chat-newbpe-q4_0.gguf", + "ram": "8", + "prompt": "<|im_start|>user\n%1<|im_end|>\n<|im_start|>assistant\n", + "system": "<|im_start|>system\n- You are a helpful assistant chatbot trained by MosaicML.\n- You answer questions.\n- You are excited to be able to help the user, but will refuse to do anything that could be considered harmful to the user.\n- You are more than just an information source, you are also able to write poetry, short stories, and make jokes.<|im_end|>" + }, + "orca-mini-3b": { + "path": "orca-mini-3b-gguf2-q4_0.gguf", + "ram": "4", + "prompt": "### User:\n%1\n### Response:\n", + "system": "### System:\nYou are an AI assistant that follows instruction extremely well. Help as much as you can.\n\n" + }, + "replit-code-3b": { + "path": "replit-code-v1_5-3b-newbpe-q4_0.gguf", + "ram": "4", + "prompt": "%1", + "system": None + }, + "starcoder": { + "path": "starcoder-newbpe-q4_0.gguf", + "ram": "4", + "prompt": "%1", + "system": None + }, + "rift-coder-7b": { + "path": "rift-coder-v0-7b-q4_0.gguf", + "ram": "8", + "prompt": "%1", + "system": None + }, + "all-MiniLM-L6-v2": { + "path": "all-MiniLM-L6-v2-f16.gguf", + "ram": "1", + "prompt": None, + "system": None + }, + "mistral-7b-german": { + "path": "em_german_mistral_v01.Q4_0.gguf", + "ram": "8", + "prompt": "USER: %1 ASSISTANT: ", + "system": "Du bist ein hilfreicher Assistent. " + } +} +``` + +#### Performance Considerations +**When running language models locally, consider the following:** + - RAM requirements vary by model size (see the 'ram' field in the model list). + - CPU/GPU capabilities affect inference speed. + - Disk space is needed to store the model files. + +#### Troubleshooting +**Common issues and solutions:** + 1. **Model download fails**: Check your internet connection and try again. + 2. **Out of memory error**: Choose a smaller model or increase your system's RAM. + 3. **Slow inference**: Consider using a GPU or a more powerful CPU. + + + +[Return to Home](/) diff --git a/docs/providers-and-models.md b/docs/providers-and-models.md new file mode 100644 index 00000000..7c6bc613 --- /dev/null +++ b/docs/providers-and-models.md @@ -0,0 +1,214 @@ + + +# G4F - Providers and Models + +This document provides an overview of various AI providers and models, including text generation, image generation, and vision capabilities. It aims to help users navigate the diverse landscape of AI services and choose the most suitable option for their needs. + +## Table of Contents + - [Providers](#providers) + - [Models](#models) + - [Text Models](#text-models) + - [Image Models](#image-models) + - [Vision Models](#vision-models) + - [Providers and vision models](#providers-and-vision-models) + - [Conclusion and Usage Tips](#conclusion-and-usage-tips) + +--- +## Providers +| Provider | Text Models | Image Models | Vision Models | Stream | Status | Auth | +|----------|-------------|--------------|---------------|--------|--------|------| +|[ai4chat.co](https://www.ai4chat.co)|`g4f.Provider.Ai4Chat`|`gpt-4`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[aichatfree.info](https://aichatfree.info)|`g4f.Provider.AIChatFree`|`gemini-pro`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[api.airforce](https://api.airforce)|`g4f.Provider.Airforce`|`gpt-4o, gpt-4o-mini, gpt-4-turbo, llama-2-7b, llama-3.1-8b, llama-3.1-70b, hermes-2-pro, hermes-2-dpo, phi-2, deepseek-coder, openchat-3.5, openhermes-2.5, lfm-40b, german-7b, zephyr-7b, neural-7b`|`flux, flux-realism', flux-anime, flux-3d, flux-disney, flux-pixel, flux-4o, any-dark, sdxl`|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[aiuncensored.info](https://www.aiuncensored.info)|`g4f.Provider.AIUncensored`|✔|✔|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[allyfy.chat](https://allyfy.chat/)|`g4f.Provider.Allyfy`|`gpt-3.5-turbo`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[bing.com](https://bing.com/chat)|`g4f.Provider.Bing`|`gpt-4`|✔|`gpt-4-vision`|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌+✔| +|[bing.com/images](https://www.bing.com/images/create)|`g4f.Provider.BingCreateImages`|`❌|✔|❌|❌|![Active](https://img.shields.io/badge/Active-brightgreen)|✔| +|[blackbox.ai](https://www.blackbox.ai)|`g4f.Provider.Blackbox`|`blackboxai, blackboxai-pro, gemini-flash, llama-3.1-8b, llama-3.1-70b, llama-3.1-405b, gpt-4o, gemini-pro, claude-3.5-sonnet`|`flux`|`blackboxai, gemini-flash, llama-3.1-8b, llama-3.1-70b, llama-3.1-405b, gpt-4o, gemini-pro`|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[chatgot.one](https://www.chatgot.one/)|`g4f.Provider.ChatGot`|`gemini-pro`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[chatgpt.com](https://chatgpt.com)|`g4f.Provider.ChatGpt`|`?`|`?`|`?`|?|![Unknown](https://img.shields.io/badge/Unknown-grey) |❌| +|[chatgpt.es](https://chatgpt.es)|`g4f.Provider.ChatGptEs`|`gpt-4o, gpt-4o-mini`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[playground.ai.cloudflare.com](https://playground.ai.cloudflare.com)|`g4f.Provider.Cloudflare`|`gemma-7b, llama-2-7b, llama-3-8b, llama-3.1-8b, llama-3.2-1b, phi-2, qwen-1.5-0-5b, qwen-1.5-8b, qwen-1.5-14b, qwen-1.5-7b`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[darkai.foundation/chat](https://darkai.foundation/chat)|`g4f.Provider.DarkAI`|`gpt-4o, gpt-3.5-turbo, llama-3-70b, llama-3-405b`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[duckduckgo.com](https://duckduckgo.com/duckchat/v1/chat)|`g4f.Provider.DDG`|`gpt-4o-mini, claude-3-haiku, llama-3.1-70b, mixtral-8x7b`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[deepinfra.com](https://deepinfra.com)|`g4f.Provider.DeepInfra`|✔|❌|❌|✔|![Unknown](https://img.shields.io/badge/Unknown-grey)|✔| +|[deepinfra.com/chat](https://deepinfra.com/chat)|`g4f.Provider.DeepInfraChat`|`llama-3.1-8b, llama-3.1-70b, wizardlm-2-8x22b, qwen-2-72b`|❌|❌|❌|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[deepinfra.com](https://deepinfra.com)|`g4f.Provider.DeepInfraImage`|❌|✔|❌|❌|![Unknown](https://img.shields.io/badge/Unknown-grey)|✔| +|[chat10.free2gpt.xyz](chat10.free2gpt.xyz)|`g4f.Provider.Free2GPT`|`mixtral-7b`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[freegptsnav.aifree.site](https://freegptsnav.aifree.site)|`g4f.Provider.FreeGpt`|`gemini-pro`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[gemini.google.com](https://gemini.google.com)|`g4f.Provider.Gemini`|✔|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|✔| +|[ai.google.dev](https://ai.google.dev)|`g4f.Provider.GeminiPro`|✔|❌|✔|?|![Active](https://img.shields.io/badge/Active-brightgreen)|✔| +|[app.giz.ai](https://app.giz.ai/assistant/)|`g4f.Provider.GizAI`|`gemini-flash`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[developers.sber.ru](https://developers.sber.ru/gigachat)|`g4f.Provider.GigaChat`|✔|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|✔| +|[console.groq.com/playground](https://console.groq.com/playground)|`g4f.Provider.Groq`|✔|❌|❌|?|![Active](https://img.shields.io/badge/Active-brightgreen)|✔| +|[huggingface.co/chat](https://huggingface.co/chat)|`g4f.Provider.HuggingChat`|`llama-3.1-70b, command-r-plus, qwen-2-72b, llama-3.2-11b, hermes-3, mistral-nemo, phi-3.5-mini`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[huggingface.co](https://huggingface.co/chat)|`g4f.Provider.HuggingFace`|✔|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[liaobots.work](https://liaobots.work)|`g4f.Provider.Liaobots`|`gpt-3.5-turbo, gpt-4o-mini, gpt-4o, gpt-4-turbo, grok-2, grok-2-mini, claude-3-opus, claude-3-sonnet, claude-3-5-sonnet, claude-3-haiku, claude-2.1, gemini-flash, gemini-pro`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[magickpen.com](https://magickpen.com)|`g4f.Provider.MagickPen`|`gpt-4o-mini`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[meta.ai](https://www.meta.ai)|`g4f.Provider.MetaAI`|✔|✔|?|?|![Active](https://img.shields.io/badge/Active-brightgreen)|✔| +|[platform.openai.com](https://platform.openai.com/)|`g4f.Provider.Openai`|✔|❌|✔||![Unknown](https://img.shields.io/badge/Unknown-grey)|✔| +|[chatgpt.com](https://chatgpt.com/)|`g4f.Provider.OpenaiChat`|`gpt-4o, gpt-4o-mini, gpt-4`|❌|✔||![Unknown](https://img.shields.io/badge/Unknown-grey)|✔| +|[www.perplexity.ai)](https://www.perplexity.ai)|`g4f.Provider.PerplexityAi`|✔|❌|❌|?|![Disabled](https://img.shields.io/badge/Disabled-red)|❌| +|[perplexity.ai](https://www.perplexity.ai)|`g4f.Provider.PerplexityApi`|✔|❌|❌|?|![Unknown](https://img.shields.io/badge/Unknown-grey)|✔| +|[labs.perplexity.ai](https://labs.perplexity.ai)|`g4f.Provider.PerplexityLabs`|`sonar-online, sonar-chat, llama-3.1-8b, llama-3.1-70b`|❌|❌|?|![Cloudflare](https://img.shields.io/badge/Cloudflare-f48d37)|❌| +|[pi.ai/talk](https://pi.ai/talk)|`g4f.Provider.Pi`|`pi`|❌|❌|?|![Unknown](https://img.shields.io/badge/Unknown-grey)|❌| +|[]()|`g4f.Provider.Pizzagpt`|`gpt-4o-mini`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[poe.com](https://poe.com)|`g4f.Provider.Poe`|✔|❌|❌|?|![Unknown](https://img.shields.io/badge/Unknown-grey)|✔| +|[app.prodia.com](https://app.prodia.com)|`g4f.Provider.Prodia`|❌|✔|❌|❌|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[raycast.com](https://raycast.com)|`g4f.Provider.Raycast`|✔|❌|❌|✔|![Unknown](https://img.shields.io/badge/Unknown-grey)|✔| +|[chat.reka.ai](https://chat.reka.ai/)|`g4f.Provider.Reka`|✔|❌|✔|✔|![Unknown](https://img.shields.io/badge/Unknown-grey)|✔| +|[replicate.com](https://replicate.com)|`g4f.Provider.Replicate`|✔|❌|❌|?|![Unknown](https://img.shields.io/badge/Unknown-grey)|✔| +|[replicate.com](https://replicate.com)|`g4f.Provider.ReplicateHome`|`gemma-2b, llava-13b`|`sd-3, sdxl, playground-v2.5`|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[replicate.com](https://replicate.com)|`g4f.Provider.RubiksAI`|`llama-3.1-70b, gpt-4o-mini`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[talkai.info](https://talkai.info)|`g4f.Provider.TalkAi`|✔|❌|❌|✔|![Disabled](https://img.shields.io/badge/Disabled-red)|❌| +|[teach-anything.com](https://www.teach-anything.com)|`g4f.Provider.TeachAnything`|`llama-3.1-70b`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[beta.theb.ai](https://beta.theb.ai)|`g4f.Provider.Theb`|✔|❌|❌|✔|![Unknown](https://img.shields.io/badge/Unknown-grey)|✔| +|[beta.theb.ai](https://beta.theb.ai)|`g4f.Provider.ThebApi`|✔|❌|❌|✔|![Unknown](https://img.shields.io/badge/Unknown-grey)|✔| +|[console.upstage.ai/playground/chat](https://console.upstage.ai/playground/chat)|`g4f.Provider.Upstage`|`solar-pro, solar-mini`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌| +|[whiterabbitneo.com](https://www.whiterabbitneo.com)|`g4f.Provider.WhiteRabbitNeo`|✔|❌|❌|?|![Unknown](https://img.shields.io/badge/Unknown-grey)|✔| +|[you.com](https://you.com)|`g4f.Provider.You`|✔|✔|✔|✔|![Unknown](https://img.shields.io/badge/Unknown-grey)|❌+✔| + +## Models + +### Text Models +| Model | Base Provider | Providers | Website | +|-------|---------------|-----------|---------| +|gpt-3.5-turbo|OpenAI|4+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-3-5-turbo)| +|gpt-4|OpenAI|6+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4)| +|gpt-4-turbo|OpenAI|4+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4)| +|gpt-4o|OpenAI|7+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-4o)| +|gpt-4o-mini|OpenAI|10+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-4o-mini)| +|o1|OpenAI|0+ Providers|[platform.openai.com](https://openai.com/index/introducing-openai-o1-preview/)| +|o1-mini|OpenAI|0+ Providers|[platform.openai.com](https://openai.com/index/openai-o1-mini-advancing-cost-efficient-reasoning/)| +|llama-2-7b|Meta Llama|1+ Providers|[huggingface.co](https://huggingface.co/meta-llama/Llama-2-7b)| +|llama-2-13b|Meta Llama|1+ Providers|[llama.com](https://www.llama.com/llama2/)| +|llama-3-8b|Meta Llama|4+ Providers|[ai.meta.com](https://ai.meta.com/blog/meta-llama-3/)| +|llama-3-70b|Meta Llama|4+ Providers|[ai.meta.com](https://ai.meta.com/blog/meta-llama-3/)| +|llama-3.1-8b|Meta Llama|7+ Providers|[ai.meta.com](https://ai.meta.com/blog/meta-llama-3-1/)| +|llama-3.1-70b|Meta Llama|14+ Providers|[ai.meta.com](https://ai.meta.com/blog/meta-llama-3-1/)| +|llama-3.1-405b|Meta Llama|5+ Providers|[ai.meta.com](https://ai.meta.com/blog/meta-llama-3-1/)| +|llama-3.2-1b|Meta Llama|1+ Providers|[huggingface.co](https://huggingface.co/meta-llama/Llama-3.2-1B)| +|llama-3.2-3b|Meta Llama|1+ Providers|[huggingface.co](https://huggingface.co/blog/llama32)| +|llama-3.2-11b|Meta Llama|3+ Providers|[ai.meta.com](https://ai.meta.com/blog/llama-3-2-connect-2024-vision-edge-mobile-devices/)| +|llama-3.2-90b|Meta Llama|2+ Providers|[ai.meta.com](https://ai.meta.com/blog/llama-3-2-connect-2024-vision-edge-mobile-devices/)| +|llamaguard-7b|Meta Llama|1+ Providers|[huggingface.co](https://huggingface.co/meta-llama/LlamaGuard-7b)| +|llamaguard-2-8b|Meta Llama|1+ Providers|[huggingface.co](https://huggingface.co/meta-llama/Meta-Llama-Guard-2-8B)| +|mistral-7b|Mistral AI|4+ Providers|[mistral.ai](https://mistral.ai/news/announcing-mistral-7b/)| +|mixtral-8x7b|Mistral AI|6+ Providers|[mistral.ai](https://mistral.ai/news/mixtral-of-experts/)| +|mixtral-8x22b|Mistral AI|3+ Providers|[mistral.ai](https://mistral.ai/news/mixtral-8x22b/)| +|mistral-nemo|Mistral AI|2+ Providers|[huggingface.co](https://huggingface.co/mistralai/Mistral-Nemo-Instruct-2407)| +|mistral-large|Mistral AI|2+ Providers|[mistral.ai](https://mistral.ai/news/mistral-large-2407/)| +|mixtral-8x7b-dpo|NousResearch|1+ Providers|[huggingface.co](https://huggingface.co/NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO)| +|hermes-2-dpo|NousResearch|1+ Providers|[huggingface.co](https://huggingface.co/NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO)| +|hermes-2|NousResearch|1+ Providers|[huggingface.co](https://huggingface.co/NousResearch/Hermes-2-Pro-Mistral-7B)| +|yi-34b|NousResearch|1+ Providers|[huggingface.co](https://huggingface.co/NousResearch/Nous-Hermes-2-Yi-34B)| +|hermes-3|NousResearch|2+ Providers|[huggingface.co](https://huggingface.co/NousResearch/Hermes-3-Llama-3.1-8B)| +|gemini|Google DeepMind|1+ Providers|[deepmind.google](http://deepmind.google/technologies/gemini/)| +|gemini-flash|Google DeepMind|4+ Providers|[deepmind.google](https://deepmind.google/technologies/gemini/flash/)| +|gemini-pro|Google DeepMind|10+ Providers|[deepmind.google](https://deepmind.google/technologies/gemini/pro/)| +|gemma-2b|Google|5+ Providers|[huggingface.co](https://huggingface.co/google/gemma-2b)| +|gemma-2b-9b|Google|1+ Providers|[huggingface.co](https://huggingface.co/google/gemma-2-9b)| +|gemma-2b-27b|Google|2+ Providers|[huggingface.co](https://huggingface.co/google/gemma-2-27b)| +|gemma-7b|Google|1+ Providers|[huggingface.co](https://huggingface.co/google/gemma-7b)| +|gemma_2_27b|Google|1+ Providers|[huggingface.co](https://huggingface.co/blog/gemma2)| +|claude-2.1|Anthropic|1+ Providers|[anthropic.com](https://www.anthropic.com/news/claude-2)| +|claude-3-haiku|Anthropic|4+ Providers|[anthropic.com](https://www.anthropic.com/news/claude-3-haiku)| +|claude-3-sonnet|Anthropic|2+ Providers|[anthropic.com](https://www.anthropic.com/news/claude-3-family)| +|claude-3-opus|Anthropic|2+ Providers|[anthropic.com](https://www.anthropic.com/news/claude-3-family)| +|claude-3.5-sonnet|Anthropic|6+ Providers|[anthropic.com](https://www.anthropic.com/news/claude-3-5-sonnet)| +|blackboxai|Blackbox AI|1+ Providers|[docs.blackbox.chat](https://docs.blackbox.chat/blackbox-ai-1)| +|blackboxai-pro|Blackbox AI|1+ Providers|[docs.blackbox.chat](https://docs.blackbox.chat/blackbox-ai-1)| +|yi-1.5-9b|01-ai|1+ Providers|[huggingface.co](https://huggingface.co/01-ai/Yi-1.5-9B)| +|phi-2|Microsoft|1+ Providers|[huggingface.co](https://huggingface.co/microsoft/phi-2)| +|phi-3-medium-4k|Microsoft|1+ Providers|[huggingface.co](https://huggingface.co/microsoft/Phi-3-medium-4k-instruct)| +|phi-3.5-mini|Microsoft|2+ Providers|[huggingface.co](https://huggingface.co/microsoft/Phi-3-medium-4k-instruct)| +|dbrx-instruct|Databricks|1+ Providers|[huggingface.co](https://huggingface.co/databricks/dbrx-instruct)| +|command-r-plus|CohereForAI|1+ Providers|[docs.cohere.com](https://docs.cohere.com/docs/command-r-plus)| +|sparkdesk-v1.1|iFlytek|1+ Providers|[xfyun.cn](https://www.xfyun.cn/doc/spark/Guide.html)| +|qwen|Qwen|1+ Providers|[huggingface.co](https://huggingface.co/Qwen)| +|qwen-1.5-0.5b|Qwen|1+ Providers|[huggingface.co](https://huggingface.co/Qwen/Qwen1.5-0.5B)| +|qwen-1.5-7b|Qwen|2+ Providers|[huggingface.co](https://huggingface.co/Qwen/Qwen1.5-7B)| +|qwen-1.5-14b|Qwen|3+ Providers|[huggingface.co](https://huggingface.co/Qwen/Qwen1.5-14B)| +|qwen-1.5-72b|Qwen|1+ Providers|[huggingface.co](https://huggingface.co/Qwen/Qwen1.5-72B)| +|qwen-1.5-110b|Qwen|1+ Providers|[huggingface.co](https://huggingface.co/Qwen/Qwen1.5-110B)| +|qwen-1.5-1.8b|Qwen|1+ Providers|[huggingface.co](https://huggingface.co/Qwen/Qwen1.5-1.8B)| +|qwen-2-72b|Qwen|4+ Providers|[huggingface.co](https://huggingface.co/Qwen/Qwen2-72B)| +|glm-3-6b|Zhipu AI|1+ Providers|[github.com/THUDM/ChatGLM3](https://github.com/THUDM/ChatGLM3)| +|glm-4-9B|Zhipu AI|1+ Providers|[github.com/THUDM/GLM-4](https://github.com/THUDM/GLM-4)| +|solar-1-mini|Upstage|1+ Providers|[upstage.ai/](https://www.upstage.ai/feed/product/solarmini-performance-report)| +|solar-10-7b|Upstage|1+ Providers|[huggingface.co](https://huggingface.co/upstage/SOLAR-10.7B-Instruct-v1.0)| +|solar-pro|Upstage|1+ Providers|[huggingface.co](https://huggingface.co/upstage/solar-pro-preview-instruct)| +|pi|Inflection|1+ Providers|[inflection.ai](https://inflection.ai/blog/inflection-2-5)| +|deepseek-coder|DeepSeek|1+ Providers|[huggingface.co](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Instruct)| +|wizardlm-2-7b|WizardLM|1+ Providers|[huggingface.co](https://huggingface.co/dreamgen/WizardLM-2-7B)| +|wizardlm-2-8x22b|WizardLM|2+ Providers|[huggingface.co](https://huggingface.co/alpindale/WizardLM-2-8x22B)| +|sh-n-7b|Together|1+ Providers|[huggingface.co](https://huggingface.co/togethercomputer/StripedHyena-Nous-7B)| +|llava-13b|Yorickvp|1+ Providers|[huggingface.co](https://huggingface.co/liuhaotian/llava-v1.5-13b)| +|lzlv-70b|Lzlv|1+ Providers|[huggingface.co](https://huggingface.co/lizpreciatior/lzlv_70b_fp16_hf)| +|openchat-3.5|OpenChat|1+ Providers|[huggingface.co](https://huggingface.co/openchat/openchat_3.5)| +|openchat-3.6-8b|OpenChat|1+ Providers|[huggingface.co](https://huggingface.co/openchat/openchat-3.6-8b-20240522)| +|phind-codellama-34b-v2|Phind|1+ Providers|[huggingface.co](https://huggingface.co/Phind/Phind-CodeLlama-34B-v2)| +|dolphin-2.9.1-llama-3-70b|Cognitive Computations|1+ Providers|[huggingface.co](https://huggingface.co/cognitivecomputations/dolphin-2.9.1-llama-3-70b)| +|grok-2-mini|x.ai|1+ Providers|[x.ai](https://x.ai/blog/grok-2)| +|grok-2|x.ai|1+ Providers|[x.ai](https://x.ai/blog/grok-2)| +|sonar-online|Perplexity AI|2+ Providers|[docs.perplexity.ai](https://docs.perplexity.ai/)| +|sonar-chat|Perplexity AI|1+ Providers|[docs.perplexity.ai](https://docs.perplexity.ai/)| +|mythomax-l2-13b|Gryphe|1+ Providers|[huggingface.co](https://huggingface.co/Gryphe/MythoMax-L2-13b)| +|cosmosrp|Gryphe|1+ Providers|[huggingface.co](https://huggingface.co/PawanKrd/CosmosRP-8k)| +|german-7b|TheBloke|1+ Providers|[huggingface.co](https://huggingface.co/TheBloke/DiscoLM_German_7b_v1-GGUF)| +|tinyllama-1.1b|TinyLlama|1+ Providers|[huggingface.co](https://huggingface.co/TinyLlama/TinyLlama-1.1B-Chat-v1.0)| +|cybertron-7b|TheBloke|1+ Providers|[huggingface.co](https://huggingface.co/fblgit/una-cybertron-7b-v2-bf16)| +|openhermes-2.5|Teknium|1+ Providers|[huggingface.co](https://huggingface.co/datasets/teknium/OpenHermes-2.5)| +|lfm-40b|Liquid|1+ Providers|[liquid.ai](https://www.liquid.ai/liquid-foundation-models)| +|zephyr-7b|HuggingFaceH4|1+ Providers|[huggingface.co](https://huggingface.co/HuggingFaceH4/zephyr-7b-beta)| + + +### Image Models +| Model | Base Provider | Providers | Website | +|-------|---------------|-----------|---------| +|sdxl|Stability AI|1+ Providers|[huggingface.co](https://huggingface.co/docs/diffusers/en/using-diffusers/sdxl)| +|sdxl-lora|Stability AI|1+ Providers|[huggingface.co](https://huggingface.co/blog/lcm_lora)| +|sdxl-turbo|Stability AI|1+ Providers|[huggingface.co](https://huggingface.co/stabilityai/sdxl-turbo)| +|sd-1.5|Stability AI|1+ Providers|[huggingface.co](https://huggingface.co/runwayml/stable-diffusion-v1-5)| +|sd-3|Stability AI|1+ Providers|[huggingface.co](https://huggingface.co/docs/diffusers/main/en/api/pipelines/stable_diffusion/stable_diffusion_3)| +|playground-v2.5|Playground AI|1+ Providers|[huggingface.co](https://huggingface.co/playgroundai/playground-v2.5-1024px-aesthetic)| +|flux|Black Forest Labs|2+ Providers|[github.com/black-forest-labs/flux](https://github.com/black-forest-labs/flux)| +|flux-pro|Black Forest Labs|2+ Providers|[github.com/black-forest-labs/flux](https://github.com/black-forest-labs/flux)| +|flux-realism|Flux AI|2+ Providers|[]()| +|flux-anime|Flux AI|1+ Providers|[]()| +|flux-3d|Flux AI|1+ Providers|[]()| +|flux-disney|Flux AI|1+ Providers|[]()| +|flux-pixel|Flux AI|1+ Providers|[]()| +|flux-4o|Flux AI|1+ Providers|[]()| +|flux-schnell|Black Forest Labs|2+ Providers|[huggingface.co](https://huggingface.co/black-forest-labs/FLUX.1-schnell)| +|dalle|OpenAI|1+ Providers|[openai.com](https://openai.com/index/dall-e/)| +|dalle-2|OpenAI|1+ Providers|[openai.com](https://openai.com/index/dall-e-2/)| +|emi||1+ Providers|[]()| +|any-dark||1+ Providers|[]()| +|midjourney|Midjourney|1+ Providers|[docs.midjourney.com](https://docs.midjourney.com/docs/model-versions)| + +### Vision Models +| Model | Base Provider | Providers | Website | +|-------|---------------|-----------|---------| +|gpt-4-vision|OpenAI|1+ Providers|[openai.com](https://openai.com/research/gpt-4v-system-card)| +|gemini-pro-vision|Google DeepMind|1+ Providers | [deepmind.google](https://deepmind.google/technologies/gemini/)| +|blackboxai|Blackbox AI|1+ Providers|[docs.blackbox.chat](https://docs.blackbox.chat/blackbox-ai-1)| + +### Providers and vision models +| Provider | Base Provider | | Vision Models | Status | Auth | +|-------|---------------|-----------|---------|---------|---------| +| `g4f.Provider.Blackbox` | Blackbox AI | | `blackboxai, gemini-flash, llama-3.1-8b, llama-3.1-70b, llama-3.1-405b, gpt-4o, gemini-pro` | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | + +## Conclusion and Usage Tips +This document provides a comprehensive overview of various AI providers and models available for text generation, image generation, and vision tasks. **When choosing a provider or model, consider the following factors:** + 1. **Availability**: Check the status of the provider to ensure it's currently active and accessible. + 2. **Model Capabilities**: Different models excel at different tasks. Choose a model that best fits your specific needs, whether it's text generation, image creation, or vision-related tasks. + 3. **Authentication**: Some providers require authentication, while others don't. Consider this when selecting a provider for your project. + 4. **Streaming Support**: If real-time responses are important for your application, prioritize providers that offer streaming capabilities. + 5. **Vision Models**: For tasks requiring image understanding or multimodal interactions, look for providers offering vision models. + +Remember to stay updated with the latest developments in the AI field, as new models and providers are constantly emerging and evolving. + +--- + +[Return to Home](/) diff --git a/docs/requirements.md b/docs/requirements.md index a4137a64..f5c598ca 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -38,13 +38,10 @@ Install required package for loading cookies from browser: ``` pip install browser_cookie3 ``` -Install curl_cffi for better protection from being blocked: -``` -pip install curl_cffi -``` Install all packages and uninstall this package for disabling the webdriver: ``` pip uninstall undetected-chromedriver ``` -[Return to Home](/)
\ No newline at end of file +--- +[Return to Home](/) |