documentation: Update ocm/ccm examples

This commit is contained in:
世界
2026-03-10 21:49:18 +08:00
parent 67621ee6ba
commit 8bb4c4dd32
4 changed files with 81 additions and 18 deletions

View File

@@ -66,7 +66,19 @@ List of authorized users for token authentication.
If empty, no authentication is required. If empty, no authentication is required.
Claude Code authenticates by setting the `ANTHROPIC_AUTH_TOKEN` environment variable to their token value. Object format:
```json
{
"name": "",
"token": ""
}
```
Object fields:
- `name`: Username identifier for tracking purposes.
- `token`: Bearer token for authentication. Claude Code authenticates by setting the `ANTHROPIC_AUTH_TOKEN` environment variable to their token value.
#### headers #### headers
@@ -84,23 +96,36 @@ TLS configuration, see [TLS](/configuration/shared/tls/#inbound).
### Example ### Example
#### Server
```json ```json
{ {
"services": [ "services": [
{ {
"type": "ccm", "type": "ccm",
"listen": "127.0.0.1", "listen": "0.0.0.0",
"listen_port": 8080 "listen_port": 8080,
"usages_path": "./claude-usages.json",
"users": [
{
"name": "alice",
"token": "ak-ccm-hello-world"
},
{
"name": "bob",
"token": "ak-ccm-hello-bob"
}
]
} }
] ]
} }
``` ```
Connect to the CCM service: #### Client
```bash ```bash
export ANTHROPIC_BASE_URL="http://127.0.0.1:8080" export ANTHROPIC_BASE_URL="http://127.0.0.1:8080"
export ANTHROPIC_AUTH_TOKEN="sk-ant-ccm-auth-token-not-required-in-this-context" export ANTHROPIC_AUTH_TOKEN="ak-ccm-hello-world"
claude claude
``` ```

View File

@@ -66,7 +66,19 @@ Claude Code OAuth 凭据文件的路径。
如果为空,则不需要身份验证。 如果为空,则不需要身份验证。
Claude Code 通过设置 `ANTHROPIC_AUTH_TOKEN` 环境变量为其令牌值进行身份验证。 对象格式:
```json
{
"name": "",
"token": ""
}
```
对象字段:
- `name`:用于跟踪的用户名标识符。
- `token`:用于身份验证的 Bearer 令牌。Claude Code 通过设置 `ANTHROPIC_AUTH_TOKEN` 环境变量为其令牌值进行身份验证。
#### headers #### headers
@@ -84,23 +96,36 @@ TLS 配置,参阅 [TLS](/zh/configuration/shared/tls/#inbound)。
### 示例 ### 示例
#### 服务端
```json ```json
{ {
"services": [ "services": [
{ {
"type": "ccm", "type": "ccm",
"listen": "127.0.0.1", "listen": "0.0.0.0",
"listen_port": 8080 "listen_port": 8080,
"usages_path": "./claude-usages.json",
"users": [
{
"name": "alice",
"token": "ak-ccm-hello-world"
},
{
"name": "bob",
"token": "ak-ccm-hello-bob"
}
]
} }
] ]
} }
``` ```
连接到 CCM 服务: #### 客户端
```bash ```bash
export ANTHROPIC_BASE_URL="http://127.0.0.1:8080" export ANTHROPIC_BASE_URL="http://127.0.0.1:8080"
export ANTHROPIC_AUTH_TOKEN="sk-ant-ccm-auth-token-not-required-in-this-context" export ANTHROPIC_AUTH_TOKEN="ak-ccm-hello-world"
claude claude
``` ```

View File

@@ -37,7 +37,9 @@ See [Listen Fields](/configuration/shared/listen/) for details.
Path to the OpenAI OAuth credentials file. Path to the OpenAI OAuth credentials file.
If not specified, defaults to `~/.codex/auth.json`. If not specified, defaults to:
- `$CODEX_HOME/auth.json` if `CODEX_HOME` environment variable is set
- `~/.codex/auth.json` otherwise
Refreshed tokens are automatically written back to the same location. Refreshed tokens are automatically written back to the same location.
@@ -111,6 +113,8 @@ TLS configuration, see [TLS](/configuration/shared/tls/#inbound).
Add to `~/.codex/config.toml`: Add to `~/.codex/config.toml`:
```toml ```toml
# profile = "ocm" # set as default profile
[model_providers.ocm] [model_providers.ocm]
name = "OCM Proxy" name = "OCM Proxy"
base_url = "http://127.0.0.1:8080/v1" base_url = "http://127.0.0.1:8080/v1"
@@ -143,11 +147,11 @@ codex --profile ocm
"users": [ "users": [
{ {
"name": "alice", "name": "alice",
"token": "sk-alice-secret-token" "token": "sk-ocm-hello-world"
}, },
{ {
"name": "bob", "name": "bob",
"token": "sk-bob-secret-token" "token": "sk-ocm-hello-bob"
} }
] ]
} }
@@ -160,11 +164,13 @@ codex --profile ocm
Add to `~/.codex/config.toml`: Add to `~/.codex/config.toml`:
```toml ```toml
# profile = "ocm" # set as default profile
[model_providers.ocm] [model_providers.ocm]
name = "OCM Proxy" name = "OCM Proxy"
base_url = "http://127.0.0.1:8080/v1" base_url = "http://127.0.0.1:8080/v1"
supports_websockets = true supports_websockets = true
experimental_bearer_token = "sk-alice-secret-token" experimental_bearer_token = "sk-ocm-hello-world"
[profiles.ocm] [profiles.ocm]
model_provider = "ocm" model_provider = "ocm"

View File

@@ -37,7 +37,9 @@ OCMOpenAI Codex 多路复用器)服务是一个多路复用服务,允许
OpenAI OAuth 凭据文件的路径。 OpenAI OAuth 凭据文件的路径。
如果未指定,默认值为 `~/.codex/auth.json` 如果未指定,默认值为
- 如果设置了 `CODEX_HOME` 环境变量,则使用 `$CODEX_HOME/auth.json`
- 否则使用 `~/.codex/auth.json`
刷新的令牌会自动写回相同位置。 刷新的令牌会自动写回相同位置。
@@ -111,6 +113,9 @@ TLS 配置,参阅 [TLS](/zh/configuration/shared/tls/#inbound)。
`~/.codex/config.toml` 中添加: `~/.codex/config.toml` 中添加:
```toml ```toml
# profile = "ocm" # 设为默认配置
[model_providers.ocm] [model_providers.ocm]
name = "OCM Proxy" name = "OCM Proxy"
base_url = "http://127.0.0.1:8080/v1" base_url = "http://127.0.0.1:8080/v1"
@@ -143,11 +148,11 @@ codex --profile ocm
"users": [ "users": [
{ {
"name": "alice", "name": "alice",
"token": "sk-alice-secret-token" "token": "sk-ocm-hello-world"
}, },
{ {
"name": "bob", "name": "bob",
"token": "sk-bob-secret-token" "token": "sk-ocm-hello-bob"
} }
] ]
} }
@@ -160,11 +165,13 @@ codex --profile ocm
`~/.codex/config.toml` 中添加: `~/.codex/config.toml` 中添加:
```toml ```toml
# profile = "ocm" # 设为默认配置
[model_providers.ocm] [model_providers.ocm]
name = "OCM Proxy" name = "OCM Proxy"
base_url = "http://127.0.0.1:8080/v1" base_url = "http://127.0.0.1:8080/v1"
supports_websockets = true supports_websockets = true
experimental_bearer_token = "sk-alice-secret-token" experimental_bearer_token = "sk-ocm-hello-world"
[profiles.ocm] [profiles.ocm]
model_provider = "ocm" model_provider = "ocm"