﻿---
title: "通过 Coder AI Gateway 连接模型服务"
filename: "~/.codex/ai_gateway.config.toml"
canonical: /templates/coder-ai-gateway/
---

# 通过 Coder AI Gateway 连接模型服务

用户层 [model_providers.ai_gateway]，base_url 以 /api/v2/ai-gateway/openai/v1 结尾，env_key = OPENAI_API_KEY，wire_api = responses，supports_websockets = false。再用 ~/.codex/ai_gateway.config.toml 和 --profile ai_gateway。

```
model_provider = "ai_gateway"

[model_providers.ai_gateway]
name = "AI Gateway"
base_url = "https://YOUR_DEPLOYMENT/api/v2/ai-gateway/openai/v1"
env_key = "OPENAI_API_KEY"
wire_api = "responses"
supports_websockets = false

```
