# Getting Started

{% hint style="warning" %}
Before you can make requests to the GLChat API, you must obtain **API Key**. You can obtain them by contacting us via [hi\[at\]glair.ai](mailto:hi@glair.ai) or via our representative for your company.
{% endhint %}

<a href="https://github.com/gdplabs/glchat-sdk-cookbook/tree/main/glchat/examples/hello-world" class="button primary" data-icon="github">View full project code on GitHub</a>

## GLChat SDK

You can send message programmatically using GLChat SDK.

{% tabs %}
{% tab title="Python" %}
Install

```bash
pip install glchat-sdk
```

Set API Key

```bash
export GLCHAT_API_KEY=...
```

Make your first API call

{% code lineNumbers="true" %}

```python
from glchat_sdk import GLChat

client = GLChat()
response = client.message.create(
    chatbot_id="no-op",
    message="Hello!",
    stream=False
)

print(response.message)
```

{% endcode %}

This is a sample of the response:

```
Hello! How can I assist you today?
```

More details on [PyPI glchat-sdk](https://pypi.org/project/glchat-sdk/).
{% endtab %}

{% tab title="JavaScript" %}
Install

```bash
npm install glchat-sdk
```

Set API Key

```bash
export GLCHAT_API_KEY=...
```

Make your first API call

{% code lineNumbers="true" %}

```javascript
import { GLChat } from "glchat-sdk";

const client = new GLChat();

void (async () => {
  const result = await client.message.create({
    chatbot_id: "no-op",
    message: "Hello!",
    stream: false
  });

  for await (const chunk of result) {
    console.log(chunk);
  }
})();
```

{% endcode %}

The response will be a streaming Server-Sent Event (SSE) so you can display parts of the response as they become available. This is a sample of the streaming response:

{% code lineNumbers="true" %}

```json
data:{"conversation_id": null, "user_message_id": null, "assistant_message_id": null, "created_date": 1750403502862, "status": "response", "message": "Hello"}
data:{"conversation_id": null, "user_message_id": null, "assistant_message_id": null, "created_date": 1750403502873, "status": "response", "message": "Hello!"}
data:{"conversation_id": null, "user_message_id": null, "assistant_message_id": null, "created_date": 1750403502884, "status": "response", "message": "Hello! How"}
data:{"conversation_id": null, "user_message_id": null, "assistant_message_id": null, "created_date": 1750403502894, "status": "response", "message": "Hello! How can"}
data:{"conversation_id": null, "user_message_id": null, "assistant_message_id": null, "created_date": 1750403502913, "status": "response", "message": "Hello! How can I"}
data:{"conversation_id": null, "user_message_id": null, "assistant_message_id": null, "created_date": 1750403502924, "status": "response", "message": "Hello! How can I assist"}
data:{"conversation_id": null, "user_message_id": null, "assistant_message_id": null, "created_date": 1750403502969, "status": "response", "message": "Hello! How can I assist you"}
data:{"conversation_id": null, "user_message_id": null, "assistant_message_id": null, "created_date": 1750403502980, "status": "response", "message": "Hello! How can I assist you today"}
data:{"conversation_id": null, "user_message_id": null, "assistant_message_id": null, "created_date": 1750403502991, "status": "response", "message": "Hello! How can I assist you today?"}
data:{"conversation_id": null, "user_message_id": null, "assistant_message_id": null, "created_date": 1750403503002, "status": "response", "message": "Hello! How can I assist you today?\n"}
```

{% endcode %}

More details on [NPM glchat-sdk](https://www.npmjs.com/package/glchat-sdk).
{% endtab %}

{% tab title="cURL" %}
{% code lineNumbers="true" %}

```bash
curl -X POST 'https://chat.gdplabs.id/api/proxy/message' \
-H 'Authorization: Bearer '$GLCHAT_API_KEY'' \
-F 'chatbot_id=no-op' \
-F 'message=Hello!'
```

{% endcode %}

The response will be a streaming Server-Sent Event (SSE) so you can display parts of the response as they become available. This is a sample of the streaming response:

{% code lineNumbers="true" %}

```json
data:{"conversation_id": null, "user_message_id": null, "assistant_message_id": null, "created_date": 1750403502862, "status": "response", "message": "Hello"}
data:{"conversation_id": null, "user_message_id": null, "assistant_message_id": null, "created_date": 1750403502873, "status": "response", "message": "Hello!"}
data:{"conversation_id": null, "user_message_id": null, "assistant_message_id": null, "created_date": 1750403502884, "status": "response", "message": "Hello! How"}
data:{"conversation_id": null, "user_message_id": null, "assistant_message_id": null, "created_date": 1750403502894, "status": "response", "message": "Hello! How can"}
data:{"conversation_id": null, "user_message_id": null, "assistant_message_id": null, "created_date": 1750403502913, "status": "response", "message": "Hello! How can I"}
data:{"conversation_id": null, "user_message_id": null, "assistant_message_id": null, "created_date": 1750403502924, "status": "response", "message": "Hello! How can I assist"}
data:{"conversation_id": null, "user_message_id": null, "assistant_message_id": null, "created_date": 1750403502969, "status": "response", "message": "Hello! How can I assist you"}
data:{"conversation_id": null, "user_message_id": null, "assistant_message_id": null, "created_date": 1750403502980, "status": "response", "message": "Hello! How can I assist you today"}
data:{"conversation_id": null, "user_message_id": null, "assistant_message_id": null, "created_date": 1750403502991, "status": "response", "message": "Hello! How can I assist you today?"}
data:{"conversation_id": null, "user_message_id": null, "assistant_message_id": null, "created_date": 1750403503002, "status": "response", "message": "Hello! How can I assist you today?\n"}
```

{% endcode %}
{% endtab %}
{% endtabs %}

For more advanced usages, see [how-to-guides](https://gdplabs.gitbook.io/glchat/sdk/how-to-guides "mention").

## Notes for On-Premises GL Chat

If you use *self-managed on-premises GL Chat*, you can set API Keys via environment variable:

```bash
# Available API Keys
PROXY_API_KEYS=api-key-1,api-key-2

# What endpoints can user access via API (in this examples, user can only access /message)
PROXY_ENDPOINTS=message

# What endpoints can user access via API (in this examples, user can access /message and /conversations)
PROXY_ENDPOINTS=message,conversations
```

See [glchat-ui](https://gdplabs.gitbook.io/glchat/sdk/resources/white-label/environment-variables/glchat-ui "mention") for more details on environment variables.
