Getting your API key
Message the bot
Contact @KellyAIBot on Telegram to request your API key.
Receive your key
The bot will provide you with a unique API key. Keep this key secure—don’t share it publicly or commit it to version control.
Initializing the client
Basic initialization
The simplest way to initialize the Kelly AI client is by passing your API key directly:Using environment variables
For better security, store your API key in an environment variable:Configuration options
TheKellyAPI class accepts several configuration parameters:
Parameters
Your Kelly AI API key obtained from @KellyAIBot
The base URL for the Kelly AI API. You typically don’t need to change this unless you’re using a custom endpoint.
A custom
aiohttp.ClientSession class for advanced use cases. Useful if you need to configure custom timeouts, proxies, or connection pooling.Using a custom session
For advanced scenarios, you can provide your ownaiohttp.ClientSession configuration:
Authentication errors
The SDK will raise anInvalidApiKey exception if your API key is invalid or unauthorized:
Authentication is checked on every API request. If you receive a 401 or 403 status code, the SDK will automatically raise an
InvalidApiKey exception.Best practices
Secure storage
Store API keys in environment variables or secrets management systems, never in code.
Separate keys
Use different API keys for development, staging, and production environments.
Key rotation
Regularly rotate your API keys and update them across your applications.
Access control
Limit who has access to your API keys within your organization.
Next steps
Now that you understand authentication, you’re ready to explore the SDK’s features:Image generation
Generate images with Stable Diffusion and SDXL models
Language models
Use ChatGPT, Gemini, and other LLMs for text generation
Image tools
Upscale images, remove backgrounds, and more
Voice synthesis
Convert text to speech with multiple voice models