Skip to main content

Crate codex_convert_proxy

Crate codex_convert_proxy 

Source
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

  • providers-lib: Provider trait + implementations + conversion functions (minimal embedding)
  • config-lib: BackendRouter and config types (optional, for standalone proxy)
  • lib: Alias for providers-lib
  • full (default): Full library including server functionality and CLI
  • server: Pingora-based proxy server (implies lib + config-lib)
  • binary: CLI binary support (alias for full)

§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:

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::streaming::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 telemetry::TelemetryConfig;
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.
telemetry
OpenTelemetry integration module.
types
Type definitions for both API formats.
util
Utility modules.