SDK for querying Azure OpenAI through Azure API Management Gateway.
Project description
Tieto Azure APIM SDK
A Python SDK that allows you to query Azure OpenAI APIs securely through Azure API Management (APIM). This simplifies interaction with Azure OpenAI endpoints and abstracts the complexities of making authenticated HTTP requests.
📦 Installation
pip install tieto_azure_apim_sdk
Usage Example
from tieto_azure_apim_sdk import TietoAPIMClient
import os
from dotenv import load_dotenv
load_dotenv()
# Load configuration from environment variables
APIM_ENDPOINT = os.getenv("APIM_ENDPOINT")
SUBSCRIPTION_KEY = os.getenv("SUBSCRIPTION_KEY")
# Initialize the client
client = TietoAPIMClient(APIM_ENDPOINT=APIM_ENDPOINT, SUBSCRIPTION_KEY=SUBSCRIPTION_KEY)
# Send a chat request
response = client.chat(
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "How to build a website like Snapchat. give all the details in 200 words"}
],
max_tokens=500,
stream=False
)
print("Response:", response)
| Parameter | Type | Description |
|---|---|---|
APIM_ENDPOINT |
str |
Your Azure API Management Gateway URL. Example: https://my-apim.azure-api.net |
SUBSCRIPTION_KEY |
str |
The subscription key generated in Azure APIM for authenticating API requests. |
messages |
list |
A list of chat messages following OpenAI's Chat Completion API format. |
max_tokens |
int |
The maximum number of tokens to generate in the response. |
stream |
bool |
If True, responses are streamed in chunks; if False, the complete response is returned. |
Example Scenarios
- Basic Synchronous Request
response = client.chat(
messages=[{"role": "user", "content": "Tell me a joke."}],
max_tokens=500,
stream=False
)
- Streaming Large Responses
response = client.chat(
messages=[{"role": "user", "content": "Explain quantum computing in simple terms."}],
max_tokens=1000,
stream=True
)
When using stream=True, make sure to handle the response appropriately in chunks.
📅 Versioning
This project uses Semantic Versioning. Example:
MAJOR: Breaking API changes
MINOR: Backward-compatible new features
PATCH: Bug fixes
📄 License This project is licensed under the MIT License.
Feel free to contribute or raise issues on GitHub. https://github.com/NaveenGandla/azure_apim_openai_sdk
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 tieto_azure_apim_sdk-0.1.2.tar.gz.
File metadata
- Download URL: tieto_azure_apim_sdk-0.1.2.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1793a14392f7b37dc0b5fedae1f41e511d3efe0e62de912777ebe564e2aa101
|
|
| MD5 |
de73150cfb31d17d0c1a2dd717bd6613
|
|
| BLAKE2b-256 |
808edb4dd115c38bfe4575b34756e4d5d2d74fb26683e80c628bd34cad10e338
|
File details
Details for the file tieto_azure_apim_sdk-0.1.2-py3-none-any.whl.
File metadata
- Download URL: tieto_azure_apim_sdk-0.1.2-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6fa040f8caa047115a0791d6ab2c42d1d6ddd41a8edd603b0540b833cbd8ccd
|
|
| MD5 |
6bfbbf0092ef9c2bc135e18f3f17d59a
|
|
| BLAKE2b-256 |
fb9533c1beab941b8f3688d3edbbff5d43be552f34b78a49c0a1fdac34623ab1
|