feat: add OpenAI API integration support#132
feat: add OpenAI API integration support#132xuzhongpeng wants to merge 1 commit intoclaude-code-best:mainfrom
Conversation
Add comprehensive OpenAI API adapter to support OpenAI-compatible API endpoints, enabling users to use OpenAI models alongside Claude models. Changes: - Add OpenAI API adapter with streaming support and tool calling - Add OpenAI integration documentation with usage examples - Update model configuration system to support OpenAI models - Enhance authentication flow to handle OpenAI API keys - Add model provider detection and routing logic Closes claude-code-best#48 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR implements OpenAI-compatible API mode support, allowing users to configure and use OpenAI API endpoints instead of Anthropic's. It introduces environment variable configuration, an adapter translating Anthropic message format to OpenAI, model identifier mappings, and comprehensive documentation for multi-platform setup. Changes
Sequence DiagramsequenceDiagram
actor User
participant CodeClient as Code Client<br/>(CLAUDE_CODE_USE_OPENAI=true)
participant Adapter as OpenAI Adapter
participant OpenAI as OpenAI API
User->>CodeClient: Call message creation
CodeClient->>CodeClient: Check CLAUDE_CODE_USE_OPENAI env
CodeClient->>Adapter: Instantiate adapter with<br/>apiKey & baseURL
CodeClient->>Adapter: createMessage(messages, tools, etc)
Adapter->>Adapter: Convert Anthropic message<br/>format to OpenAI format
Adapter->>Adapter: Map tool schemas &<br/>system prompts
Adapter->>OpenAI: POST /chat/completions<br/>(with stream or non-stream)
OpenAI-->>Adapter: Response deltas/completion
Adapter->>Adapter: Convert OpenAI response<br/>to Anthropic message
Adapter->>Adapter: Map stop reasons &<br/>assemble content blocks
Adapter-->>CodeClient: Anthropic-compatible<br/>message object
CodeClient-->>User: Processed result
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Comment |
|
前天提交了一半忘提pr了,看到最新代码以及已经更新该功能了,快得离谱,现关闭pr |
Add comprehensive OpenAI API adapter to support OpenAI-compatible API endpoints, enabling users to use OpenAI models alongside Claude models.
Changes:
Closes #48
Summary by CodeRabbit
New Features
Documentation
Improvements