能力标签
AI DIAL 适配器
🛠
AI工具

AI DIAL 适配器

基于 Python · 开源免费,本地部署,数据完全自主可控
英文名:ai-dial-adapter-openai
⭐ 17 Stars 🍴 8 Forks 💻 Python 📄 Apache-2.0 🏷 AI 8.0分
8.0AI 综合评分
AIDIALOpenAIPython
✦ AI Skill Hub 推荐

AI DIAL 适配器 是 AI Skill Hub 本期精选AI工具之一。综合评分 8.0 分,整体质量较高。我们强烈推荐将其纳入你的 AI 工具库,帮助提升工作效率。

📚 深度解析

AI DIAL 适配器 是一款基于 Python 的开源工具,在 GitHub 上收获 0k+ Star,是AI、DIAL、OpenAI、Python领域中的优质开源项目。开源工具的最大优势在于代码完全透明,你可以审计每一行代码的安全性,也可以根据自身需求进行二次开发和定制。

**为什么要使用开源工具而非商业 SaaS?**
对于个人开发者和有隐私需求的用户,本地部署的开源工具意味着数据不离本机,不受第三方服务商的数据政策约束。同时,开源工具通常没有使用次数限制和月度费用,一次安装即可长期使用,对于高频使用场景的总拥有成本(TCO)远低于订阅制商业工具。

**安装与环境准备**
AI DIAL 适配器 依赖 Python 运行环境。建议通过 pyenv(Python)或 nvm(Node.js)管理 Python 版本,避免全局环境污染。对于新手用户,推荐先创建虚拟环境(python -m venv venv && source venv/bin/activate),再安装依赖,这样即使出现问题也可以随时删除虚拟环境重新开始,不影响系统稳定性。

**社区与维护**
GitHub Issue 和 Discussion 是获取帮助的最快渠道。在提问前建议先检查 Closed Issues(已关闭的问题),大多数常见问题都已有解答。遇到 Bug 时,提供 pip list 的输出、完整错误堆栈和最小可复现示例,能显著提高开发者响应速度。AI Skill Hub 将持续追踪 AI DIAL 适配器 的版本更新,及时通知重要功能变化。

📋 工具概览

实现 Azure OpenAI 语言模型的 AI DIAL API

AI DIAL 适配器 是一款基于 Python 开发的开源工具,专注于 AI、DIAL、OpenAI 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。

GitHub Stars
⭐ 17
开发语言
Python
支持平台
Windows / macOS / Linux
维护状态
轻量级项目,按需更新
开源协议
Apache-2.0
AI 综合评分
8.0 分
工具类型
AI工具
Forks
8

📖 中文文档

以下内容由 AI Skill Hub 根据项目信息自动整理,如需查看完整原始文档请访问底部「原始来源」。

实现 Azure OpenAI 语言模型的 AI DIAL API

AI DIAL 适配器 是一款基于 Python 开发的开源工具,专注于 AI、DIAL、OpenAI 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。

📌 核心特色
  • 开源免费,支持本地部署,数据完全自主可控
  • 活跃的 GitHub 开源社区,持续迭代更新
  • 提供详细文档和使用示例,新手友好
  • 支持自定义配置,灵活适配不同使用环境
  • 可作为基础组件集成进现有技术栈或进行二次开发
🎯 主要使用场景
  • 本地部署运行,保护数据隐私,满足合规要求
  • 自定义集成到现有系统,扩展技术栈能力
  • 作为开源基础组件进行商业化二次开发
以下安装命令基于项目开发语言和类型自动生成,实际以官方 README 为准。
安装命令
# 方式一: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('安装成功')"
📋 安装步骤说明
  1. 访问 GitHub 仓库页面
  2. 按照 README 文档完成依赖安装
  3. 根据系统环境完成初始化配置
  4. 参考官方示例或文档开始使用
  5. 遇到问题可在 GitHub Issues 中查找解答
