1.1.1 • Published 25 days ago

@llm-utils/chatgpt-api v1.1.1

Weekly downloads
-
License
GPLv3
Repository
github
Last release
25 days ago

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

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)

<script type="importmap">
    {
        "imports": {
            "@llm-utils/chatgpt-api": "https://unpkg.com/@llm-utils/chatgpt-api@latest/dist/index.module.mjs"
        }
    }
</script>
<div id="app"></div>
<script type="module">
    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();
</script>

LICENSE

GPL-V3

1.1.1

25 days ago

1.1.0

10 months ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago