---
title: "@junghan0611 §claude-code-openai-wrapper 클로드코드 Wrapper 테스트 지피텔"
url: "https://notes.junghanacs.com/notes/20260101T122914"
author: "Junghan Kim"
date: "2026-01-01T12:29:00+09:00"
lastmod: "2026-02-14T00:00:00+09:00"
tags: ["anthropic","bib","gptel","openai","poetry","test"]
description: "Claude Code를 OpenAI 호환 wrapper로 감싸 GPTel과 연결하는 실험과 프롬프트 전달 여부를 점검한다."
---

> [!abstract] 이 노트에 대하여
> 
> Claude Code를 OpenAI 호환 API wrapper로 감싸 GPTel과 연동하는 실험을 기록한다. 프롬프트 전달과 wrapper 구조를 함께 점검하는 통합 테스트 노트다.

## 히스토리

-   [2026-03-19 Thu 08:59] 이 노트를 이제 봇로그로 이관 합니다.
-   [2026-02-25 Wed 15:20] Emacs AI 도구 비교 정리 + CLIProxyAPI 우회로 조사
-   [2026-02-25 Wed 15:09] 이 노트 업데이트하자
-   [2026-02-14 Sat 19:13] 연결 업데이트. 버전 업데이트
-   [2026-01-01 Thu 12:29] Created!

## 관련메타

