Skip to content

Connecting OpenAI

This guide explains how to configure OpenAI as the AI provider for TG Support Bot.

TIP

Before proceeding, make sure the AI assistant is enabled by following the base integration guide.

Getting an API Key

  1. Sign in to OpenAI API Keys.
  2. Generate a new key and copy it — you will need it in the next step.

Configuring .env

Add or update the following variables in your .env file:

env
OPENAI_API_KEY=your_api_key
OPENAI_BASE_URL=https://api.openai.com/v1
OPENAI_MODEL=gpt-4o-mini
OPENAI_MAX_TOKENS=2000
OPENAI_TEMPERATURE=0.7
VariableDescription
OPENAI_API_KEYYour OpenAI API key
OPENAI_BASE_URLBase URL for API requests — defaults to https://api.openai.com/v1
OPENAI_MODELModel to use (e.g. gpt-4o-mini, gpt-4o, gpt-3.5-turbo)
OPENAI_MAX_TOKENSMaximum number of tokens in a single response
OPENAI_TEMPERATURECreativity level: 0 — deterministic, 1 — creative

Enabling OpenAI

Set OpenAI as the default provider in your .env file:

env
AI_ENABLED=true
AI_DEFAULT_PROVIDER=openai

Released under the MIT License.