Toolkit for fast and flexible integration with Azure OpenAI
Project description
rsazure-openai-toolkit
A lightweight, independent toolkit (with CLI support) to simplify and accelerate integration with Azure OpenAI.
๐ Contents
- Why This Project?
- Design Principles
- Key Features
- Security
- Requirements
- License
- Quick Start
- Manual Setup
- Usage
- Environment Configuration
- Logging & Usage Tracking
- Advanced Configuration (Optional)
- CLI Usage (
rschat) - Developer Tools (
rschat-tools) - Possible Issues
- Changelog
- About the Author
- Contact
โ Why This Project?
There are many tools for interacting with OpenAI โ but most are either too simplistic for real-world use, or too complex and tightly coupled to specific platforms.
This project was born out of the need for something in between:
- ๐ Transparent and auditable โ no magic, no vendor lock-in
- โ๏ธ Flexible โ can be used in scripts, production systems, or CI/CD pipelines
- ๐งฉ Modular โ easy to extend or integrate with other workflows
- ๐ง Smart โ includes retry logic, environment handling, and a developer-friendly CLI
- ๐งช Lightweight โ zero dependencies beyond whatโs needed, no bloat
Whether you're prototyping locally or running critical flows in production, this toolkit helps you do it faster, safer, and with full control.
Built by an engineer with real-world experience in AI, cloud, and software systems โ to solve real developer problems.
๐ง Design Principles
These principles define how this toolkit is designed, maintained, and expected to be used โ prioritizing security, clarity, and real-world applicability:
- Security first: No telemetry, no hidden dependencies, and full code transparency โ always auditable and verifiable.
- Simplicity over complexity: A minimal, no-friction interface that works out-of-the-box without overwhelming configuration.
- Production-readiness: Built with reliability in mind โ includes retry logic, CLI validation, and clear error handling.
- Explicit over implicit: All configurations are visible and controlled; no surprises behind the scenes.
- Extendable by design: Modular and adaptable for integration into larger systems and workflows.
- Developer & team friendly: Works great for individuals, but also for teams needing reproducibility and onboarding ease.
These principles are not just technical choices โ they're part of a commitment to making this toolkit secure, stable, and genuinely useful in professional environments.
๐ Key Features
This toolkit was designed with reliability and real-world use in mind:
- โ Modular architecture โ easy to integrate and extend
- โ
Intelligent retry mechanism with exponential backoff (via
tenacity) - โ Fully compatible with OpenAI-style request formats
- โ
CLI-first design โ includes
rschatfor terminal usage andrschat-toolsfor automation - โ Secure by design โ no telemetry, no external data sent
- โ Production-ready โ suitable for professional, CI/CD-integrated environments
- โ Transparent logging โ opt-in logging of all interactions with token usage and config
- โ Smart token tracking โ includes input/output/total token count (with fallback)
- โ Reproducible outputs โ seed-based generation for deterministic results
- โ
Config utilities โ reusable
get_model_config()function to define model behavior
๐ Security
Security is a core pillar of this project โ not an afterthought.
- โ All code is fully open, auditable, and free from telemetry or tracking
- โ No data is ever sent externally โ all logic executes locally and transparently
- โ Direct pushes and unreviewed merges are blocked by default via GitHub branch protection
- โ Releases are manually reviewed and published by the maintainer
If you discover any security vulnerabilities or have concerns:
- ๐ง Please report privately to renan.siqu@gmail.com
- ๐ See the full SECURITY policy on GitHub.
This project follows responsible disclosure practices. Thank you for helping keep the ecosystem secure.
๐ Requirements
- Python 3.9 or higher
- An active Azure OpenAI resource and deployment
๐ License
This project is open source and licensed under the MIT License, ensuring maximum flexibility and adoption.
You are free to use it in both personal and commercial projects.
๐งช Quick Start
โ ๏ธ Requires Python 3.9+ and internet access. ๐ View setup scripts
Don't want to deal with virtual environments or manual setup?
Set up your environment with one command:
โถ๏ธ Windows (PowerShell):
iwr -useb https://raw.githubusercontent.com/renan-siqueira/rsazure-openai-toolkit/main/scripts/setup.ps1 | iex
๐ง Linux/macOS (Bash):
curl -sSfL https://raw.githubusercontent.com/renan-siqueira/rsazure-openai-toolkit/main/scripts/setup.sh | bash
This will:
- Create a virtual environment
- Activate it
- Install
rsazure-openai-toolkit - Print usage instructions
Ideal for both beginners and experienced developers ๐
๐ฌ Want to try it out quickly? Run
rschat-tools samplesafter setup to see ready-to-run examples.
๐ป Manual Setup (Alternative)
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=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Summarize what artificial intelligence is."}
]
)
๐ Logging and Usage Tracking
This toolkit gives you full control over logging behavior โ by default, no logs are saved unless explicitly configured.
To enable logging:
RSCHAT_LOG_MODE=jsonl # or csv
RSCHAT_LOG_PATH=~/.rsazure/chat_logs.jsonl
What gets logged:
- Prompt and response
- Token usage (input, output, total)
- Model used
- Seed (if any)
- Response time
- Raw API response
- Full model configuration
This helps with debugging, cost estimation, and auditability โ without compromising privacy.
If you set RSCHAT_LOG_MODE=none or omit both variables, no logs will be generated โ respecting user intent by design.
๐ง Advanced Configuration (Optional)
This toolkit provides a utility function called get_model_config() to help you explicitly configure OpenAI model behavior โ in a way that is transparent, reproducible, and easy to override.
It returns a dictionary of model parameters that can be passed directly into the call_azure_openai_handler.
โ Benefits:
- Clear defaults for fast iteration
- Full support for OpenAI parameters
- Reproducible generation with optional
seed - Easy to override only what you need
๐ Supported Parameters
| Parameter | Description |
|---|---|
temperature |
Controls randomness (0.0 = deterministic, 1.0 = more creative) |
max_tokens |
Maximum number of tokens to generate |
seed |
Makes generation deterministic for same input (if supported by model) |
top_p |
Controls diversity via nucleus sampling |
frequency_penalty |
Penalizes repetition |
presence_penalty |
Encourages introduction of new topics |
stop |
Sequence(s) to stop generation (e.g., "\nUser:") |
user |
Optional user identifier (e.g., "rschat-cli") |
logit_bias |
Bias certain tokens (e.g., {token_id: -100} to suppress a token) |
โ๏ธ Default Configuration
If you call get_model_config() with no arguments, you get:
from rsazure_openai_toolkit.utils.model_config_utils import get_model_config
model_config = get_model_config()
# Returns:
# {
# "temperature": 0.7,
# "max_tokens": 1024,
# "seed": 1
# }
This ensures a balance of creativity, length, and reproducibility.
๐งฉ Custom Overrides
You can selectively override any parameter using the overrides argument:
# Adjust temperature and disable seed for non-deterministic behavior
config = get_model_config(overrides={"temperature": 0.5}, seed=None)
# Set a custom top_p and seed
config = get_model_config(overrides={"top_p": 0.9}, seed=42)
# Completely override everything
config = get_model_config(overrides={
"temperature": 0.2,
"max_tokens": 512,
"seed": 123,
"frequency_penalty": 0.5
})
If seed is provided as both an argument and inside overrides, the override takes precedence:
get_model_config(overrides={"seed": 99}, seed=1) # โ uses seed=99
๐ Why This Matters
In production scenarios, controlling model behavior explicitly improves:
- Cost and token budgeting
- Debugging and reproducibility
- Output consistency for testing and evaluation
Youโre always in control โ no hidden defaults.
๐ก This function powers the CLI (
rschat) under the hood, and you can reuse it in your own apps or pipelines.
๐ป 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.
๐ Logging with CLI
To enable logging while using the CLI:
RSCHAT_LOG_MODE=jsonl
RSCHAT_LOG_PATH=~/.rsazure/chat_logs.jsonl
This will record your interactions, including prompt, response, token usage, seed, and full configuration.
To disable logging:
RSCHAT_LOG_MODE=none
# Or omit RSCHAT_LOG_MODE and RSCHAT_LOG_PATH variables
๐งฐ 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.
๐จ 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.
๐ฆ Changelog
We follow semantic versioning to ensure predictable upgrades.
- ๐ Check the full CHANGELOG.md for detailed release notes
- ๐ Visit the Releases Page to explore version history
๐จโ๐ป About the Author
I'm a software engineer with real-world experience across backend, frontend, DevOps, cloud, and AI โ building solutions that are designed to last.
Today, my passion is helping teams make AI development more accessible, maintainable, and truly production-ready โ with full control, transparency, and respect for sound engineering principles.
I believe that great tools should be simple, powerful, and built to empower โ not to lock people in. Thatโs the mindset behind everything I build and share.
๐ฌ Contact
I'm always open to feedback, ideas, or professional collaboration.
- GitHub: github.com/renan-siqueira
- Email: renan.siqu@gmail.com
- LinkedIn: linkedin.com/in/renan-siqueira-antonio
Feel free to connect or open an issue.
Suggestions, contributions, and responsible disclosures are always welcome.
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.4.0.tar.gz.
File metadata
- Download URL: rsazure_openai_toolkit-0.4.0.tar.gz
- Upload date:
- Size: 22.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad6c290f14fbd729d00fe39b1bf7ab13bb041961ed3283c63ccfc3e700cb4e99
|
|
| MD5 |
5360d030e28f4d35680f032d0961964e
|
|
| BLAKE2b-256 |
f69c4235f21a56ccbcc03d10328c40647f80e22e4a6af9bd7d3ec0804e05e775
|
File details
Details for the file rsazure_openai_toolkit-0.4.0-py3-none-any.whl.
File metadata
- Download URL: rsazure_openai_toolkit-0.4.0-py3-none-any.whl
- Upload date:
- Size: 22.4 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 |
4330c18f7ad081d0f63ec78df813d2f83ab13384754eb04e12fec77855820e85
|
|
| MD5 |
f800a00af59353e02c335a4f5221692c
|
|
| BLAKE2b-256 |
f7a74fbecd05dcccb307d1ebdcdf0c167fb486304b5e2961304a07fc489c0c5c
|