> For the complete documentation index, see [llms.txt](https://whoman.gitbook.io/openlib-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://whoman.gitbook.io/openlib-documentation/initialize-the-library.md).

# Initialize the library

## But first.. what even is OpenLib?

OpenLib is a library that lets you use the chatgpt api for free (almost)\
With this library you can do Text Completion and Chat Completion, it is open source and can be found in [this](https://github.com/altacountbabi/OpenLib) github repository, please leave a star if you like this project\
\
And keep in mind, this is for roblox executors not roblox games however i might port it to work as a server script that you can add, if we get 5 stars on the [github repo](https://github.com/altacountbabi/OpenLib) i will do it.

## Get an api key.

Sadly we need an api key for this too but thankfully its free, however there is a credit system but lets ignore that for now.

You can get an api key from [this](https://discord.gg/pawan-krd-1055397662976905229) server, to get it you have to go to the "Bot" channel and use the /key slash command and the bot should give you your api key.

## Initializing the library

Alright now lets initialize the library, to do this we will add this piece of code:

{% code lineNumbers="true" fullWidth="false" %}

```lua
local OpenLib = loadstring(game:HttpGet('https://raw.githubusercontent.com/altacountbabi/OpenLib/main/src.lua'))()

local client = OpenLib.init({
    api_key = 'pk-Nx*********************************************id'
})
```

{% endcode %}

<details>

<summary>All Arguments/Options</summary>

api\_key (string) (required)

api\_base (string) (optional) (default: "<https://api.pawan.krd/v1>") changes the api endpoint so you can actually just use the official openai api if you want to

reset\_ip (bool) (optional) (default: true) this only works when the api\_base is "<https://api.pawan.krd/v1>" or default i recommend that you leave this on as it will attempt to link your api key to the user's ip

</details>

Alright, now we have the client loaded we can use [text completion](/openlib-documentation/text-completion.md) or [chat completion](/openlib-documentation/chat-completion.md)
