# Call API

### Overview

| Field                                           | Description                                                                                                                                                  | Example                               |
| ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------- |
| URL                                             | The URL of the API endpoint you are calling                                                                                                                  | <https://api.openai.com/v1/responses> |
| HTTP Method                                     | The HTTP method verb                                                                                                                                         | POST                                  |
| Bearer token                                    | The authentication token for your API call. Generally this is issued to you by the API service and is unique and private. Do not share this key with anyone. | sk-xyzabcdef                          |
| Request body                                    | The request body for the API call. Must be properly formatted JSON. Leave this blank for GET requests.                                                       | <p>{                                  |
| <br>"model": "gpt-4.1",                         |                                                                                                                                                              |                                       |
| <br>"input": "Give me some whale facts please!" |                                                                                                                                                              |                                       |
| <br>}</p>                                       |                                                                                                                                                              |                                       |
| Response body variable name                     | This is the variable which you can use in other nodes to process the API response body.                                                                      | gptResponse                           |

### OpenAPI (GPT) example

Example bot in action:

<figure><img src="https://1776366025-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0L1z_JwGF9x5j-YBBE%2Fuploads%2F57T5hHW4wjOFWbKKb0EK%2Fimage.png?alt=media&#x26;token=6a1bf07f-a82e-4cbc-a996-69cf93eb723d" alt=""><figcaption><p>With this command, we'll let users ask questions to Chat GPT via our bot</p></figcaption></figure>

The following flow in BSD is used to get a prompt from the user and call Chat GPT (via OpenAI API)

<figure><img src="https://1776366025-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0L1z_JwGF9x5j-YBBE%2Fuploads%2FS4P2FUxp8h4W1X5LFaQx%2Fimage.png?alt=media&#x26;token=7da0246e-2c1b-40b8-a81d-ea863fb64519" alt=""><figcaption><p>Flow layout, sends a message for API success with the response</p></figcaption></figure>

<figure><img src="https://1776366025-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0L1z_JwGF9x5j-YBBE%2Fuploads%2F93j5blTBAToXus85Bp0a%2Fimage.png?alt=media&#x26;token=ece8269a-1590-4514-846a-4c62380f2778" alt=""><figcaption><p>The get input node is used to save the text after the !gpt command to a variable. We will pass this to the API as the prompt</p></figcaption></figure>

<figure><img src="https://1776366025-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0L1z_JwGF9x5j-YBBE%2Fuploads%2FWlD06QYpEjI3d2GkljUC%2Fimage.png?alt=media&#x26;token=0ba33360-ce47-4a00-a772-cb701c480518" alt=""><figcaption><p>The Call API node is used to send the user's prompt to the API endpoint to get a response from Open AI. Make sure to enter your actual bearer token here.</p></figcaption></figure>

<figure><img src="https://1776366025-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0L1z_JwGF9x5j-YBBE%2Fuploads%2FBjLGu1sMYFO6Pik666zi%2Fimage.png?alt=media&#x26;token=5dbea207-bc3c-4242-b42d-3c8d08e898cb" alt=""><figcaption><p>The send message node is used to send the GPT response in a message to the user.</p></figcaption></figure>

We can reference `gptResponse` since we used that variable name in the API Call node.

That's it! Now when a user uses the `!gpt` command with our bot, their prompt will be sent to OpenAI and our bot will respond.
