Giter VIP home page Giter VIP logo

liboai's Introduction


Introduction

liboai is a simple, unofficial C++17 library for the OpenAI API. It allows developers to access OpenAI endpoints through a simple collection of methods and classes. The library can most effectively be thought of as a spiritual port of OpenAI's Python library, simply called openai, due to its similar structure - with few exceptions.

Features

Usage

See below for just how similar in style liboai and its Python alternative are when generating an image using DALL-E.

DALL-E Generation in Python.
import openai
import os

openai.api_key = os.getenv("OPENAI_API_KEY")
response = openai.Image.create(
    prompt="A snake in the grass!",
    n=1,
    size="256x256"
)
print(response["data"][0]["url"])
DALL-E Generation in C++.
#include "liboai.h"

using namespace liboai;

int main() {
  OpenAI oai;
  oai.auth.SetKeyEnv("OPENAI_API_KEY");
	
  Response res = oai.Image->create(
    "A snake in the grass!",
    1,
    "256x256"
  );

  std::cout << res["data"][0]["url"] << std::endl;
}

Running the above will print out the URL to the resulting generated image, which may or may not look similar to the one found below.

Example Image

Keep in mind the above C++ example is a minimal example and is not an exception-safe snippet. Please see the documentation for more detailed and exception-safe code snippets.

Dependencies

For the library to work the way it does, it relies on two major dependencies. These dependencies can be found listed below.

If building the library using the provided solution, it is recommended to install these dependencies using vcpkg.

Documentation

For detailed documentation and additional code examples, see the library's documentation here.

Contributing

Artificial intelligence is an exciting and quickly-changing field.

If you'd like to partake in further placing the power of AI in the hands of everyday people, please consider contributing by either submitting new code and features via a Pull Request. If you have any issues using the library, or just want to suggest new features, feel free to contact me directly using the info on my profile or open an Issue.

liboai's People

Contributors

d7ead avatar huckdirks avatar jmgr avatar khei4 avatar lodenrogue avatar pkeir avatar pkusunjy avatar renovate[bot] avatar sasmaster 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.