2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Codex CLI と Azure OpenAI の接続設定

Posted at

はじめに

  • Azure OpenAI 使ってるとたいていの場合、接続に手間取りませんか?
  • とりあえず接続できて使えた設定を記載します。こうした方がいいとか間違ってるとかあったらコメントください

手順

# OS ubuntu 22.04 lts
npm install -g @openai/codex
~/.codex/config.toml
[model_providers.azure]
name = "Azure"
# <YOUR_RESOURCE_NAME> は使用しているリソース名にしてください
base_url = "https://<YOUR_RESOURCE_NAME>.openai.azure.com/openai/"
env_key = "AZURE_OPENAI_API_KEY"
# api-versionを指定 普段使用しているものでも問題なし
query_params = { api-version = "2025-04-01-preview" }
wire_api = "responses"

# Optional profile so you can switch easily
# azure_gpt41はprofileを指定するときの名前です
[profiles.azure_gpt41]
model_provider = "azure"
# 使用しているmodelのdeployment name
model = "gpt-4.1"
# azure_gpt5はprofileを指定するときの名前です
[profiles.azure_gpt5]
model_provider = "azure"
# 使用しているmodelのdeployment name
model = "gpt-5"

# オプション設定
preferred_auth_method = "apikey"
model_reasoning_effort = "high"
model_reasoning_summary = "detailed"

接続確認

# 接続キーのエクスポート
export AZURE_OPENAI_API_KEY='xxxxx'
codex --profile azure_gpt41 "hello"
  • 以下のような回答があれば接続できている
codex
Hi there! How can I help you today?
# /statusでmodel名を確認するとさらに確実です
/status
📂 Workspace
  • Path: ~/xxxxxxxx
  • Approval Mode: on-request
  • Sandbox: workspace-write

🧠 Model
  • Name: gpt-4.1
  • Provider: Azure

📊 Token Usage
  • Session ID: xxxxxxxx
  • Input: 0
  • Output: 0
  • Total: 0
# 異なるmodelで接続するとき
codex --profile azure_gpt5 "hello"

この記事が何かのお役にたてれば幸いです。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?