Code Monkey home page Code Monkey logo

lobe2api's Introduction

lobe2api

Welcome to the lobe2api, offering free self-hosted API access to lobe-chat with OpenAI's familiar structure, so no code changes are needed.

Features

  • Streaming Response: The API supports streaming response, so you can get the response as soon as it's available.
  • API Endpoint Compatibility: Full alignment with official OpenAI API endpoints, ensuring hassle-free integration with existing OpenAI libraries.
  • Complimentary Access: No charges for API usage, making advanced AI accessible to everyone even without an API key.

Installing/Self-Hosting Guide

  1. Edit the .env file, add variables such as PORT ใ€ BASE_URL ใ€ AUTH_TOKEN .
Key Default Value Note
PORT 3000 Port that lobe2api listens on
BASE_URL http://localhost:1234 That lobe-chat url that you need to reverse
AUTH_TOKEN Authentication for your lobe2api
ACCESS_CODE The access code for the lobe-chat url that you need to reverse
  1. Run the following command:
    npm install
    npm run start
  2. Done! You can now connect to your local server's API at:
    http://localhost:PORT/v1/chat/completions
    
    Note that the base URL is http://localhost:PORT/v1.

Usage Examples

Leverage the same integration code as OpenAI's official libraries by simply adjusting the API key and base URL in your requests. For self-hosted setups, ensure to switch the base URL to your local server's address as mentioned above.

Example Usage with curl

curl --location 'http(s)://localhost:PORT/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer AUTH_TOKEN' \
--data '{
  "model": "gpt-3.5-turbo",
  "stream": true,
  "messages": [{"role": "user", "content": "Tell me a story about socialism."}]
}'

License

This repository is under the AGPL-3.0 License. Refer to the LICENSE file for detailed information.

lobe2api's People

Contributors

k0baya avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.