Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
easychen authored Mar 23, 2023
1 parent 9bfbd56 commit 1069c49
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,51 +11,51 @@ Simple proxy for OpenAi api via a one-line docker command

以下英文由GPT翻译。The following English was translated by GPT.

## NodeJS Deployment
## NodeJS Deployment

You can deploy ./app.js to any environment that supports nodejs 14+, such as cloud functions and edge computing platforms.

1. Copy app.js and package.json to the directory
2. Run yarn install to install dependencies
3. Run node app.js to start the service.
2. Install dependencies with yarn install
3. Start the service with node app.js

## Docker Deployment

```
docker run -p 9000:9000 easychen/ai.level06.com:latest
```

The proxy address is http://${IP}:9000.
Proxy address is http://${IP}:9000

### Available Environment Variables

1. PORT: Service port.
2. PROXY_KEY: Proxy access key used to restrict access.
3. TIMEOUT: Request timeout, default is 5 seconds.
1. PORT: Service port
2. PROXY_KEY: Proxy access key, used to restrict access
3. TIMEOUT: Request timeout, default 5 seconds

## Usage of the API
## Interface Usage

1. Change the request address of OpenAI (https://api.openai.com) to the address of this proxy (without a slash).
2. If PROXY_KEY is set, add `:<PROXY_KEY>` after the OpenAI key. If not set, no modification is required.
1. Change the domain name/IP (with port number) of the original openai request address (such as https://api.openai.com) to the domain name/IP of this proxy
2. If PROXY_KEY is set, add `:<PROXY_KEY>` after the openai key. If not set, no modification is required.

## Explanation
## Notes

1. Only GET and POST method interfaces are supported, and file-related interfaces are not supported.
2. ~~SSE is currently not supported, so stream-related options need to be turned off.~~ SSE is OK now.
2. ~~SSE is not currently supported, so the stream-related options need to be turned off~~ Supported now.

## Example of Client Usage
## Client Usage Example

Take `https://www.npmjs.com/package/chatgpt` as an example.
Taking `https://www.npmjs.com/package/chatgpt` as an example:

```js
chatApi= new gpt.ChatGPTAPI({
apiKey: 'sk.....:<proxy_key here>',
apiBaseUrl: "http://localhost:9001", // Pass the proxy address
apiKey: 'sk.....:<proxy_key_here>',
apiBaseUrl: "http://localhost:9001/v1", // Replace with proxy domain name/IP
});

```

## Acknowledgments

1. SSE referenced the related code in [chatgpt-api project](https://github.com/transitive-bullshit/chatgpt-api/blob/main/src/fetch-sse.ts).
1. SSE reference to [chatgpt-api project related code](https://github.com/transitive-bullshit/chatgpt-api/blob/main/src/fetch-sse.ts)

0 comments on commit 1069c49

Please sign in to comment.