以下用法示例由 AI Skill Hub 整理,涵盖最常见的使用场景。
常用命令 / 代码示例
# 命令行使用
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"
📑 README 深度解析 真实文档 完整度 44/100 含工作流图 查看 GitHub 原文 →
以下内容由系统直接从 GitHub README 解析整理,保留代码块、表格与列表结构。

简介

DIAL OpenAI Adapter

About DIALX

Discord

---

Overview

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.

---

Chat Completions API deployments

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

the upstream Claude model name served by the Foundry deployment.

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"

Responses API deployments

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:

  1. WebSocket mode isn't supported.
  2. Passing context from the previous response is limited to DIAL deployments with number of upstreams equal one.
  3. References to DIAL files aren't supported.

Configuring the upstream model name

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 endpointSource 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.

---

Supported upstream chat APIs

Azure OpenAI Chat Completions API

<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.

  1. 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/completions
  2. UPSTREAM_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.
sequenceDiagram autonumber actor U as DIAL Client participant C as DIAL Core participant A as OpenAI Adapter participant AZ as Azure OpenAI participant OP as OpenAI Platform Note over U,C: DIAL_DEPLOYMENT_ID U->>C: POST /openai/deployments/
${DIAL_DEPLOYMENT_ID}/chat/completions Note over C,A: UPSTREAM_DEPLOYMENT_ID C->>A: POST ${ADAPTER_ORIGIN}/openai/deployments/
${UPSTREAM_DEPLOYMENT_ID}/chat/completions alt v1 Azure OpenAI upstream Note over A,AZ: UPSTREAM_DEPLOYMENT_ID A->>AZ: POST https://${AZURE_OPENAI_SERVICE_NAME}.openai.azure.com/openai/v1/chat/completions
(with "model"=${UPSTREAM_DEPLOYMENT_ID}) Note right of A: Auth: api-key (if provided) or Azure AD via DefaultAzureCredential AZ-->>A: JSON or SSE stream else OpenAI Platform upstream A->>OP: POST https://api.openai.com/v1/chat/completions
(with "model"=${UPSTREAM_DEPLOYMENT_ID}, api-key) OP-->>A: JSON or SSE stream end A-->>C: Normalized response (headers/stream) C-->>U: Response to client

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.

Azure OpenAI Chat Completions API (legacy)

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.

Azure OpenAI Responses 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>

Web Search Tool

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>

Azure AI Foundry Chat Completions API

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>

Azure OpenAI Images 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/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 in DALLE3_DEPLOYMENTS env variable, and GPT-Image 1 deployment - in GPT_IMAGE_1_DEPLOYMENTS.

Azure OpenAI Video API (Sora 1 API)

<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).

Azure OpenAI Sora 2 API

<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:

  1. text-to-video generation: the last user message is used as a text prompt sent to Sora 2

<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>

  1. image-to-video generation: if the last user message has an attachment, this attachment is sent to Sora 2 as a reference source along with the last user message as a text prompt.

<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).

Azure Audio API

The adapter supports models connected via Azure Audio API.

Text-to-speech models (TTS)

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:

  1. gpt-4o-mini-tts - prompt tokens are computed using gpt-4o tiktoken algorithm. Completion tokens are set to zero.
  2. 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.
Speech-to-text models (STT)

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:

  1. gpt-4o-* models return audio tokens in the usage.prompt_tokens field and text tokens - in usage.completion_tokens.
  2. whisper models return duration of the given audio file in seconds in usage.prompt_tokens and zero in usage.completion_tokens.

OpenAI Platform Chat Completions API

<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.

Amazon Bedrock OpenAI Chat Completions API

The adapter supports OpenAI models deployed through Amazon Bedrock. Two upstream endpoint formats are recognized:

  • Bedrock Mantle - https://bedrock-mantle.${AWS_REGION}.api.aws/openai/v1/chat/completions
  • Bedrock Runtime - https://bedrock-runtime.${AWS_REGION}.amazonaws.com/openai/v1/chat/completions

