> For the complete documentation index, see [llms.txt](https://docs.flutfast.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flutfast.com/backend/working-with-open-ai.md).

# Working with Open AI

## OpenAI Methods Documentation

This file contains various functions utilizing the OpenAI API for different purposes.

### Initialization

Before using any OpenAI functions, ensure that you have initialized the API client with your API key.

### Functions

#### chatCompletion()

This function allows interactive chat with an AI model. It sends a series of messages between the user and the assistant, generating responses from the AI model based on the conversation.

#### generateImage()

This function generates an image based on a given prompt. It utilizes the DALL-E model to create an image that corresponds to the provided description.

#### readingImage()

This function describes the content of an image. It takes an image URL as input and uses the GPT-4 Vision Preview model to generate a textual description of the image.

#### moderateInput()

This function moderates input text for inappropriate content. It sends a text input to the moderation API, which analyzes the text and returns a moderation decision.

### Usage

These functions can be imported into your application and called as needed to leverage the capabilities of the OpenAI API for various tasks.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.flutfast.com/backend/working-with-open-ai.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
