azure-openai
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "azure-openai":https://skillpi.com/zh/skills/deepskill-5c16e3503d16b267cc50e56fde9c65f55856f95aa2816c40e9abe0b348a3eb0f。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
Azure OpenAI:在 Azure 基础设施上运行的 OpenAI 模型(如 GPT-4o、DALL·E 3、Whisper)。适用于需要在企业级合规性(GDPR、HIPAA、SOC2)下部署 OpenAI 模型、使用 Azure 原生身份验证(例如托管标识)、内容过滤或通过 VNET 隔离进行部署的场景。API 与 OpenAI 保持一致,托管于 Azure 平台。
介绍来源: third_party · TerminalSkills · 1.0.0 参考来源
SkillPi 解读
- 软件、账号及付费要求
- 贝什
- 实测状态
- 未测试
文件浏览
Frontmatter
name: azure-openai
description: >-
Azure OpenAI Service — OpenAI models (GPT-4o, DALL-E 3, Whisper) on Azure
infrastructure. Use when deploying OpenAI models with enterprise compliance
(GDPR, HIPAA, SOC2), Azure-native auth via Managed Identity, content filtering,
or VNET-isolated deployments. Same OpenAI API, hosted on Azure.
license: Apache-2.0
compatibility: "Python 3.9+ or Node.js 18+ with openai SDK >=1.0.0"
metadata:
author: terminal-skills
version: "1.0.0"
category: data-ai
tags: ["azure-openai", "azure", "gpt-4", "enterprise", "microsoft"]
use-cases:
- "Deploy GPT-4o on Azure with enterprise compliance and data residency"
- "Authenticate with Managed Identity — no API keys in code"
- "Apply Azure Content Filtering to moderate LLM inputs and outputs"
agents: [claude-code, openai-codex, gemini-cli, cursor]Azure OpenAI Service
Overview
Azure OpenAI Service provides OpenAI's models (GPT-4o, GPT-4o mini, DALL-E 3, Whisper) hosted on Microsoft Azure infrastructure. It offers enterprise features: Managed Identity authentication (no API keys), VNET integration, Azure Policy compliance, content filtering, abuse monitoring, and regional data residency. Uses the same openai Python/TS SDK — just point it at your Azure endpoint.
Azure vs OpenAI Direct
| Feature | OpenAI (direct) | Azure OpenAI |
|---|---|---|
| Auth | API Key | API Key or Managed Identity |
| Data residency | US primarily | Any Azure region |
| Enterprise compliance | Limited | SOC2, HIPAA, ISO 27001 |
| Content filtering | ❌ | ✅ Configurable |
| VNET isolation | ❌ | ✅ Private endpoints |
| Deployment control | Shared | Your own deployments |
| Fine-tuning | ✅ | ✅ |
| Latency to Azure services | Higher | Lower (co-located) |
Setup
pip install openai azure-identity # azure-identity for Managed Identity
# API Key auth (dev/test)
export AZURE_OPENAI_API_KEY=...
export AZURE_OPENAI_ENDPOINT=https://my-resource.openai.azure.com/
# Deployment names (you set these when deploying models in Azure Portal)
export AZURE_OPENAI_DEPLOYMENT=gpt-4o # Your deployment name
Instructions
Basic Chat with API Key
from openai import AzureOpenAI
client = AzureOpenAI(
api_key="your_azure_openai_api_key",
azure_endpoint="https://my-resource.openai.azure.com/",
api_version="2024-10-21", # Check docs for latest stable version
)
response = client.chat.completions.create(
model="gpt-4o", # This is your DEPLOYMENT NAME, not the model name
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is Azure OpenAI Service?"},
],
max_tokens=1024,
temperature=0.7,
)
print(response.choices[0].message.content)
Managed Identity Auth (No API Keys)
from openai import AzureOpenAI
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
# DefaultAzureCredential works with:
# - Managed Identity (in Azure VM, AKS, App Service, Functions)
# - Azure CLI (local development)
# - Visual Studio / VS Code credentials
credential = DefaultAzureCredential()
token_provider = get_bearer_token_provider(
credential,
"https://cognitiveservices.azure.com/.default"
)
client = AzureOpenAI(
azure_endpoint="https://my-resource.openai.azure.com/",
azure_ad_token_provider=token_provider,
api_version="2024-10-21",
)
response = client.chat.completions.create(
model="gpt-4o", # deployment name
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
TypeScript / Node.js
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.AZURE_OPENAI_API_KEY,
baseURL: `${process.env.AZURE_OPENAI_ENDPOINT}openai/deployments/${process.env.AZURE_OPENAI_DEPLOYMENT}`,
defaultQuery: { "api-version": "2024-10-21" },
defaultHeaders: { "api-key": process.env.AZURE_OPENAI_API_KEY },
});
const response = await client.chat.completions.create({
model: process.env.AZURE_OPENAI_DEPLOYMENT!,
messages: [{ role: "user", content: "Explain TypeScript generics." }],
});
console.log(response.choices[0].message.content);
Streaming
from openai import AzureOpenAI
client = AzureOpenAI(
api_key="...",
azure_endpoint="https://my-resource.openai.azure.com/",
api_version="2024-10-21",
)
stream = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Write a sonnet about cloud computing."}],
stream=True,
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
print()
Function Calling
import json
from openai import AzureOpenAI
client = AzureOpenAI(
api_key="...",
azure_endpoint="https://my-resource.openai.azure.com/",
api_version="2024-10-21",
)
tools = [
{
"type": "function",
"function": {
"name": "get_azure_resource_cost",
"description": "Get the cost of an Azure resource for the current month",
"parameters": {
"type": "object",
"properties": {
"resource_group": {"type": "string"},
"resource_name": {"type": "string"},
},
"required": ["resource_group", "resource_name"],
},
},
}
]
messages = [{"role": "user", "content": "How much is my vm-prod01 costing this month?"}]
response = client.chat.completions.create(
model="gpt-4o",
messages=messages,
tools=tools,
tool_choice="auto",
)
if response.choices[0].finish_reason == "tool_calls":
tool_call = response.choices[0].message.tool_calls[0]
args = json.loads(tool_call.function.arguments)
print(f"Called: {tool_call.function.name} with {args}")
messages.append(response.choices[0].message)
messages.append({
"role": "tool",
"tool_call_id": tool_call.id,
"content": json.dumps({"cost_usd": 142.53, "currency": "USD"}),
})
final = client.chat.completions.create(model="gpt-4o", messages=messages)
print(final.choices[0].message.content)
Image Generation with DALL-E 3
from openai import AzureOpenAI
client = AzureOpenAI(
api_key="...",
azure_endpoint="https://my-resource.openai.azure.com/",
api_version="2024-02-01", # DALL-E uses a different API version
)
response = client.images.generate(
model="dall-e-3", # your DALL-E 3 deployment name
prompt="A futuristic city skyline with solar panels, photorealistic, golden hour",
size="1024x1024",
quality="hd",
n=1,
)
print(response.data[0].url)
print(f"Revised prompt: {response.data[0].revised_prompt}")
Speech-to-Text with Whisper
from openai import AzureOpenAI
client = AzureOpenAI(
api_key="...",
azure_endpoint="https://my-resource.openai.azure.com/",
api_version="2024-06-01",
)
with open("recording.mp3", "rb") as audio_file:
transcript = client.audio.transcriptions.create(
model="whisper", # your Whisper deployment name
file=audio_file,
language="en",
response_format="text",
)
print(transcript)
Embeddings
from openai import AzureOpenAI
client = AzureOpenAI(
api_key="...",
azure_endpoint="https://my-resource.openai.azure.com/",
api_version="2024-10-21",
)
response = client.embeddings.create(
model="text-embedding-3-large", # deployment name
input=["The quick brown fox", "Jumps over the lazy dog"],
)
for item in response.data:
print(f"Embedding {item.index}: {len(item.embedding)} dims")
Deployment vs Model Name
A critical Azure OpenAI concept: deployments are your named instances of a model:
Azure Portal:
Resource: my-openai-resource
Deployments:
- Name: "gpt-4o" → Model: gpt-4o (2024-11-20)
- Name: "gpt-4o-mini" → Model: gpt-4o-mini (2024-07-18)
- Name: "text-embed-large" → Model: text-embedding-3-large
In code, model= takes the deployment name you configured, not the OpenAI model name.
Content Filtering Configuration
Content filters are configured in Azure Portal under your deployment settings:
- Hate, Violence, Sexual, Self-harm — each configurable (low/medium/high threshold)
- Prompt injection protection — detects jailbreak attempts
- Custom blocklists — add domain-specific blocked terms
# When content is filtered, the API returns an error:
from openai import AzureOpenAI, BadRequestError
client = AzureOpenAI(...)
try:
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "user_input"}],
)
except BadRequestError as e:
if e.code == "content_filter":
print(f"Content filtered: {e.error.innererror}")
Guidelines
- Use Managed Identity in production (AKS, App Service, Functions) — never store API keys in code.
- Each deployment is a separate Azure resource with its own quota and settings.
- Pin
api_versionto a stable version — latest is not always most stable. - Azure Content Filtering is always on by default — configure thresholds per deployment.
- For HIPAA compliance, ensure your Azure subscription has a Business Associate Agreement (BAA).
- VNET private endpoints prevent traffic from leaving your Azure network — required for strict isolation.
- Monitor usage and costs with Azure Monitor and set budget alerts on the Cognitive Services resource.
当前收录版本
1.0.0
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- Azure OpenAI 服务提供企业级 OpenAI 模型部署方案,满足 GDPR、HIPAA、SOC2 等合规要求
- 支持 Managed Identity 身份验证和内容过滤,适用于严格的企业安全场景
亮点
- 触发描述精准覆盖企业级部署、身份验证、内容过滤等核心使用场景
- 明确区分 Azure OpenAI 与直接 OpenAI 的差异,帮助用户准确选择
亮点
- 文档结构完整,包含概述、对比表格、设置指南、多场景示例和最佳实践
- 提供了 Python 和 TypeScript 的完整代码示例,覆盖聊天、流式、函数调用、图像生成等主要功能
亮点
- 提供了 API Key 和 Managed Identity 两种认证方式的完整实现
- 包含内容过滤异常处理示例和版本控制建议,确保生产环境可靠性
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
读取本地文件
限定到你选择的文件或项目目录;避免读取无关的个人资料、密钥和配置文件。
主文档提及 · 第 243 行 -
安装或获取外部依赖
使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。
主文档提及 · 第 44 行 -
账号、密钥或授权
使用专用、最小权限账号,不把密钥粘贴到公开内容或命令日志;核对接收数据的服务与租户。
主文档提及 · 第 32, 48, 58, 64, 86 行
文档引用的域名或地址
这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。
- cognitiveservices.azure.com
- my-resource.openai.azure.com
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
贝什
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。