# Интеграция CleverApp и ChatGPT

Для того чтобы "подружить" CleverApp и ChatGPT для начала нужно завести аккаунт на сайте -  [https://platform.openai.com](https://platform.openai.com/)

<figure><img src="/files/EYJbkF6NOy9av4vYb31b" alt=""><figcaption><p>Кнопка регистрации на сайте openai.com</p></figcaption></figure>

<figure><img src="/files/QaXunOcTiFaxdPC9ROVB" alt=""><figcaption><p>Окно регистрации на сайте openai.com</p></figcaption></figure>

Далее вам на почту придет подтверждающее письмо, и вы можете заходить в личный кабинет.

<figure><img src="/files/kLUHslDIuVqxLzkKrI5b" alt=""><figcaption><p>Личный кабинет в платформе openai</p></figcaption></figure>

Чтобы завести ключ API переходим в раздел API Keys и нажимаем Create.

<figure><img src="/files/uIVw9RQHqFQlvPnL4iOe" alt=""><figcaption><p>Создание ключа апи в openai</p></figcaption></figure>

После создания ключа его можно использовать в http-блоке в сценарии бота

ссылка запроса:

<https://api.openai.com/v1/chat/completions>

в тело запроса добавляем следующий код:

```
{
    "model": "gpt-4o",
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "{{$prompt}}"
      }
    ]
}
```

<figure><img src="/files/e64qLJkTqMIkyMdsceLr" alt=""><figcaption><p>Настроенный http-блок</p></figcaption></figure>

<figure><img src="/files/rkJLJmjE3qQJUcb9DSGw" alt=""><figcaption><p>Включенный прокси в http-блоке</p></figcaption></figure>


---

# 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://help.cleverapp.pro/integracii/integraciya-cleverapp-i-chatgpt.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.
