# 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](https://whoman.gitbook.io/openlib-documentation/text-completion) or [chat completion](https://whoman.gitbook.io/openlib-documentation/chat-completion)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://whoman.gitbook.io/openlib-documentation/initialize-the-library.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
