AI DIAL 适配器 是 AI Skill Hub 本期精选AI工具之一。综合评分 8.0 分,整体质量较高。我们强烈推荐将其纳入你的 AI 工具库,帮助提升工作效率。
实现 Azure OpenAI 语言模型的 AI DIAL API
AI DIAL 适配器 是一款基于 Python 开发的开源工具,专注于 AI、DIAL、OpenAI 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
实现 Azure OpenAI 语言模型的 AI DIAL API
AI DIAL 适配器 是一款基于 Python 开发的开源工具,专注于 AI、DIAL、OpenAI 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
# 方式一:pip 安装(推荐)
pip install ai-dial-adapter-openai
# 方式二:虚拟环境安装(推荐生产环境)
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install ai-dial-adapter-openai
# 方式三:从源码安装(获取最新功能)
git clone https://github.com/epam/ai-dial-adapter-openai
cd ai-dial-adapter-openai
pip install -e .
# 验证安装
python -c "import ai_dial_adapter_openai; print('安装成功')"
# 命令行使用
ai-dial-adapter-openai --help
# 基本用法
ai-dial-adapter-openai input_file -o output_file
# Python 代码中调用
import ai_dial_adapter_openai
# 示例
result = ai_dial_adapter_openai.process("input")
print(result)
# ai-dial-adapter-openai 配置文件示例(config.yml) app: name: "ai-dial-adapter-openai" debug: false log_level: "INFO" # 运行时指定配置文件 ai-dial-adapter-openai --config config.yml # 或通过环境变量配置 export AI_DIAL_ADAPTER_OPENAI_API_KEY="your-key" export AI_DIAL_ADAPTER_OPENAI_OUTPUT_DIR="./output"
max_tokens for Claude models---
LLM Adapters unify the APIs of respective LLMs to align with the Unified Protocol of DIAL Core. Each Adapter operates within a dedicated container. Multi-modality allows supporting non-textual communications such as image-to-text, text-to-image, file transfers and more.
The project implements AI DIAL API for language models from Azure OpenAI.
Claude models are served by the aidial-adapter-anthropic package. Its README documents the Claude-specific request/response API and is referenced throughout this document instead of being duplicated here.
---
The adapter is able to convert certain upstream APIs to the DIAL Chat Completions API (which is an extension of Azure OpenAI Chat Completions API).
Chat Completions deployments are exposed via the endpoint:
POST ${ADAPTER_ORIGIN}/openai/deployments/${UPSTREAM_DEPLOYMENT_ID}/chat/completions
ANTHROPIC_CUSTOM_MODEL_OPTION="claude-opus-4-5" ANTHROPIC_CUSTOM_MODEL_OPTION_NAME="Opus via DIAL adapter" ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION="Custom deployment routed through the DIAL OpenAI adapter"
Since: ai-dial-adapter-openai:0.38.0 AND ai-dial-core:0.42.0
The adapter is able to proxy requests to models supporting Responses API.
The following Responses API endpoints are exposed by the adapter:
POST ${ADAPTER_ORIGIN}/openai/v1/responses
GET ${ADAPTER_ORIGIN}/openai/v1/responses/{response_id}
DELETE ${ADAPTER_ORIGIN}/openai/v1/responses/{response_id}
POST ${ADAPTER_ORIGIN}/openai/v1/responses/{response_id}/cancel
POST ${ADAPTER_ORIGIN}/openai/v1/responses/input_tokens
Current limitations:
Every upstream call carries a model name. Where the adapter takes it from depends on which of its endpoints DIAL Core is configured to call:
| Adapter endpoint | Source of the upstream model name |
|---|---|
/openai/deployments/${UPSTREAM_DEPLOYMENT_ID}/... *(chat/completions, embeddings, tokenize, truncate_prompt, configuration)* | The ${UPSTREAM_DEPLOYMENT_ID} path segment; the model field of the request body is ignored |
/openai/v1/responses (responsesEndpoint) and the [Anthropic passthrough](#anthropic-api-passthrough) *(no deployment id in the URL)* | The model field of the request body, which DIAL Core fills with the DIAL model id |
The overrideName field of a DIAL Core model configuration overrides the upstream model name in both cases:
{
"models": {
"dial-model-id": {
"overrideName": "upstream-model-name",
"endpoint": "${ADAPTER_ORIGIN}/openai/deployments/a-deployment-id/chat/completions",
"responsesEndpoint": "${ADAPTER_ORIGIN}/openai/v1/responses"
}
}
}
For endpoints with a deployment id, overrideName is just an alternative to writing the name into the URL. As far as endpoint is concerned, the config above is equivalent to this one, which has no override:
{
"models": {
"dial-model-id": {
"endpoint": "${ADAPTER_ORIGIN}/openai/deployments/upstream-model-name/chat/completions"
}
}
}
For endpoints without a deployment id, it's the only way to keep the DIAL model id decoupled from the upstream one; without it, dial-model-id is sent upstream verbatim.
We recommend always specifying overrideName to make the configuration explicit and maintainable.
---
<details><summary>DIAL Core Config</summary>
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"endpoint": "${ADAPTER_ORIGIN}/openai/deployments/${UPSTREAM_DEPLOYMENT_ID}/chat/completions",
"upstreams": [
{
"endpoint": "https://${AZURE_OPENAI_SERVICE_NAME}.openai.azure.com/openai/v1/chat/completions",
"key": "${OPTIONAL_API_KEY}"
}
]
}
}
}
</details>
There are two free variables in the config related to deployment ids.
DIAL_DEPLOYMENT_ID is the deployment id visible to the DIAL Client via DIAL deployment listing. The client will be using the id to call the model by sending the request POST ${DIAL_CORE_ORIGIN}/openai/deployments/${DIAL_DEPLOYMENT_ID}/chat/completionsUPSTREAM_DEPLOYMENT_ID - the deployment id the OpenAI adapter receives when DIAL Core calls POST ${ADAPTER_ORIGIN}/openai/deployments/${UPSTREAM_DEPLOYMENT_ID}/chat/completions. This must correspond to the Azure deployment id in the given Azure OpenAI service. Use this identifier in environment variables that define deployment categories.Typically these two variables share the same value (the Azure OpenAI deployment name). They may differ if you expose multiple DIAL deployments that call the same Azure OpenAI endpoint but configured differently.
The DefaultAzureCredential is used to authenticate requests to Azure when an API key is not provided in the upstream configuration.
The legacy last generation API includes explicit deployment id in the URL, e.g.:
POST https://${AZURE_OPENAI_SERVICE_NAME}.openai.azure.com/openai/deployments/gpt-4o/chat/completions
The DIAL upstream configuration changes accordingly:
<details><summary>DIAL Core Config</summary>
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"endpoint": "${ADAPTER_ORIGIN}/openai/deployments/${AZURE_OPENAI_DEPLOYMENT_ID}/chat/completions",
"upstreams": [
{
"endpoint": "https://${AZURE_OPENAI_SERVICE_NAME}.openai.azure.com/openai/deployments/${AZURE_OPENAI_DEPLOYMENT_ID}/chat/completions",
"key": "${OPTIONAL_API_KEY}"
}
]
}
}
}
</details>
We recommend always setting the same upstream deployment id in the endpoint and all upstream[*].endpoint URLs, since upstream[*].endpoint is the actual endpoint that will be called at the end of the day.
[!WARNING] Because of the risk of such a misconfiguration, we recommend avoiding this configuration and instead opt for the v1 API.
Certain advanced features of OpenAI models, such as reasoning summary, are only accessible via Responses API and not accessible via Chat Completions API.
<details><summary>DIAL Core Config</summary>
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"endpoint": "${ADAPTER_ORIGIN}/openai/deployments/${AZURE_OPENAI_DEPLOYMENT_ID}/chat/completions",
"upstreams": [
{
"endpoint": "https://${AZURE_OPENAI_SERVICE_NAME}.openai.azure.com/openai/v1/responses",
"key": "${API_KEY}"
}
]
}
}
}
</details>
The deployments backed by Azure OpenAI Responses API support the Web Search tool, which could be enabled by passing a static function called web_search as one of the tools:
<details> <summary>Example request</summary>
{
"model": "upstream-model-name",
"messages": [
{
"role": "user",
"content": "What is the weather in Kyiv now? Include source links."
}
],
"tools": [
{
"type": "static_function",
"static_function": {
"name": "web_search",
"configuration": {
"search_context_size": "high"
}
}
}
],
"stream": true
}
</details>
Each Web Search tool calls are translated into a DIAL stages, and URL citations are mirrored as DIAL attachments:
<details> <summary>Example response:</summary>
{
"choices": [
{
"message": {
"content": "Kyiv weather is mild.",
"custom_content": {
"stages": [
{
"name": "Web Search",
"status": "completed",
"content": "Search 'weather Kyiv'"
}
],
"attachments": [
{
"type": "text/markdown",
"title": "Kyiv weather source",
"url": "https://example.com/weather/kyiv"
}
]
}
}
}
]
}
</details>
Certain LLM models like gpt-oss-120b or Mistral-Large-2411 can only be deployed to an Azure AI Foundry service. They are accessible via Azure OpenAI endpoint or legacy Azure AI model inference endpoint.
<details><summary>DIAL Core Config (Azure OpenAI endpoint)</summary>
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"endpoint": "${ADAPTER_ORIGIN}/openai/deployments/${AZURE_AI_FOUNDRY_DEPLOYMENT_ID}/chat/completions",
"upstreams": [
{
"endpoint": "https://${AZURE_AI_FOUNDRY_SERVICE_NAME}.openai.azure.com/openai/v1/chat/completions",
"key": "${OPTIONAL_API_KEY}"
}
]
}
}
}
</details>
<details><summary>DIAL Core Config (retired Azure AI model inference endpoint)</summary>
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"endpoint": "${ADAPTER_ORIGIN}/openai/deployments/${AZURE_AI_FOUNDRY_DEPLOYMENT_ID}/chat/completions",
"upstreams": [
{
"endpoint": "https://${AZURE_AI_FOUNDRY_SERVICE_NAME}.services.ai.azure.com/models/chat/completions",
"key": "${OPTIONAL_API_KEY}"
}
]
}
}
}
</details>
<details><summary>DIAL Core Config</summary>
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"endpoint": "${ADAPTER_ORIGIN}/openai/deployments/${AZURE_OPENAI_DEPLOYMENT_ID}/chat/completions",
"upstreams": [
{
"endpoint": "https://${AZURE_OPENAI_SERVICE_NAME}.openai.azure.com/openai/deployments/${AZURE_OPENAI_DEPLOYMENT_ID}/images/generations",
"key": "${OPTIONAL_API_KEY}"
}
]
}
}
}
</details>
The supported upstream models are dall-e-3 and gpt-image-1. These are the values that AZURE_OPENAI_DEPLOYMENT_ID variable can take.
[!IMPORTANT] The DALL·E 3 adapter deployment must be declared inDALLE3_DEPLOYMENTSenv variable, and GPT-Image 1 deployment - inGPT_IMAGE_1_DEPLOYMENTS.
<details><summary>DIAL Core Config</summary>
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"endpoint": "${ADAPTER_ORIGIN}/openai/deployments/sora/chat/completions",
"upstreams": [
{
"endpoint": "https://${AZURE_OPENAI_SERVICE_NAME}.openai.azure.com/openai/v1/video/generations",
"key": "${OPTIONAL_API_KEY}"
}
]
}
}
}
</details>
The video generation models support configuration via the custom_fields.configuration field in the chat completion request:
{
"model": "sora",
"messages": [
{
"role": "user",
"content": "A cat playing with a ball of yarn"
}
],
"custom_fields": {
"configuration": {
"width": 480,
"height": 480,
"n_seconds": 5,
"n_variants": 1
}
}
}
Width and height are defaulted to 480x480 if not specified.
Find the details in the Azure API specification.
[!NOTE] n_variants>1 results in multiple video attachments to a single chat completion choice.
[!IMPORTANT] Prompt tokens in the usage are set to zero. Completion tokens are set to the overall number of seconds in the generated video(s).
<details><summary>DIAL Core Config</summary>
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"endpoint": "${ADAPTER_ORIGIN}/openai/deployments/sora-2/chat/completions",
"upstreams": [
{
"endpoint": "https://${AZURE_OPENAI_SERVICE_NAME}.openai.azure.com/openai/v1/videos",
"key": "${OPTIONAL_API_KEY}"
}
]
}
}
}
</details>
The Sora 2 deployment works in either of following modes:
<details> <summary>Chat completion request</summary>
{
"model": "sora-2",
"messages": [
{
"role": "system",
"content": "A system message that will be ignored"
},
{
"role": "user",
"content": "A cat playing with a ball of yarn"
}
]
}
</details>
<details> <summary>Chat completion request</summary>
{
"model": "sora-2",
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "Animate the image"},
{"type": "image_url", "image_url": {"url": "http://example.com/image.jpg"}}
]
}
]
}
</details>
Video remixing (video-to-video generation) isn't supported.
The Sora 2 deployment supports configuration via the custom_fields.configuration field in the chat completion request:
{
"model": "sora-2",
"messages": [
{
"role": "user",
"content": "A cat playing with a ball of yarn"
}
],
"custom_fields": {
"configuration": {
"seconds": 4,
"size": "720x1280",
"auto_crop_reference_images": true
}
}
}
The size is defaulted to 720x1280 if not specified. The duration is defaulted to 4 seconds if not specified.
The auto cropping flag enables cropping of the input reference image to the output video size. It can be useful, since Sora 2 rejects any requests where the resolution of the source image and final video do not match. The flag defaults to False.
Find the details in the Azure Sora 2 API specification.
[!IMPORTANT] Prompt tokens in the usage are set to zero. Completion tokens are set to the overall number of seconds in the generated video(s).
The adapter supports models connected via Azure Audio API.
Set AZURE_DEPLOYMENT_ID variable to one of the text-to-speech models supported by Azure Audio API:
<details><summary>DIAL Core Config</summary>
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"endpoint": "${ADAPTER_ORIGIN}/openai/deployments/${AZURE_DEPLOYMENT_ID}/chat/completions",
"upstreams": [
{
"endpoint": "https://${AZURE_SERVICE_NAME}.(openai|cognitiveservices).azure.com/openai/v1/audio/speech",
"key": "${OPTIONAL_API_KEY}"
}
]
}
}
}
</details>
At the moment of writing, these are: tts, tts-hd, and gpt-4o-mini-tts.
The adapter takes the last user message as a text prompt and sends it to the upstream as input parameter. The input text is limited to 4096 characters. The text is being translated into speech audio by the upstream model. The audio file is returned as an attachment in the chat completion response.
System instructions are used to set the tone of the synthesized speech.
The adapter supports the following configuration for the TTS models:
{
"instruction": "Speak in a cheerful tone.", # optional, sets the tone; appended the system message from the chat completion request
"voice": "allow", # one of the preset voices
"speed": 1.0, # speech speed multiplier
"response_format": "mp3" # one of the supported audio formats
}
Find the configuration details in the Azure specification or in the OpenAI Platform specification.
The usage is computed in the following way:
gpt-4o-mini-tts - prompt tokens are computed using gpt-4o tiktoken algorithm. Completion tokens are set to zero.tts and tts-hd - there is no official documentation on the pricing for these models. Tokenizer for gpt-4o model will be used as a default for prompt tokens calculation. Completion tokens are set to zero.Set AZURE_DEPLOYMENT_ID variable to one of the speech-to-text models supported by Azure Audio API:
<details><summary>DIAL Core Config</summary>
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"endpoint": "${ADAPTER_ORIGIN}/openai/deployments/${AZURE_DEPLOYMENT_ID}/chat/completions",
"upstreams": [
{
"endpoint": "https://${AZURE_SERVICE_NAME}.(openai|cognitiveservices).azure.com/openai/v1/audio/transcriptions",
"key": "${OPTIONAL_API_KEY}"
}
]
}
}
}
</details>
At the moment of writing, these are: whisper, gpt-4o-transcribe, gpt-4o-mini-transcribe, and gpt-4o-transcribe-diarize.
The adapter takes an audio attachment from the last user message and pass it to the transcription model. The transcription is return as a text in the chat completion response.
System instructions are used to set the prompt parameter in the Transcription API request.
The usage is computed in the following way:
gpt-4o-* models return audio tokens in the usage.prompt_tokens field and text tokens - in usage.completion_tokens.whisper models return duration of the given audio file in seconds in usage.prompt_tokens and zero in usage.completion_tokens.<details><summary>DIAL Core Config</summary>
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"endpoint": "${ADAPTER_ORIGIN}/openai/deployments/${OPENAI_MODEL_NAME}/chat/completions",
"upstreams": [
{
"endpoint": "https://api.openai.com/v1/chat/completions",
"key": "${API_KEY}"
}
]
}
}
}
</details>
Note that the API key is required compared to the Azure OpenAI configuration.
The adapter supports OpenAI models deployed through Amazon Bedrock. Two upstream endpoint formats are recognized:
https://bedrock-mantle.${AWS_REGION}.api.aws/openai/v1/chat/completionshttps://bedrock-runtime.${AWS_REGION}.amazonaws.com/openai/v1/chat/completionsBoth formats are authenticated the same way, but they expect different model ids:
| Upstream endpoint | Model id |
|---|---|
| Bedrock Mantle | openai.gpt-5.4 |
| Bedrock Runtime | us.openai.gpt-5.4 *(the model id prefixed with the region)* |
Model availability differs between the two formats - check the AWS OpenAI model cards before choosing one.
<details><summary>DIAL Core Config</summary>
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"endpoint": "${ADAPTER_ORIGIN}/openai/deployments/openai.gpt-5.4/chat/completions",
"upstreams": [
{
"endpoint": "https://bedrock-mantle.${AWS_REGION}.api.aws/openai/v1/chat/completions",
"key": "${OPTIONAL_BEDROCK_BEARER_TOKEN}"
}
]
}
}
}
</details>
As in other v1-style upstreams, the adapter deployment id in the endpoint URL is the Bedrock model id.
[!NOTE] Bedrock support and feature parity can differ from direct OpenAI API support. Validate your model, region, and required capabilities before rollout: - OpenAI models in Amazon Bedrock - AWS OpenAI model cards - AWS Bedrock API keys
The adapter authenticates to Bedrock with the first of the following credentials that is configured:
key field of the upstream config.aws_access_key_id and aws_secret_access_key, optionally accompanied by aws_session_token.aws_assume_role_arn. The adapter exchanges its own credentials for the temporary credentials of the given role and reuses them until they are about to expire.The credentials of options 2-4 are configured either globally via AWS_* environment variables, or on a per upstream basis via the upstream extra_data field of the DIAL Core config. The fields in the extra data override the corresponding environment variables:
extra_data field | Env variable |
|---|---|
aws_access_key_id | AWS_ACCESS_KEY_ID |
aws_secret_access_key | AWS_SECRET_ACCESS_KEY |
aws_session_token | AWS_SESSION_TOKEN |
aws_assume_role_arn | AWS_ASSUME_ROLE_ARN |
Since every upstream carries its own credentials, a single deployment can be balanced across several AWS accounts. The region isn't a part of the credentials - it's taken from the upstream endpoint:
<details><summary>DIAL Core Config (credentials per upstream)</summary>
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"endpoint": "${ADAPTER_ORIGIN}/openai/deployments/openai.gpt-5.4/chat/completions",
"upstreams": [
{
"endpoint": "https://bedrock-mantle.us-east-1.api.aws/openai/v1/chat/completions",
"extra_data": {
"aws_access_key_id": "${AWS_ACCESS_KEY_ID}",
"aws_secret_access_key": "${AWS_SECRET_ACCESS_KEY}",
"aws_session_token": "${OPTIONAL_AWS_SESSION_TOKEN}"
}
},
{
"endpoint": "https://bedrock-mantle.eu-west-1.api.aws/openai/v1/chat/completions",
"extra_data": {
"aws_assume_role_arn": "arn:aws:iam::123456789012:role/BedrockAccessRoleName"
}
},
{
"endpoint": "https://bedrock-mantle.us-west-2.api.aws/openai/v1/chat/completions",
"key": "${BEDROCK_BEARER_TOKEN}"
}
]
}
}
}
</details>
[!IMPORTANT]aws_access_key_idandaws_secret_access_keyare only accepted together. The adapter returns500when one of them is configured without the other, or whenaws_session_tokenis configured without both.
AWS_SESSION_TAGS_FIELDS configures optional AWS STS session tags for the Bedrock credentials obtained through AssumeRole. The adapter resolves the configured paths against the JSON response to the DIAL GET /v1/user/info request, converts each resolved value to a JSON string, and passes the resulting tags to the STS AssumeRole call.
The tags are only applied to the assume role credentials (option 3 above). They are ignored for the bearer token, the static credentials and the AWS credential provider chain.
The variable is a comma-separated list of dot-separated paths into that JSON response. The user info response has the following fields:
| Field | Type | Description |
|---|---|---|
roles | array of strings | User roles, addressable by list index, e.g. roles.0 |
project | string or null | User project |
userClaims | object or null | User claims, addressable by nested paths, e.g. userClaims.email |
Paths use object keys and integer list indices, for example userClaims.access.0. Empty path entries are ignored, and unresolvable paths are skipped with a warning.
Tag keys are the configured paths. String values are used as-is. All other values are JSON-serialized, e.g. numbers, booleans, null, objects and arrays.
AWS sets several constraints for session tags. See the AWS docs on passing session tags in AWS STS for details. The adapter truncates the keys and the values that exceed the limits and drops the entries beyond the maximum count, reporting each adjustment in the logs.
| Intent | AWS_SESSION_TAGS_FIELDS |
|---|---|
| Disabled | Unset the variable |
| First role | roles.0 |
| Project | project |
| A claim | userClaims.email |
| Several | roles.0,project,userClaims.email |
The adapter also supports legacy Completions API both for Azure-style upstream endpoints and OpenAI Platform-style endpoints:
<details><summary>DIAL Core Config</summary>
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"endpoint": "${ADAPTER_ORIGIN}/openai/deployments/${OPENAI_MODEL_NAME}/chat/completions",
"upstreams": [
{
"endpoint": "https://api.openai.com/v1/completions",
"key": "${API_KEY}"
}
]
}
}
}
</details>
The Mistral Platform provides Chat Completions API, therefore, it could be connected to via the adapter:
<details><summary>DIAL Core Config</summary>
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"endpoint": "${ADAPTER_ORIGIN}/openai/deployments/${MISTRAL_MODEL_NAME}/chat/completions",
"upstreams": [
{
"endpoint": "https://api.mistral.ai/v1/chat/completions",
"key": "${MISTRAL_API_KEY}"
}
]
}
}
}
</details>
Where MISTRAL_MODEL_NAME is one of the available models on the Platform.
The deployment should be added to the environment variable MISTRAL_DEPLOYMENTS.
The adapter supports reasoning for Magistral models. The reasoning tokens are displayed in a dedicated stage titled Reasoning.
Alibaba Cloud Model Studio provides access to the Qwen series and mainstream third-party models (such as DeepSeek, Kimi, and GLM) through an OpenAI-compatible Chat Completions API, therefore, it could be connected to via the adapter:
<details><summary>DIAL Core Config</summary>
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"endpoint": "${ADAPTER_ORIGIN}/openai/deployments/${MODEL_STUDIO_MODEL_NAME}/chat/completions",
"upstreams": [
{
"endpoint": "https://${MODEL_STUDIO_WORKSPACE_ID}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions",
"key": "${DASHSCOPE_API_KEY}",
"extra_data": {
"vendor": "alibaba-cloud"
}
}
]
}
}
}
</details>
Where MODEL_STUDIO_MODEL_NAME is one of the available models on the platform (for example qwen3.7-max, qwen-plus, or qwen-flash).
The extra_data.vendor field is required to enable the cache breakpoints - without it the adapter treats the upstream as a vanilla OpenAI one and passes the breakpoints through untouched.
The upstream URL doesn't include the model name, so it is passed via overrideName. If this field is missing, the model name takes the value of the model field from the original chat completion request (if present), otherwise ${ADAPTER_DEPLOYMENT_ID}.
[!NOTE] The upstreambase_urldiffers by region (Singapore, US (Virginia), China (Beijing), China (Hong Kong), Japan (Tokyo), and Germany (Frankfurt)). Replace${MODEL_STUDIO_WORKSPACE_ID}with your workspace id and adjust the host to match your region. For the US (Virginia) region the host isdashscope-us.aliyuncs.comand doesn't include a workspace id. See the endpoint list for details.
vLLM provides an OpenAI-compatible Chat Completions API and can be connected to the adapter.
<details><summary>DIAL Core Config</summary>
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"endpoint": "${ADAPTER_ORIGIN}/openai/deployments/${VLLM_MODEL_NAME}/chat/completions",
"upstreams": [
{
"endpoint": "${VLLM_ORIGIN}/v1/chat/completions"
}
]
}
}
}
</details>
Enable the vLLM-specific flow by adding ${UPSTREAM_DEPLOYMENT_ID} to the environment variable VLLM_DEPLOYMENTS.
You can connect the Qwen3-ASR model served with vLLM to DIAL. This adapter provides first-class support for this integration scenario:
audio/*). The adapter converts them into the content parts expected by the vLLM Chat Completions API.Language: English (or whichever language was detected).[!NOTE]QWEN3_ASR_VLLM_DEPLOYMENTSis separate fromVLLM_DEPLOYMENTS. Deployments listed inQWEN3_ASR_VLLM_DEPLOYMENTSreceive the ASR language extraction post-processing, while regularVLLM_DEPLOYMENTSreceive reasoning extraction instead.
The adapter supports models exposing the Anthropic Messages API — Claude models deployed in Azure AI Foundry as well as third-party providers of the same API, e.g. Anthropic, Fireworks or OpenRouter.
<details><summary>DIAL Core Config for Azure AI Foundry</summary>
When the API key missing, the adapter falls back to Azure Entra ID authentication.
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"endpoint": "${ADAPTER_ORIGIN}/openai/deployments/${ANTHROPIC_MODEL_NAME}/chat/completions",
"upstreams": [
{
"endpoint": "https://${AZURE_AI_FOUNDRY_SERVICE_NAME}.services.ai.azure.com/anthropic/v1/messages",
"key": "${OPTIONAL_API_KEY}"
}
]
}
}
}
</details>
<details><summary>DIAL Core Config for Anthropic Platform or a third-party Messages API provider</summary>
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"endpoint": "${ADAPTER_ORIGIN}/openai/deployments/${ANTHROPIC_MODEL_NAME}/chat/completions",
"upstreams": [
{
"endpoint": "https://api.anthropic.com/v1/messages",
"key": "${API_KEY}"
}
]
}
}
}
</details>
max_tokens for Claude modelsUnlike OpenAI GPT models, Claude models require the max_tokens parameter in the chat completion request.
We recommend configuring max_tokens default value on a per-model basis in the DIAL Core Config, for example:
{
"models": {
"dial-claude-deployment-id": {
"type": "chat",
"description": "...",
"endpoint": "...",
"defaults": {
"max_tokens": 2048
}
}
}
}
If the default is missing in the DIAL Core Config, it will be taken from the CLAUDE_DEFAULT_MAX_TOKENS environment variable. However, we strongly recommend not to rely on this variable and instead configure the defaults in the DIAL Core Config. Such a per-model configuration is operationally cleaner since all the information relevant to tokens (like pricing and token limits) is kept in the same place.
The default value set in the DIAL Core Config takes precedence over the one configured in the adapter.
Make sure the default doesn't exceed Claude's max output tokens, otherwise, you will receive an error like this one: max_tokens: 10000 > 8192, which is the maximum allowed number of output tokens for claude-...).
The adapter supports automatic prompt caching.
To enable it:
defaults.custom_fields.cache_breakpoint.autoCachingSupported: true in the DIAL Core configuration.<details><summary>DIAL Core Config</summary>
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"defaults": {
"custom_fields": {
"cache_breakpoint": {}
}
},
"endpoint": "${ADAPTER_ORIGIN}/openai/deployments/${ANTHROPIC_MODEL_NAME}/chat/completions",
"upstreams": [
{
"endpoint": "https://${AZURE_AI_FOUNDRY_SERVICE_NAME1}.services.ai.azure.com/anthropic/v1/messages",
"key": "${OPTIONAL_API_KEY1}"
},
{
"endpoint": "https://${AZURE_AI_FOUNDRY_SERVICE_NAME2}.services.ai.azure.com/anthropic/v1/messages",
"key": "${OPTIONAL_API_KEY2}"
}
],
"features": {
"autoCachingSupported": true
}
}
}
}
</details>
The adapter support explicit cache breakpoints in system and user message as well as in the tool definitions. Find the examples of requests in the Anthropic adapter documentation.
Set the feature flag cacheSupported: true in the DIAL Core configuration, when the DIAL deployment has multiple upstreams. This flag enables logic in DIAL Core that routes chat completions requests with the same prefixes to the same upstreams:
<details><summary>DIAL Core Config</summary>
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"endpoint": "${ADAPTER_ORIGIN}/openai/deployments/${ANTHROPIC_MODEL_NAME}/chat/completions",
"upstreams": [
{
"endpoint": "https://${AZURE_AI_FOUNDRY_SERVICE_NAME1}.services.ai.azure.com/anthropic/v1/messages",
"key": "${OPTIONAL_API_KEY1}"
},
{
"endpoint": "https://${AZURE_AI_FOUNDRY_SERVICE_NAME2}.services.ai.azure.com/anthropic/v1/messages",
"key": "${OPTIONAL_API_KEY2}"
}
],
"features": {
"cacheSupported": true
}
}
}
}
</details>
In addition to the DIAL chat completions protocol, the adapter exposes the native Anthropic Messages API as a transparent passthrough mounted at /anthropic. The proxied endpoints, the error schema and the client compatibility are documented in the Anthropic adapter README.
A DIAL deployment becomes callable via the Messages API once the anthropicMessages interface is declared for it in the DIAL Core config. The upstream endpoint is resolved by the same rules as for chat completions: Azure AI Foundry or any other provider of the Messages API.
<details><summary>DIAL Core Config for Azure AI Foundry</summary>
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"overrideName": "${ANTHROPIC_MODEL_NAME}",
"interfaces": {
"anthropicMessages": {
"base_url": "${ADAPTER_ORIGIN}"
}
},
"upstreams": [
{
"endpoint": "https://${AZURE_AI_FOUNDRY_SERVICE_NAME}.services.ai.azure.com/anthropic/v1/messages",
"key": "${OPTIONAL_API_KEY}"
}
]
}
}
}
</details>
<details><summary>DIAL Core Config for Anthropic Platform or a third-party Messages API provider</summary>
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"overrideName": "${ANTHROPIC_MODEL_NAME}",
"interfaces": {
"anthropicMessages": {
"base_url": "${ADAPTER_ORIGIN}"
}
},
"upstreams": [
{
"endpoint": "https://api.anthropic.com/v1/messages",
"key": "${API_KEY}"
}
]
}
}
}
</details>
Because the passthrough exposes the native /v1/messages endpoint, Claude Code can talk to Claude models served through the adapter by pointing it at the /anthropic base path.
Copy .env.claude.example to .env.claude and adjust it for your setup:
```ini
ANTHROPIC_API_KEY="dummy-api-key"
ANTHROPIC_CUSTOM_HEADERS="X-UPSTREAM-ENDPOINT: https://my-foundry.services.ai.azure.com/anthropic/v1/messages X-UPSTREAM-KEY: optional-azure-api-key"
Note that in the following DIAL Core config examples, responsesEndpoint URL enables Responses API in DIAL. Whereas, endpoint URL is required and enables Chat Completions API in DIAL.
<details><summary>DIAL Core Config</summary>
{
"models": {
"${DIAL_DEPLOYMENT_ID}": {
"type": "chat",
"overrideName": "${AZURE_OPENAI_DEPLOYMENT_ID}",
"responsesEndpoint": "${ADAPTER_ORIGIN}/openai/v1/responses",
"upstreams": [
{
"responsesEndpoint": "https://${AZURE_OPENAI_SERVICE_NAME1}.openai.azure.com/openai/v1/responses",
"key": "${OPTIONAL_API_KEY1}"
},
{
"responsesEndpoint": "https://${AZURE_OPENAI_SERVICE_NAME2}.openai.azure.com/openai/v1/responses",
"key": "${OPTIONAL_API_KEY2}"
},
{
"responsesEndpoint": "https://${AZURE_OPENAI_SERVICE_NAME3}.openai.azure.com/openai/v1/responses",
"key": "${OPTIONAL_API_KEY3}"
}
]
}
}
}
</details>
<details><summary>DIAL Core Config</summary>
```json { "models": { "${DIAL_DEPLOYMENT_ID}": { "type": "chat", "overrideName": "${OPENAI_PLATFORM_MODEL_NAME}", "responsesEndpoint": "${ADAPTER_ORIGIN}/openai/v1/r
高质量的 AI 工具集成项目
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ Apache 2.0 — 宽松开源协议,可商用,需保留版权声明和 NOTICE 文件,含专利授权条款。
经综合评估,AI DIAL 适配器 在AI工具赛道中表现稳健,质量优秀。如果你已有明确的使用需求,可以直接上手体验;如果还在评估阶段,建议对比同类工具后再做决策。
| 原始名称 | ai-dial-adapter-openai |
| 原始描述 | 开源AI工具:The project implements AI DIAL API for language models from Azure OpenAI。⭐17 · Python |
| Topics | AIDIALOpenAIPython |
| GitHub | https://github.com/epam/ai-dial-adapter-openai |
| License | Apache-2.0 |
| 语言 | Python |
收录时间:2026-06-10 · 更新时间:2026-06-11 · License:Apache-2.0 · AI Skill Hub 不对第三方内容的准确性作法律背书。