> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bettertoken.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Codex Custom Provider: model_provider, Base URL 및 wire_api

> model_provider, Base URL, wire_api, API Key 및 Model ID로 Codex custom provider를 구성하고 provider, 401, 404 errors를 해결하세요.

## 짧은 답변

`model_provider`는 Codex CLI가 사용할 provider를 지정합니다. value는 `[model_providers.<id>]` 아래에 정의된 provider id와 일치해야 합니다.

`base_url`은 model requests를 보내는 API endpoint입니다. OpenAI-compatible provider에서는 보통 `/v1` style endpoint를 가리킵니다.

`wire_api`는 해당 provider와 통신할 때 Codex가 사용할 protocol shape를 지정합니다. Codex configuration reference에서 `responses`는 지원되는 provider protocol value입니다.

## 이 내용이 필요한 경우

* custom OpenAI-compatible provider를 구성 중임
* Codex가 provider를 찾을 수 없다고 하거나 model requests가 실패함
* `model_provider`와 `model`의 차이를 확신하지 못함
* BetterToken, OpenAI 또는 다른 provider를 하나의 `config.toml`에 넣고 있음
* Base URL, API Key 및 Model ID를 분리해야 함

## Field 관계

| Field                    | 목적                                         |
| ------------------------ | ------------------------------------------ |
| `model_provider`         | active provider id 선택                      |
| `[model_providers.<id>]` | 하나의 provider detailed configuration 정의     |
| `name`                   | provider의 display name                     |
| `base_url`               | root API endpoint                          |
| `wire_api`               | provider protocol, 보통 `responses`          |
| `model`                  | default main model ID                      |
| `review_model`           | `/review` 등의 code review flows에 사용하는 model |

## 권장 pattern

provider id를 일관되게 유지하세요.

```toml theme={null}
model_provider = "custom"
model = "gpt-5.5"

[model_providers.custom]
name = "BetterToken"
base_url = "https://www.bettertoken.ai/v1"
env_key = "MODEL_PROVIDER_API_KEY"
wire_api = "responses"
requires_openai_auth = false
```

이는 Codex가 `custom`이라는 provider를 사용하고 model requests를 `https://www.bettertoken.ai/v1`으로 보내며 Responses API shape로 통신한다는 뜻입니다.

API Key를 `config.toml`에 직접 넣지 마세요. Codex를 실행하는 terminal에서 설정하세요.

```bash theme={null}
export MODEL_PROVIDER_API_KEY="YOUR_API_KEY"
```

Windows PowerShell:

```powershell theme={null}
$env:MODEL_PROVIDER_API_KEY="YOUR_API_KEY"
```

## 설정 확인

1. `model_provider = "custom"`이 `[model_providers.custom]`과 정확히 일치하는지 확인하세요.
2. Base URL이 `https://www.bettertoken.ai/v1`이며 `/v1`을 포함하는지 확인하세요.
3. <a href={"https://bettertoken.ai/pricing"}>모델 광장</a>의 **GPT provider**에서 current Model ID를 복사하세요.
4. Codex를 완전히 종료하고 environment variable이 설정된 새 terminal에서 다시 실행하세요.
5. 작은 code-explanation task를 보내 Codex가 complete response를 반환하는지 확인하세요.

## 문제 해결

| 증상                       | 원인                                                   | 해결 방법                                          |
| ------------------------ | ---------------------------------------------------- | ---------------------------------------------- |
| Provider not found       | provider id와 configuration table이 일치하지 않음            | 두 곳 모두 `custom` 사용                             |
| startup 시 API Key 누락     | `env_key`가 지정한 variable을 사용할 수 없음                    | `MODEL_PROVIDER_API_KEY`를 설정하고 새 terminal 열기   |
| `401` 또는 `403`           | invalid API Key 또는 mixed OpenAI authentication       | Key를 다시 복사하고 `requires_openai_auth = false` 설정 |
| `404`                    | Base URL에 `/v1`이 없거나 Anthropic endpoint를 가리킴         | `https://www.bettertoken.ai/v1` 사용             |
| Model not found          | value가 display name, retired model 또는 non-GPT model임 | 모델 광장에서 current Model ID 복사                    |
| Responses protocol error | `wire_api`가 없거나 incorrect함                           | `wire_api = "responses"` 설정                    |

## 관련 문서

* [Codex CLI config.toml 구성](/ko/faq/codex/config-toml)
* [Codex BetterToken 설정 가이드](/ko/ai-tools/codex)
* [Codex CLI sandbox 및 approval modes란?](/ko/faq/codex/sandbox-approval)
* [OpenAI-compatible API와 Anthropic-compatible API 비교](/ko/faq/concepts/openai-compatible-vs-anthropic-compatible)

## 참고 자료

* [Codex configuration 참고 자료](https://developers.openai.com/codex/config-reference)
* [Codex sample config](https://developers.openai.com/codex/config-sample)
* [Codex advanced configuration](https://developers.openai.com/codex/config-advanced)
