Skip to main content

Toolkit for fast and flexible integration with Azure OpenAI

Project description

PyPI Version PyPI Downloads GitHub Tag License Repo Size Python Version

Last Commit Commits Per Month Build Status Security Scan

GitHub Stars Contributors Open Issues Open PRs

Author LinkedIn


rsazure-openai-toolkit

A lightweight, independent toolkit (with CLI support) 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=[...]
)

🖥️ CLI Usage (rschat)

After installing the package, you can interact with Azure OpenAI directly from your terminal using:

rschat "What can you do for me?"

Make sure you have a valid .env file with your Azure credentials configured:

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

You can also ask in Portuguese (or any supported language):

rschat "Resuma o que é inteligência artificial"

If any required variable is missing, the CLI will exit with a clear error message.


🧰 Developer Tools (rschat-tools)

The toolkit includes a companion CLI called rschat-tools to assist with setup and onboarding.

To generate sample projects in your current directory, run:

rschat-tools samples

You'll see an interactive menu like this:

[0] Exit
[1] Basic Usage
[2] Advanced Usage
[3] Env Usage
[4] Env + Advanced Usage
[all] Generate All

Choose an option, and a folder will be created inside ./samples/ containing ready-to-run scripts and configurations.

💡 Samples that include a chat loop will clearly display: Type 'exit' to quit
This ensures the CLI is friendly even for non-developers who might not be familiar with Ctrl+C.

You can generate all examples at once using:

rschat-tools samples
# then select: all

This is the fastest way to explore real usage examples and start integrating Azure OpenAI with minimal setup.


Features

  • Modular and easy to extend
  • Retry mechanism with exponential backoff
  • Accepts OpenAI-compatible parameters
  • Ready for production use
  • Comes with an intuitive CLI (rschat) for direct terminal interaction

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 your AZURE_OPENAI_API_KEY and AZURE_OPENAI_ENDPOINT are correctly set in your .env file.

  • Deployment Not Found
    Check that your deployment_name matches exactly the name defined in your Azure OpenAI resource.

  • Timeouts or 5xx Errors
    The toolkit includes automatic retries with exponential backoff via tenacity. If errors persist, verify network access or Azure service status.

  • Missing Environment Variables
    Always ensure load_dotenv() is called before accessing os.getenv(...), especially when testing locally.


📝 Changelog

Check the Releases page for updates and version history.

See the full list of changes in CHANGELOG.md


🛡️ Security

If you discover any security issues, please report them privately via email: renan.siqu@gmail.com.


🤝 Contributing

Contributions are welcome! Feel free to open issues or pull requests.

To contribute:

  1. Fork the repo
  2. Create a feature branch (git checkout -b feature/my-feature)
  3. Commit your changes
  4. Open a PR

Please follow PEP8 and ensure your code passes existing tests.


🧠 Design Principles

  • Simplicity over complexity
  • Focus on production-readiness
  • Explicit configuration
  • Easy to extend and maintain

👨‍💻 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.


📬 Contact

Feel free to reach out via:

Contributions, suggestions, and bug reports are welcome!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rsazure_openai_toolkit-0.3.2.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rsazure_openai_toolkit-0.3.2-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file rsazure_openai_toolkit-0.3.2.tar.gz.

File metadata

  • Download URL: rsazure_openai_toolkit-0.3.2.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for rsazure_openai_toolkit-0.3.2.tar.gz
Algorithm Hash digest
SHA256 9060214945e5089f9a8e1b9a4d2a37a66d64d947c7c9840d01ea158218ac522a
MD5 45cfd178811fe7d069adb676140dd65b
BLAKE2b-256 7fc2bd5aac325fa3fb50ecdc7b2b06af9de06bb032e202ea20e454e56ce8fe9c

See more details on using hashes here.

File details

Details for the file rsazure_openai_toolkit-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for rsazure_openai_toolkit-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5afe5b5a51a95d60210efad0814c0be8422c7dbff4ae4f1f27d75da489803294
MD5 ea255bb552c8581051709a3bd62bce10
BLAKE2b-256 1790b686c069e3345be876de2b0906b7d4b6e82ce3241e0ec6f0ee099bfa6908

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page