Both formats are authenticated the same way, but they expect different model ids:

Upstream endpointModel id
Bedrock Mantleopenai.gpt-5.4
Bedrock Runtimeus.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
Authentication

The adapter authenticates to Bedrock with the first of the following credentials that is configured:

  1. Bedrock bearer token - the key field of the upstream config.
  2. Static AWS credentials - aws_access_key_id and aws_secret_access_key, optionally accompanied by aws_session_token.
  3. AWS role - 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.
  4. AWS credential provider chain - when nothing above is configured, the credentials are resolved by the AWS SDK itself (instance profile, EKS service account, and other sources).

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 fieldEnv variable
aws_access_key_idAWS_ACCESS_KEY_ID
aws_secret_access_keyAWS_SECRET_ACCESS_KEY
aws_session_tokenAWS_SESSION_TOKEN
aws_assume_role_arnAWS_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_id and aws_secret_access_key are only accepted together. The adapter returns 500 when one of them is configured without the other, or when aws_session_token is configured without both.
Session tags

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:

FieldTypeDescription
rolesarray of stringsUser roles, addressable by list index, e.g. roles.0
projectstring or nullUser project
userClaimsobject or nullUser 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.

IntentAWS_SESSION_TAGS_FIELDS
DisabledUnset the variable
First roleroles.0
Projectproject
A claimuserClaims.email
Severalroles.0,project,userClaims.email

OpenAI Completions API

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>

Mistral Chat Completion API

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 Chat Completions API

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 upstream base_url differs 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 is dashscope-us.aliyuncs.com and doesn't include a workspace id. See the endpoint list for details.

vLLM Chat Completion API

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.

Qwen3-ASR

