果砸的博客

果砸的博客

Codex 安装配置教程

2026-07-10

工具与资源指南

官方链接

工具名称

功能说明

访问链接

Codex

官方 AI 编程助手

https://openai.com/zh-Hans-CN/codex/

CC Switch

用于快速修改 Claude Code 配置

https://ccswitch.io/zh/

推荐API中转站链接: https://www.168hours.top:20004/

使用方法

一、安装Codex

二、安装CC Switch

三、配置绘图Skill

将下面的内容粘贴给codex,让其创建为skill用于绘图:

1. 安装 OpenAI Python SDK。

```
pip install openai
```

2. 图片生成:根据文字描述生成图片。

**图片生成 (Python)**

```python
from openai import OpenAI
import base64

client = OpenAI(
    base_url="https://www.168hours.top:20004/v1",
    api_key="你的API Key",
)

result = client.images.generate(
    model="gpt-image-2",
    prompt="A children's book drawing of a veterinarian using a stethoscope to listen to the heartbeat of a baby otter.",
    size="1024x1024",
    quality="high",
)

image_base64 = result.data[0].b64_json
image_bytes = base64.b64decode(image_base64)

with open("otter.png", "wb") as f:
    f.write(image_bytes)
```

**图片生成 (curl)**

```bash
curl -X POST "https://www.168hours.top:20004/v1/images/generations" \
    -H "Authorization: Bearer 你的API Key" \
    -H "Content-Type: application/json" \
    -d '{
        "model": "gpt-image-2",
        "prompt": "A children's book drawing of a veterinarian using a stethoscope to listen to the heartbeat of a baby otter.",
        "size": "1024x1024",
        "quality": "high"
    }' | jq -r '.data[0].b64_json' | base64 --decode > otter.png
```

3. 图片编辑:基于已有图片和文字描述进行修改。

**图片编辑 (Python)**

```python
from openai import OpenAI
import base64

client = OpenAI(
    base_url="https://www.168hours.top:20004/v1",
    api_key="你的API Key",
)

result = client.images.edit(
    model="gpt-image-2",
    image=open("sunlit_lounge.png", "rb"),
    mask=open("mask.png", "rb"),
    prompt="A sunlit indoor lounge area with a pool containing a flamingo",
    size="1024x1024",
    quality="high",
)

image_base64 = result.data[0].b64_json
image_bytes = base64.b64decode(image_base64)

with open("edited.png", "wb") as f:
    f.write(image_bytes)
```

**图片编辑 (curl)**

```bash
curl -X POST "https://www.168hours.top:20004/v1/images/edits" \
    -H "Authorization: Bearer 你的API Key" \
    -F "model=gpt-image-2" \
    -F "image[]=@sunlit_lounge.png" \
    -F "mask=@mask.png" \
    -F "prompt=A sunlit indoor lounge area with a pool containing a flamingo" \
    -F "size=1024x1024" \
    -F "quality=high" \
    | jq -r '.data[0].b64_json' | base64 --decode > edited.png
```