How to setup a free OpenAI GPT-4 API on your own
- Clone this repository to your local machine.
git clone https://github.com/username/gpt4free-demo.git
- Navigate into the cloned directory.
cd gpt4free-demo
- There is an example environment file in this directory called
.env.example
. You need to copy this file and rename the copy to.env
. You can do this with the following command:
cp .env.example .env
-
Open the newly created
.env
file with your preferred text editor. Fill in your own values for the given variables. Save and close the file when you're finished. -
Now, you can start your services using Docker Compose. Run the following command:
docker-compose up -d
This command will start the services defined in your docker-compose.yml
file in the background and leave them running.
Note: If you change any environment variables in your .env
file, you will need to stop and restart your services for the changes to take effect. You can do this with docker-compose down
and docker-compose up -d
respectively.
-
Once the services are running, the API will be accessible at
http://127.0.0.1:13000
. You can test it using the following examples:-
Forefront Model
http://127.0.0.1:13000/ask?prompt=whoareyou&model=forefront http://127.0.0.1:13000/ask/stream?prompt=whoareyou&model=forefront
-
MCBBS Model
http://127.0.0.1:13000/ask?prompt=nothing&model=mcbbs&messages=[{"role":"system","content":"IMPORTANT: You are a virtual assistant powered by the gpt-3.5-turbo model, now time is 2023/6/3 13:42:27}"},{"role":"user","content":"你好\n"},{"role":"assistant","content":"你好!有什么我可以帮助你的吗?"},{"role":"user","content":"写个冒泡排序\n"}]
-
You Model
http://127.0.0.1:13000/ask?prompt=whoareyou&model=you http://127.0.0.1:13000/ask/stream?prompt=whoareyou&model=you
-
- Website: https://productsway.com/
- Twitter: @jellydn
- Github: @jellydn