Toolkit for fast and flexible integration with Azure OpenAI
Project description
rsazure-openai-toolkit
A lightweight, independent toolkit to simplify and accelerate integration with Azure OpenAI.
Installation
From PyPI:
pip install rsazure-openai-toolkit
From GitHub:
pip install git+https://github.com/renan-siqueira/rsazure-openai-toolkit
Usage
from rsazure_openai_toolkit import call_azure_openai_handler
response = call_azure_openai_handler(
api_key="your-api-key",
azure_endpoint="https://your-resource.openai.azure.com/",
api_version="2023-12-01-preview",
deployment_name="gpt-35-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Summarize what artificial intelligence is."}
]
)
print(response)
Environment Configuration
To simplify local development and testing, this toolkit supports loading environment variables from a .env file.
Create a .env file in your project root (or copy the provided .env.example) and add your Azure OpenAI credentials:
AZURE_OPENAI_API_KEY=your-api-key
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
AZURE_OPENAI_API_VERSION=2023-12-01-preview
AZURE_DEPLOYMENT_NAME=your-deployment-name
In your script, load the environment variables before calling the handler:
from dotenv import load_dotenv
import os
load_dotenv() # defaults to loading from .env in the current directory
from rsazure_openai_toolkit import call_azure_openai_handler
response = call_azure_openai_handler(
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
api_version=os.getenv("AZURE_OPENAI_API_VERSION"),
deployment_name=os.getenv("AZURE_DEPLOYMENT_NAME"),
messages=[...]
)
Features
- Modular and easy to extend
- Retry mechanism with exponential backoff
- Accepts OpenAI-compatible parameters
- Ready for production use
Requirements
- Python 3.9+
- Azure OpenAI resource and deployment
License
This project is open-sourced and available to everyone under the MIT License.
🚨 Possible Issues
-
Invalid API Key or Endpoint
Ensure yourAZURE_OPENAI_API_KEYandAZURE_OPENAI_ENDPOINTare correctly set in your.envfile. -
Deployment Not Found
Check that yourdeployment_namematches exactly the name defined in your Azure OpenAI resource. -
Timeouts or 5xx Errors
The toolkit includes automatic retries with exponential backoff viatenacity. If errors persist, verify network access or Azure service status. -
Missing Environment Variables
Always ensureload_dotenv()is called before accessingos.getenv(...), especially when testing locally.
📬 Contact
This project is maintained by Renan Siqueira Antonio.
Feel free to reach out via:
- GitHub: github.com/renan-siqueira
- Email: renan.siqu@gmail.com
Contributions, suggestions, and bug reports are welcome!
👨💻 About the Author
Hi, I'm Renan Siqueira Antonio — a technical leader in Artificial Intelligence with hands-on experience in delivering real-world AI solutions across different industries.
Over the years, I've had the opportunity to collaborate with incredible teams and contribute to initiatives recognized by companies.
This project was born from a personal need: to create a clean, reusable, and production-ready way to interact with Azure OpenAI. I'm sharing it with the hope that it helps others move faster and build better.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rsazure_openai_toolkit-0.1.2.tar.gz.
File metadata
- Download URL: rsazure_openai_toolkit-0.1.2.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9946086340761f04b8882d5d06016f0518853cf08488aa4a72ade5030b791db4
|
|
| MD5 |
20bb76ff40f4abc88ade89221080252d
|
|
| BLAKE2b-256 |
05563e981f4b9b1c2aab4c165a779eec5bfdb04c72d80fe25723ebc7dd2b7efc
|
File details
Details for the file rsazure_openai_toolkit-0.1.2-py3-none-any.whl.
File metadata
- Download URL: rsazure_openai_toolkit-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65d089260e6ad7b446d07a5ade397f356dfda32c96831e6b11a053e7a868e152
|
|
| MD5 |
fc7c4cbae19a4b2d70cd5d2787284007
|
|
| BLAKE2b-256 |
2f9a3d49a8d6d1a59a322ae0f87c256d09a95dcf01f5b2b049154eea9f0bd5f6
|