You can connect the Qwen3-ASR model served with vLLM to DIAL. This adapter provides first-class support for this integration scenario:

  • Audio attachments: Clients send audio files as DIAL attachments (mime types audio/*). The adapter converts them into the content parts expected by the vLLM Chat Completions API.
  • ASR language metadata extraction: The adapter reports the detected language in a dedicated DIAL stage titled Language: English (or whichever language was detected).
[!NOTE] QWEN3_ASR_VLLM_DEPLOYMENTS is separate from VLLM_DEPLOYMENTS. Deployments listed in QWEN3_ASR_VLLM_DEPLOYMENTS receive the ASR language extraction post-processing, while regular VLLM_DEPLOYMENTS receive reasoning extraction instead.

Anthropic Messages API

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>

Default max_tokens for Claude models

Unlike 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-...).

Automatic prompt caching

The adapter supports automatic prompt caching.

To enable it:

  • Configure a top-level cache breakpoint in the chat completion request via defaults.custom_fields.cache_breakpoint.
  • If the DIAL deployment uses multiple upstreams, set 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>

Explicit prompt caching

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>

Anthropic API Passthrough

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>

Using Claude Code with the adapter

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

Claude Code sends this as the X-Api-Key header. The adapter does not use it

directly. When routing through DIAL Core, set this to your DIAL API key.

ANTHROPIC_API_KEY="dummy-api-key"

The adapter is a pure proxy and does not know the upstream Anthropic endpoint

Foundry endpoint and key through Claude Code custom headers.

ANTHROPIC_CUSTOM_HEADERS="X-UPSTREAM-ENDPOINT: https://my-foundry.services.ai.azure.com/anthropic/v1/messages X-UPSTREAM-KEY: optional-azure-api-key"

Supported upstream Responses APIs

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.

Azure OpenAI Responses API

<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>

OpenAI Platform Responses API

<details><summary>DIAL Core Config</summary>

```json { "models": { "${DIAL_DEPLOYMENT_ID}": { "type": "chat", "overrideName": "${OPENAI_PLATFORM_MODEL_NAME}", "responsesEndpoint": "${ADAPTER_ORIGIN}/openai/v1/r

🎯 aiskill88 AI 点评 A 级 2026-06-10

高质量的 AI 工具集成项目

📚 实用指南(长尾问题)
适合谁
  • 构建企业知识库 / RAG 检索应用的团队
  • 跨境业务、多语言内容运营团队
  • 做语音类 AI 产品的开发者
最佳实践
  • 生产部署优先使用 Docker Compose 隔离依赖,并挂载 volume 持久化数据
常见错误
  • API key 直接提交到 git 仓库(请用 .env 并加入 .gitignore)
  • 容器内无法访问宿主机 localhost — 使用 host.docker.internal
  • Python 依赖冲突:建议用 venv / uv 隔离环境
部署方案
  • Docker:ai-dial-adapter-openai 提供官方镜像,docker compose up 一键启动
  • 云端托管:可放在 Vercel / Railway / Fly.io 等 PaaS 平台
相关搜索
ai-dial-adapter-openai 中文教程ai-dial-adapter-openai 安装报错怎么办ai-dial-adapter-openai Docker 部署ai-dial-adapter-openai 与同类工具对比ai-dial-adapter-openai 最佳实践ai-dial-adapter-openai 适合谁用

⚡ 核心功能

👥 适合谁
  • 构建企业知识库 / RAG 检索应用的团队
  • 跨境业务、多语言内容运营团队
  • 做语音类 AI 产品的开发者
⭐ 最佳实践
  • 生产部署优先使用 Docker Compose 隔离依赖,并挂载 volume 持久化数据
⚠️ 常见错误
  • API key 直接提交到 git 仓库(请用 .env 并加入 .gitignore)
  • 容器内无法访问宿主机 localhost — 使用 host.docker.internal
  • Python 依赖冲突:建议用 venv / uv 隔离环境

👥 适合人群

AI 技术爱好者研究人员和学生开发者和工程师技术创业者

🎯 使用场景

  • 本地部署运行,保护数据隐私,满足合规要求
  • 自定义集成到现有系统,扩展技术栈能力
  • 作为开源基础组件进行商业化二次开发

⚖️ 优点与不足

✅ 优点
  • +Apache-2.0 协议,可免费商用
  • +完全开源免费,无授权费用
  • +本地部署,数据完全自主可控
  • +开发者社区支持,遇问题可查可问
⚠️ 不足
  • 安装和初始配置可能需要一定技术基础
  • 功能完整性通常不如成熟商业产品
  • 技术支持主要依赖开源社区,响应速度不稳定
⚠️ 使用须知

AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。

建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。

📄 License 说明

✅ Apache 2.0 — 宽松开源协议,可商用,需保留版权声明和 NOTICE 文件,含专利授权条款。

🔗 相关工具推荐

📚 相关教程推荐
📰 相关 AI 新闻
🍿 AI 圈相关吃瓜
🗺️ 相关解决方案
🧩 你可能还需要
基于当前 Skill 的能力图谱,自动补全的工具组合

❓ 常见问题 FAQ

ai-dial-adapter-openai 是一款Python开发的AI辅助工具。开源AI工具:The project implements AI DIAL API for language models from Azure OpenAI。⭐17 · Python 主要应用场景包括:语言模型集成。
💡 AI Skill Hub 点评

经综合评估,AI DIAL 适配器 在AI工具赛道中表现稳健,质量优秀。如果你已有明确的使用需求,可以直接上手体验;如果还在评估阶段,建议对比同类工具后再做决策。

📚 深入学习 AI DIAL 适配器
查看分步骤安装教程和完整使用指南,快速上手这款工具
🌐 原始信息
原始名称 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
🔗 原始来源
🐙 GitHub 仓库  https://github.com/epam/ai-dial-adapter-openai 🌐 官方网站  https://dialx.ai

收录时间:2026-06-10 · 更新时间:2026-06-11 · License:Apache-2.0 · AI Skill Hub 不对第三方内容的准确性作法律背书。

📺 订阅 AI Skill Hub Daily Telegram 频道
每天 8 条精选 AI Skill、MCP、Agent 与自动化工具推送
加入频道 →