新闻资讯

News and information

Azure AI Foundry 正式上线 GPT-5 Codex,手把手教你部署使用

发布日期 / 9/30/2025 11:56:00 AM / 204

9月24日,微软宣布在 Azure AI Foundry(国际版)中正式推出 GPT-5 Codex,并同步在 Visual Studio Code 的 GitHub Copilot 副驾驶® 中开启公共预览。本文将引导你完成从环境准备到模型部署与使用的完整流程。

01

先决条件

在开始之前,请确保你已具备以下条件:

  • 一个有效的 Azure 订阅账号;
  • 对 Azure AI Foundry 拥有 Contributor(参与者)权限;
  • 已安装 homebrew 或者 npm,用于安装 Codex CLI 或 VS Code 扩展。

02

在 Azure AI Foundry 中部署模型

1、创建新项目
访问 Azure AI Foundry 并创建一个新项目。
1.png

2、选择模型

从模型目录中选择支持 Responses API 的模型,例如 GPT-5 Codex


2.png
3.png

3、获取 Endpoint 与 API Key

记录生成的 Endpoint 和 API Key,格式如下:

  • Endpoint: 

    https://xxxx.openai.azure.com

  • API Key: 

    xxxxxxxxxxxxxxxxxxxxxxxxx


4.png

03

安装与配置 Codex CLI

1、安装方式(任选其一):
  • 通过npm:
bash
复制
npm install -g @openai/codex
codex --version  # 验证安装
  • 通过Homebrew:
bash
复制
brew install codex
codex --version  # 验证安装
2、配置 config.toml 文件

  a. 创建或编辑 ~/.codex/config.toml


bash
复制
cd ~/.codex
nano config.toml

  

  b. 写入以下配置(替换YOUR_RESOURCE_NAME 和实际模型部署名称):


toml
复制
model = "gpt-5-codex"
model_provider = "azure"
model_reasoning_effort = "high"
 
[model_providers.azure]
name = "Azure OpenAI"
base_url = "https://YOUR_RESOURCE_NAME.openai.azure.com/openai/v1"
env_key = "AZURE_OPENAI_API_KEY"
wire_api = "responses"

 

  c. 设置环境变量:


bash
复制
export AZURE_OPENAI_API_KEY="<your-api-key>"


d. 运行测试命令验证配置是否成功:


5.png


04

在 VS Code 中使用 Codex 扩展

1、在 VS Code 插件市场中搜索并安装 Codex 插件
6.png
2、安装后可通过 UI 与 Codex 交互,并与 CLI 共享 API 配置与对话历史。
7.png

05

使用 AGENTS.md 进行行为引导

你可以在以下位置创建 AGENTS.md 文件,为 Codex 提供项目上下文与行为指导:

  • ~/.codex/AGENTS.md:全局个人偏好;

  • 项目根目录 / AGENTS.md:项目级指引;

  • 子目录中的 AGENTS.md:任务级说明。

示例内容(摘自 Azure AI Agents SDK 文档):

markdown
复制
# Instructions for working with Azure AI Foundry Agents
 
You are an expert in the Azure AI Agents client library for Python.
 
## Key Concepts
- **Client Initialization**: Use `AIProjectClient` or `AgentsClient` with `DefaultAzureCredential`.
- **Agent Creation**: Call `agents_client.create_agent()` with `model`, `name`, and `instructions`.
- **Tools**: Support for File Search, Code Interpreter, and Function tools.


06

在 GitHub Actions 中集成 Codex

  以下示例演示如何在 CI 流水线中使用 Codex 自动更新项目日志:

yaml
复制
jobs:
  update_changelog:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Update changelog via Codex
        run: |
          npm install -g @openai/codex
          export AZURE_OPENAI_API_KEY="${{ secrets.AZURE_OPENAI_KEY }}"
          codex -p azure exec --full-auto "update CHANGELOG for next release"


07

总结

通过本文,你已完成以下关键操作:

1、在 Azure AI Foundry 中部署 GPT-5 Codex 模型;

2、安装并配置 Codex CLI

3、在 VS Code 中集成 Codex 扩展;

4、使用 AGENTS.md 引导模型行为;

5、在 GitHub Actions 中自动化 Codex 任务。

现在你可以开始高效使用 GPT-5 Codex 加速开发流程了!



  • 首页
  • 电话
  • 留言
  • 返回顶部
  • 您的姓名
  • 您的电话
  • 您的邮箱
  • 图形验证
  • 您的留言