Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zhzluke96/node-chatgpt-api
ChatGPT API
https://github.com/zhzluke96/node-chatgpt-api
chatgpt chatgpt-api gpt-3 openai
Last synced: about 2 months ago
JSON representation
ChatGPT API
- Host: GitHub
- URL: https://github.com/zhzluke96/node-chatgpt-api
- Owner: zhzLuke96
- License: gpl-3.0
- Created: 2023-03-09T07:50:11.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-05T16:28:01.000Z (10 months ago)
- Last Synced: 2024-11-30T01:49:39.291Z (2 months ago)
- Topics: chatgpt, chatgpt-api, gpt-3, openai
- Language: TypeScript
- Homepage:
- Size: 143 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# chatgpt-api
ChatGPT API> fork from https://github.com/transitive-bullshit/chatgpt-api
- only support official API
- without conversation management
- same as usage calculation from OpenAI-official
- autoscaling messages# examples
## nodejs
```js
import { ChatGPTAPI } from '@llm-utils/chatgpt-api';
import nodeFetch from "node-fetch";
const main = async () => {
const api = new ChatGPTAPI({
apiKey: process.env.OPENAI_API_KEY,
fetch: nodeFetch
});
const resp = await api.createChatCompletions([
{
role: "system",
content: "You are a helpful assistant.",
},
{
role: "user",
content: "hi, what date in today?",
},
]);
console.log(resp);
}
main();
```## browser (esm)
```html{
"imports": {
"@llm-utils/chatgpt-api": "https://unpkg.com/@llm-utils/chatgpt-api@latest/dist/index.module.mjs"
}
}import { ChatGPTAPI } from '@llm-utils/chatgpt-api';
const OPENAI_API_KEY = `<YOU-API-HERE>`;
const main = async () => {
const api = new ChatGPTAPI({
apiKey: OPENAI_API_KEY,
});
const resp = await api.createChatCompletions([
{
role: "system",
content: "You are a helpful assistant.",
},
{
role: "user",
content: "hi, what date in today?",
},
]);
console.log(resp);
}
main();```
# LICENSE
GPL-V3