Expand description
Codex Convert Proxy Library
A library for converting between OpenAI Responses API (used by Codex) and Chat Completions API (used by Chinese LLM providers).
§Overview
Codex 0.118+ only supports the Responses API, but Chinese LLM providers (GLM, Kimi, DeepSeek, MiniMax) only support the Chat Completions API. This library provides bidirectional conversion between these formats.
§Features
lib: Provider trait + implementations + conversion + types (for embedding the conversion logic in other Rust applications)server(default): Full Pingora-based proxy binary (implieslib, adds config parsing, the HTTP server, CLI, and logging)telemetry: OpenTelemetry tracing/metrics exporters
§Usage (as library)
ⓘ
use codex_convert_proxy::{
response_to_chat, chat_to_response, chat_to_response_with_context,
chat_chunk_to_response_events, event_to_sse,
Provider, GLMProvider, create_provider,
StreamState, ResponseRequestContext, ResponseStreamEvent,
types::response_api::{ResponseRequest, InputItemOrString},
util::parse_sse,
};§Providers
Each Chinese LLM provider may have slightly different API requirements. Use the appropriate provider when converting:
GLMProvider- For Zhipu AI GLM modelsKimiProvider- For Moonshot AI Kimi modelsDeepSeekProvider- For DeepSeek modelsMiniMaxProvider- For MiniMax models
Re-exports§
pub use error::ConversionError;pub use error::ProxyError;pub use convert::chat_chunk_to_response_events;pub use convert::chat_to_response;pub use convert::chat_to_response_with_context;pub use convert::event_to_sse;pub use convert::response_to_chat;pub use convert::ResponseRequestContext;pub use convert::streaming::ResponseStreamEvent;pub use convert::streaming::StreamState;pub use stats::RequestRecord;pub use stats::RequestStats;pub use stats::StatsSummary;pub use stats::TokenUsage;pub use providers::create_provider;pub use providers::DeepSeekProvider;pub use providers::GLMProvider;pub use providers::KimiProvider;pub use providers::MiniMaxProvider;pub use providers::Provider;pub use config::BackendConfig;pub use config::BackendInfo;pub use config::BackendRouter;pub use config::ProxyConfig;pub use proxy::CodexProxy;pub use cli::Cli;pub use cli::Commands;pub use cli::StartArgs;pub use types::*;
Modules§
- cli
- CLI argument parsing module.
- config
- Configuration module for proxy settings and backend routing.
- constants
- 项目级配置常量
- convert
- Conversion between Responses API and Chat API.
- error
- Error types for the library.
- logger
- Logging module based on tracing ecosystem.
- providers
- Provider implementations for Chinese LLM services.
- proxy
- Proxy module for pingora integration.
- server
- Pingora server startup and configuration.
- stats
- Statistics and metrics module.
- types
- Type definitions for both API formats.
- util
- Utility modules.