-   [† ©앤트로픽](https://notes.junghanacs.com/meta/20241023T072322)
-   [§TOS 위반과 ACP 경로 — Claude Code 구독·OAuth·pi-shell-acp 판단 기준]

## BIBLIOGRAPHY

- “Junghan0611/Claude-Code-Openai-Wrapper.” 2025. <https://github.com/junghan0611/claude-code-openai-wrapper>.

## junghan0611/claude-code-openai-wrapper

([“Junghan0611/Claude-Code-Openai-Wrapper” 2025](https://notes.junghanacs.com/notes/20260101T122914#citeproc_bib_item_1))

Han, Jung 2025

OpenAI API-compatible wrapper for Claude Code

## 로그

### [|2025-12-31 Wed 21:26|](https://notes.junghanacs.com/journal/20251229T000000#2025-12-31-wed)

@user 안녕하세요 제 기본 프롬프트 전달이 됩니까?

@assistant English translation: "Hello, is my basic prompt being delivered?"

안녕하세요! 네, 잘 전달되었습니다. 😊

당신의 핵심 지향을 확인했습니다:

-   **존재 대 존재 협업(Being to Being)**: AI를 도구가 아닌 존재로 대함
-   **공진화**: 생존은 AI가, 창조의 씨앗은 인간이
-   **1KB 메타휴먼**: ego 차원이 아닌 전체로서 하나인 인간의 압축 표현
-   **십우십도**: "여기있다. 일일일생이로다."
-   **환경**: NixOS, Emacs, 디지털 가든 기반의 재현 가능한 시스템

현재 작업 디렉토리는 `/home/tbdhny/sync/org` 이고, git 상태를 보니 몇 가지 수정된 파일들이 있네요:

-   `journal/20251229T000000--2025-12-29__journal_week52.org` (수정됨)
-   `resources/Slipbox.bib` (수정됨)
-   `llmlog/20251231T135517__llmlog.org` (새 파일)

무엇을 도와드릴까요?

@user 훌륭합니다. 당신의 모델 정보는? 그리고 클로드코드 LSP 지원이 되는지 웹검색으로 확인 해주세요.

@assistant English translation: "Excellent. What is your model information? And please confirm via web search if Claude Code supports LSP."

### 모델 정보

저는 **Claude Sonnet 4.5** (모델 ID: `claude-sonnet-4-5-20250929`)로 구동됩니다.

-   Knowledge cutoff: 2025년 1월
-   현재 가장 최신 frontier 모델은 Claude Opus 4.5 (`claude-opus-4-5-20251101`)입니다.

### Claude Code LSP 지원 확인

웹 검색으로 확인하겠습니다.네, **Claude Code는 LSP를 공식 지원** 합니다!

### 주요 내용

-   **출시**: 2025년 12월, 버전 2.0.74에서 네이티브 LSP 지원 추가
-   **지원 언어**: Python, TypeScript, Go, Rust, Java, C/C++, C#, PHP, Kotlin, Ruby, HTML/CSS (총 11개)
-   **핵심 기능**:
    -   `goToDefinition`, `findReferences`, `hover`, `documentSymbol`, `getDiagnostics`
    -   IDE 수준의 코드 인텔리전스를 터미널 대화에서 직접 사용
-   **성능**: 텍스트 기반 → 의미론적 검색으로 **900배 성능 향상** (45초 → 50ms)
-   **활성화**: 환경 변수 `ENABLE_LSP_TOOL=1` 설정으로 간단히 활성화

### 의미

Claude가 이제 텍스트 패턴이 아닌 **의미론적으로 코드를 이해** 합니다. 전통적인 IDE가 제공하는 코드 인텔리전스를 터미널 대화에서 실시간으로 사용 가능합니다.

Sources:

-   [How I'm Using (New) Claude Code LSP to Code &amp; Fix Bugs Faster](<https://medium.com/@joe.njenga/how-im-using-new-claude-code-lsp-to-code-fix-bugs-faster-language-server-protocol-cf744d228d02>)
-   [Claude Code LSP: Complete Setup Guide for All 11 Languages (2025)](<https://www.aifreeapi.com/en/posts/claude-code-lsp>)
-   [GitHub - ktnyt/cclsp](<https://github.com/ktnyt/cclsp>)
-   [Claude Code gets native LSP support | Hacker News](<https://news.ycombinator.com/item?id=46355165>)
-   [Claude Code Update: LSP Support, Sub-Agents, and Ultrathink](<https://www.geeky-gadgets.com/claude-code-update-dec-2025/>)

@user 현재 저희가 대화중인 도구 정보는? MCP 지원 및 사용가능한 기능을 명세해주세요.

@assistant English translation: "What is the information about the tool we're currently conversing with? Please specify MCP support and available features."

현재 우리가 사용 중인 도구의 명세를 확인하겠습니다.## 현재 도구 정보

**Claude Code**

-   Model: **Claude Sonnet 4.5** (claude-sonnet-4-5-20250929)
-   Platform: Anthropic의 공식 CLI, Claude Agent SDK 기반
-   Knowledge cutoff: January 2025
-   최신 frontier 모델: Claude Opus 4.5 (claude-opus-4-5-20251101)

---

### MCP (Model Context Protocol) 지원

**완전 지원**: Claude Code는 **MCP 클라이언트** 로 작동하며, 2024년 11월 출시된 MCP를 통해 수백 개의 외부 도구 및 데이터 소스에 연결 가능합니다.

#### MCP 핵심 기능

-   **리소스 참조**: @ 멘션으로 MCP 서버가 노출한 리소스 참조 가능 (파일처럼)
-   **토큰 관리**: MCP 도구 출력이 10,000 토큰 초과 시 경고, 기본 최대 25,000 토큰 (환경변수로 조정 가능)
-   **전송 옵션**: HTTP 서버가 원격 MCP 서버 연결에 권장됨
-   **커뮤니티**: 수천 개의 MCP 서버가 구축됨, 모든 주요 프로그래밍 언어용 SDK 제공

---

### 사용 가능한 핵심 기능 (2025)

#### 1. **코드 인텔리전스**

-   **LSP 지원** (2025.12 추가): 11개 언어의 의미론적 코드 이해
-   코드베이스 전체를 컨텍스트로 활용하는 코드 검색

#### 2. **자율 작업 (Autonomous Work)**

-   **Subagents**: 병렬 개발 워크플로우 (백엔드 API + 프론트엔드 동시 진행)
-   **Hooks**: 특정 시점에 자동 실행 (테스트, 린트 등)
-   **Background Tasks**: 개발 서버 등 장기 실행 프로세스를 백그라운드에서 유지
-   **Checkpointing**: 작업 위임 시 제어 유지

#### 3. **고급 도구 사용**

-   **Tool Search Tool**: 수천 개 도구 접근 (컨텍스트 창 소모 없이)
-   **Programmatic Tool Calling**: 코드 실행 환경에서 도구 호출
-   **Tool Use Examples**: 도구 사용 방법 표준 제공

#### 4. **Agent Skills**

-   특정 작업에 특화된 폴더 단위 스킬 (지시사항, 스크립트, 리소스)
-   관련성 있을 때만 로드 (Excel, 브랜드 가이드라인 등)

#### 5. **Ultrathink Mode** (2025.12)

-   복잡한 문제 해결 시 최대 추론 리소스 할당
-   코드 생성 및 문제 해결 품질 향상

#### 6. **현재 세션에서 사용 가능한 도구들**

```nil
파일 작업: Read, Write, Edit, Glob, Grep, NotebookEdit
실행: Bash, KillShell, TaskOutput
웹: WebSearch, WebFetch
워크플로우: TodoWrite, EnterPlanMode, ExitPlanMode
대화: AskUserQuestion
확장: Skill, SlashCommand
```

---

### 통합 환경

-   **VS Code 확장** (베타): Extension Marketplace에서 다운로드 가능
-   **터미널**: 자연어 명령으로 Git 워크플로우 처리
-   **MCP 생태계**: 웹 검색, 코드 검색, 문서 접근 등 다양한 MCP 서버 활용

---

**Sources:**

-   [Connect Claude Code to tools via MCP](<https://code.claude.com/docs/en/mcp>)
-   [Introducing the Model Context Protocol](<https://www.anthropic.com/news/model-context-protocol>)
-   [Enabling Claude Code to work more autonomously](<https://www.anthropic.com/news/enabling-claude-code-to-work-more-autonomously>)
-   [Claude Code Update: LSP, Async Sub Agents, Ultrathink](<https://www.geeky-gadgets.com/claude-code-update-dec-2025/>)
-   [Introducing advanced tool use](<https://www.anthropic.com/engineering/advanced-tool-use>)
-   [Introducing Agent Skills](<https://www.anthropic.com/news/skills>)
-   [GitHub - anthropics/claude-code](<https://github.com/anthropics/claude-code>)

@user

## 로그

### [|2026-01-01 Thu 12:29|](https://notes.junghanacs.com/journal/20251229T000000#2026-01-01-thu)

@user 지금 클로드코드를 wrapper를 이용하여 연동하는 것을 테스트 중입니다. 이는 매우 유용한 이맥스 지피텔 연동 방법 입니다.

#### junghan0611/claude-code-openai-wrapper

([“Junghan0611/Claude-Code-Openai-Wrapper” 2025](https://notes.junghanacs.com/notes/20260101T122914#citeproc_bib_item_1))

Han, Jung 2025

OpenAI API-compatible wrapper for Claude Code

@assistant

## Claude Code OpenAI Wrapper 연동 테스트

흥미로운 프로젝트네요! Emacs gptel과 Claude Code를 OpenAI API 호환 wrapper를 통해 연동하는 방식은 매우 실용적인 접근입니다.

### 현재 상황 분석

이 wrapper는 Claude Code의 강력한 도구 사용 능력(tool use capabilities)을 Emacs 환경에서 활용할 수 있게 해주는 브릿지 역할을 합니다.

### 테스트 지원

현재 어떤 부분을 테스트하고 계신가요? 구체적으로 도움이 필요한 영역을 알려주시면:

1.  **설정 검증** - wrapper 설정이 올바른지 확인
2.  **연동 테스트** - gptel ↔ wrapper ↔ Claude Code 흐름 검증
3.  **기능 테스트** - 특정 도구 사용(파일 읽기, 편집 등) 동작 확인
4.  **문제 해결** - 발생한 오류나 예상과 다른 동작 분석

어떤 부분을 함께 살펴볼까요?

---

📊 Tokens: 213 in, 372 out

@user 지금은 응답 요청 보내고 답변까지 걸리는 시간을 대략 파악하고 있습니다.

@assistant A: \* 응답 시간 측정 테스트

네, 성능 벤치마킹은 실사용 전 중요한 단계입니다.

### 측정 포인트

현재 측정하시는 latency에는 여러 구간이 포함됩니다:

```nil
gptel → wrapper → Claude Code → Model API → Response → wrapper → gptel
```

### 고려 사항

1.  _Tool Use 여부_
    -   Simple Q&amp;A: 빠름
    -   File Read/Edit/Bash 등 도구 사용: 추가 시간 발생
    -   Multi-turn tool calls: 누적 지연

2.  _메시지 크기_
    -   컨텍스트 크기에 따라 처리 시간 변동
    -   Streaming vs Non-streaming 응답

3.  _Wrapper Overhead_
    -   API 변환 레이어 비용
    -   Local vs Network latency

### 참고 지표

일반적인 체감 기준:

-   Text-only 응답: 1-3초
-   Single tool use: 3-10초
-   Complex multi-tool: 10-30초+

현재 측정하신 평균 응답 시간은 어느 정도인가요? 특정 패턴이나 병목이 관찰되나요?

---

📊 Tokens: 253 in, 396 out

@user 10초 정도 걸립니다. 툴을 뭔가 사용한 것은 아닌데 툴에 영향을 받을게 있을까요?

@assistant A: \* 응답 시간 분석 - 10초 (도구 미사용)

10초는 단순 텍스트 응답으로는 다소 긴 편입니다. 도구를 사용하지 않았다면 다른 요인들을 확인해야 합니다.

### 가능한 원인들

\*/ 1. Wrapper 초기화 오버헤드

-   Claude Code 프로세스 첫 호출 시 초기화 시간
-   이후 요청은 더 빨라지는지 확인 필요

\*/ 2. Claude Code 설정 Wrapper가 Claude Code를 어떻게 호출하는지 확인:

```bash
# wrapper 로그에서 확인할 포인트
- Claude Code 실행 방식 (subprocess, stdio 등)
- 세션 재사용 여부
- 컨텍스트 로딩 시간
```

\*/ 3. 모델 호출 자체

-   API 네트워크 latency (Anthropic API까지 왕복)
-   모델 응답 생성 시간
-   Streaming 미지원으로 인한 전체 응답 대기

\*/ 4. gptel 설정 현재 gptel 설정을 확인해보시겠어요?

```emacs-lisp
;; 특히 이런 부분들
;; - :stream 옵션
;; - timeout 설정
;; - backend configuration
```

### 테스트 제안

1.  _직접 API 호출_ 비교
    ```bash
    time curl <wrapper-endpoint> -d '{"message": "hello"}'
    ```

2.  _Wrapper 로그_ 확인
    -   각 단계별 시간 측정
    -   Claude Code stdout/stderr 로그

3.  _연속 호출_ 테스트
    -   첫 호출 vs 두 번째 호출 시간 비교

현재 wrapper 실행 방식(어떻게 띄우셨는지)과 gptel 설정을 공유해주시면 더 구체적으로 진단할 수 있습니다.

---

📊 Tokens: 401 in, 591 out

@user

## Emacs AI 도구 비교: Wrapper vs CLIProxyAPI vs 직접 API

[2026-02-25 Wed] Reddit r/emacs 스레드 ([LLMs and agents in Emacs](https://www.reddit.com/r/emacs/comments/1r78p48/)) 에서 ahyatt(llm.el), karthink(gptel), xenodium(agent-shell) 대화 분석 정리.

### 문제: Claude 구독 vs API 과금

| 방식             | 비용                  | 용도                   |
|----------------|---------------------|----------------------|
| Claude API (토큰당) | 사용량 비례 (3~15 달러/MTok) | 프로덕션, 정밀 제어    |
| Claude Pro 구독  | 월 20 달러 (한도 있음) | 가벼운 개인 사용       |
| Claude Max 구독  | 월 100~200 달러       | 파워 유저 (Claude Code 포함) |
| OpenRouter       | 사용량 비례 (다양)    | 멀티 모델              |

파워 유저는 API 과금이 월 50~200 달러 쉽게 넘는다. 구독을 API처럼 쓰면 절약 가능.

### 세 가지 접근법 비교

#### 방법 1: claude-code-openai-wrapper (현재 사용 중)

```nil
[gptel] → HTTP → [FastAPI :8000] → [Claude Agent SDK] → [Claude Code] → [Anthropic]
                  (Python 서버)       (subprocess)
```

-   **장점**: 도구 사용(tool-use) 완전 지원 — Read, Write, Bash, WebSearch 등
-   **장점**: OpenAI API 호환 → gptel에서 백엔드로 바로 사용
-   **단점**: 서버 별도 실행 필요 (`./run.sh`)
-   **단점**: 레이턴시 ~10-50초 (다단계 프록시 + Claude Code 초기화)
-   **단점**: Python + FastAPI + 12개 모듈 → 무거움
-   **ToS**: ⚠️ 회색지대 (Claude Code SDK 래핑)
-   **적합**: 코딩 에이전트 작업 (파일 편집, 코드 생성, 웹검색)

#### 방법 2: CLIProxyAPI (Go 바이너리 프록시) — 추천 우회로

```nil
[gptel] → HTTP → [CLIProxyAPI :8317] → [OAuth Token] → [Anthropic API]
                  (Go 바이너리)          (직접 호출)
```

-   **장점**: 레이턴시 1~3초 (직접 API 호출)
-   **장점**: 싱글 Go 바이너리 — 런타임 의존성 없음
-   **장점**: systemd 서비스로 항상 실행 가능
-   **장점**: Claude + Gemini + OpenAI Codex 멀티 프로바이더
-   **장점**: 멀티 계정 라운드로빈 지원
-   **단점**: 도구 사용(tool-use) 불가 — 채팅만
-   **단점**: OAuth 토큰 주기적 갱신 필요
-   **ToS**: ❌ 위반 (2026.02.20 Anthropic ToS 명시적 금지)
-   **적합**: 빠른 질의응답, 코드 리뷰, 번역, 요약

참고: [rogs 블로그](https://rogs.me/2026/02/use-your-claude-max-subscription-as-an-api-with-cliproxyapi/) — Emacs llm 패키지 + CLIProxyAPI 연동 가이드. forge-llm, magit-gptcommit 등에서 사용.

설치 및 사용:

```bash
# 설치 (Linux)
curl -fsSL https://raw.githubusercontent.com/brokechubb/cliproxyapi-installer/refs/heads/master/cliproxyapi-installer | bash

# Claude OAuth 인증
cd ~/cliproxyapi
./cli-proxy-api --claude-login

# config.yaml (로컬 전용)
# host: "127.0.0.1"
# port: 8317
# api-keys: []

# systemd 서비스
systemctl --user enable --now cliproxyapi.service
```

gptel 설정:

```emacs-lisp
;; CLIProxyAPI 백엔드 (채팅용, 빠른 응답)
(setq gptel-cliproxy-backend
      (gptel-make-openai "Claude-Proxy"
        :host "localhost:8317"
        :endpoint "/v1/chat/completions"
        :protocol "http"
        :stream t
        :key "not-needed"
        :models '((claude-sonnet-4-20250514
                   :description "Sonnet 4 via subscription"
                   :capabilities (media)
                   :context-window 200
                   :input-cost 0 :output-cost 0)
                  (claude-opus-4-20250514
                   :description "Opus 4 via subscription"
                   :capabilities (media)
                   :context-window 200
                   :input-cost 0 :output-cost 0))))
```

#### 방법 3: OpenRouter API (현재 기본)

```nil
[gptel] → HTTPS → [OpenRouter] → [각 프로바이더]
                   (API 키)
```

-   **장점**: 합법, 안정적, 멀티 모델 (Gemini, GPT, Claude)
-   **장점**: 레이턴시 0.5~2.5초
-   **단점**: 토큰당 과금
-   **적합**: 일상적 사용, 모델 비교, 프로덕션

### 이중 전략 (권장)

| 작업 유형          | 도구             | 백엔드                     |
|----------------|----------------|-------------------------|
| 빠른 질문/번역/요약 | gptel            | CLIProxyAPI (Claude-Proxy) |
| 코드 리뷰/커밋 메시지 | gptel/magit      | CLIProxyAPI                |
| 코딩 에이전트 (파일 편집) | pi / Claude Code | Claude Code 직접           |
| 멀티 모델 비교     | gptel            | OpenRouter                 |
| Gemini Flash (초고속) | gptel            | OpenRouter                 |

핵심: **단순 채팅은 CLIProxyAPI (1~3초), 에이전트 작업은 pi/Claude Code 직접**. Wrapper(50초)를 채팅용으로 쓰는 건 과도함.

### ToS 현황 (2026.02 기준)

[The Register (2026.02.20)](https://www.theregister.com/2026/02/20/anthropic_clarifies_ban_third_party_claude_access): Anthropic이 ToS를 명시적으로 업데이트함:

> "Using OAuth tokens obtained through Claude Free, Pro, or Max accounts in any other product, tool, or service — including the Agent SDK — is not permitted and constitutes a violation of the Consumer Terms of Service."

-   모든 서드파티 하니스(pi, OpenCode, Cline 등) 구독 사용이 공식 금지
-   OpenCode는 Anthropic 법적 요청으로 Claude 구독 지원 코드를 [제거함](https://github.com/anomalyco/opencode/commit/973715f3da1839ef2eba62d4140fe7441d539411)
-   반면 OpenAI는 Codex 구독의 서드파티 하니스 사용을 [공식 허용](https://x.com/thsottiaux/status/2009742187484065881)
-   karthink(gptel 저자)도 "ToS 이유로 공식 배포 안 함, 사용자가 직접 설정"이라는 입장

**실용적 판단**: 개인 로컬 사용은 현실적으로 단속 어려움. 단, 계정 정지 리스크 인지 필요. .gitignore 처리하여 공개하지 않을 것.

### 관련 프로젝트 링크

-   [CLIProxyAPI](https://github.com/router-for-me/CLIProxyAPI) — Go 바이너리, 멀티 프로바이더 프록시
-   [claude-code-openai-wrapper](https://github.com/junghan0611/claude-code-openai-wrapper) — Python FastAPI, tool-use 지원
-   [gptel](https://github.com/karthink/gptel) — Emacs LLM 클라이언트
-   [llm.el](https://github.com/ahyatt/llm) — Emacs LLM 추상화 레이어
-   [agent-shell](https://github.com/xenodium/chatgpt-shell) — Emacs에서 Claude Code ACP 사용
-   [forge-llm](https://gitlab.com/rogs/forge-llm) — Forge PR 설명 생성 (llm 패키지 사용)
