GPT-4 API

GPT4Free TypeScript Version: Providing a free OpenAI GPT-4 API!

4 min


[vc_row][vc_column][vc_headings linewidth=”0″ borderwidth=”1″ borderclr=”#000000″ title=”GPT4Free TypeScript Version” google_fonts=”font_family:Comfortaa%3A300%2Cregular%2C700|font_style:700%20bold%20regular%3A700%3Anormal” titlesize=”60″ titleclr=”#000000″]Providing a free OpenAI GPT-4 API![/vc_headings][vc_single_image image=”3056″ alignment=”center”][vc_column_text]GPT4Free TypeScript Version is a project that aims to provide a free GPT-4 API, a powerful natural language processing model developed by OpenAI. The project is based on TypeScript, a programming language that extends JavaScript with static types and other features. The project uses TensorFlow.js, a library for machine learning in JavaScript, to implement the GPT-4 model and run it in the browser or on Node.js.[/vc_column_text][vc_separator][/vc_column][/vc_row][vc_row][vc_column][vc_headings style=”theme4″ borderclr=”#000000″ style2=”image” title=”Getting Started” google_fonts=”font_family:Comfortaa%3A300%2Cregular%2C700|font_style:700%20bold%20regular%3A700%3Anormal” lineheight=”3″ titlesize=”40″ titleclr=”#000000″ image_id=”2854″][/vc_headings][vc_column_text]

To get started, A file named .env is required for this project.

This step is essential for all methods of operation.

http_proxy=http://host:port
rapid_api_key=xxxxxxxxxx
EMAIL_TYPE=temp-email44
DEBUG=0
POOL_SIZE=1
  • http_proxy: If you have trouble reaching the desired site, you may need to set up a proxy server.
  • rapid_api_key: This is a required configuration for using the forefront api. The apikey allows you to receive registration emails. get api key here
  • EMAIL_TYPE: temporary email types include temp-email temp-email44 tempmail-lol
    • temp-email: The maximum number of requests per day is 100. To increase this limit, you need to link a credit card to your account. This service is very reliable!
    • temp-email44: limited 100req/days! Stable!
    • tempmail-lol: limited to 25request/5min. Not Stable.
  • DEBUG: Valid when use forefront Set it to 1 when running locally. show reverse process
  • POOL_SIZEforefront concurrency size. Keep set=1 until you run it successfully!!! You can engage in {POOL_SIZE} conversations concurrently. A higher pool size enables more parallel conversations, but it also consumes more RAM.

Run it locally 🖥️

# install module
yarn
# start server
yarn start

Run with docker🐳(Recommended!)

docker run -p 3000:3000 --env-file .env xiangsx/gpt4free-ts:latest

Deploy with docker-compose 🎭

To run the application with docker, you need to create a .env file first. Then, follow the instructions in the “Run with docker” section.

deployment:

docker-compose up --build -d

[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_headings style=”theme4″ borderclr=”#000000″ style2=”image” title=”Running GPT-4″ google_fonts=”font_family:Comfortaa%3A300%2Cregular%2C700|font_style:700%20bold%20regular%3A700%3Anormal” lineheight=”3″ titlesize=”40″ titleclr=”#000000″ image_id=”2854″][/vc_headings][vc_message]

Return when chat complete http://127.0.0.1:3000/ask?prompt=***&model=***&site=***

[/vc_message][vc_message]

Return with eventstream http://127.0.0.1:3000/ask/stream?prompt=***&model=***&site=***

[/vc_message][vc_column_text]

Request Parameters📝

  • prompt: your question. It can be a string or jsonstr.
    • example jsonstr:[{"role":"user","content":"你好\n"},{"role":"assistant","content":"你好!有什么我可以帮助你的吗?"},{"role":"user","content":"你是谁"}]
    • example string你是谁
  • model: default gpt3.5-turbo. model include:gpt4 gpt3.5-turbo
  • site: default you. target site, include forefront you mcbbs

Response Parameters 🔙

Response when chat ends (/ask):

interface ChatResponse {
    content: string;
    error?: string;
}

Response with stream like(/ask/stream):

event: message
data: {"content":"I"}

event: done
data: {"content":"'m"}

event: error
data: {"error":"some thind wrong"}

Example💡

  1. request to site you with history

req:

127.0.0.1:3000/ask?site=you&prompt=[{“role”:”user”,”content”:”hello”},{“role”:”assistant”,”content”:”Hi there! How can I assist you today?”},{“role”:”user”,”content”:”who are you”}]

res:

{
  "content": "Hi there! How can I assist you today?"
}

[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_headings style=”theme4″ borderclr=”#000000″ style2=”image” title=”Sites using this project” google_fonts=”font_family:Comfortaa%3A300%2Cregular%2C700|font_style:700%20bold%20regular%3A700%3Anormal” lineheight=”3″ titlesize=”40″ titleclr=”#000000″ image_id=”2871″][/vc_headings][vc_separator color=”sandy_brown” border_width=”3″][vc_column_text css=”.vc_custom_1686630222221{border-top-width: 2px !important;border-right-width: 2px !important;border-bottom-width: 2px !important;border-left-width: 2px !important;background-color: #b5b5b5 !important;border-left-color: #0a0a0a !important;border-left-style: solid !important;border-right-color: #0a0a0a !important;border-right-style: solid !important;border-top-color: #0a0a0a !important;border-top-style: solid !important;border-bottom-color: #0a0a0a !important;border-bottom-style: solid !important;border-radius: 2px !important;}”]

model support status active time
ai.mcbbs.gq gpt3.5 Active after 2023-06-03
forefront.ai 👍GPT-4/gpt3.5 Active after 2023-06-03
aidream GPT-3.5 Active after 2023-05-12
you.com GPT-3.5 Active after 2023-05-12
phind.com GPT-4 / Internet / good search Active
bing.com/chat GPT-4/3.5
poe.com GPT-4/3.5
writesonic.com GPT-3.5 / Internet
t3nsor.com GPT-3.5

[/vc_column_text][vc_btn title=”Project Page” color=”inverse” align=”center” i_align=”right” i_icon_fontawesome=”fab fa-github” add_icon=”true” link=”url:https%3A%2F%2Fgithub.com%2Fxiangsx%2Fgpt4free-ts”][/vc_column][/vc_row][vc_row][vc_column][vc_separator color=”turquoise” border_width=”2″][vc_headings style=”theme4″ borderclr=”#000000″ style2=”image” title=”Notice” google_fonts=”font_family:Comfortaa%3A300%2Cregular%2C700|font_style:700%20bold%20regular%3A700%3Anormal” lineheight=”3″ titlesize=”40″ titleclr=”#000000″ image_id=”3031″][/vc_headings][vc_column_text]This GitHub repository contains APIs from various sites without their authorization or affiliation. This project is for learning purposes only. This is a personal hobby project. Sites can contact developer to request better security or removal of their site from this repository.[/vc_column_text][/vc_column][/vc_row]

Comments

comments


Like it? Share with your friends!

-4

0 Comments

Your email address will not be published. Required fields are marked *

Belmechri

I am an IT engineer, content creator, and proud father with a passion for innovation and excellence. In both my personal and professional life, I strive for excellence and am committed to finding innovative solutions to complex problems.