ReqLLM.Providers.Zenmux (ReqLLM v1.14.0)

View Source

Zenmux provider – OpenAI Chat Completions compatible with Zenmux's unified API.

Implementation

Uses built-in OpenAI-style encoding/decoding defaults. No custom wrapper modules – leverages the standard OpenAI-compatible implementations.

Zenmux-Specific Extensions

Beyond standard OpenAI parameters, Zenmux supports:

  • provider - Provider routing configuration with routing strategy and fallback
  • model_routing_config - Model selection and routing within the same provider
  • reasoning - Reasoning process configuration (enable, depth, expose)
  • web_search_options - Web search tool configuration
  • verbosity - Output detail level (low, medium, high)

Provider Routing

Zenmux supports advanced provider routing with the provider option:

  • routing.type - Routing type (priority, round_robin, least_latency)
  • routing.primary_factor - Primary consideration (cost, speed, quality)
  • routing.providers - List of providers for routing
  • fallback - Failover strategy (true, false, or specific provider name)

Model Routing

Configure model selection with model_routing_config:

  • available_models - List of model names for routing
  • preference - Preferred model name
  • task_info - Task metadata (task_type, complexity)

See provider_schema/0 for the complete Zenmux-specific schema and ReqLLM.Provider.Options for inherited OpenAI parameters.

Configuration

# Add to .env file (automatically loaded)
ZENMUX_API_KEY=sk-ai-v1-...

Summary

Functions

Default implementation of attach/3.

Default implementation of attach_stream/4.

Default implementation of build_body/1.

Default implementation of decode_response/1.

Default implementation of decode_stream_event/2.

Custom body encoding that adds Zenmux-specific extensions to the default OpenAI-compatible format.

Default implementation of extract_usage/2.

Custom prepare_request for :object operations to maintain Zenmux-specific max_tokens handling.

Default implementation of translate_options/3.

Functions

attach(request, model_input, user_opts)

Default implementation of attach/3.

Sets up Bearer token authentication and standard pipeline steps.

attach_stream(model, context, opts, finch_name)

Default implementation of attach_stream/4.

Builds complete streaming requests using OpenAI-compatible format.

base_url()

build_body(request)

Default implementation of build_body/1.

Builds request body using OpenAI-compatible format for chat and embedding operations.

decode_response(request_response)

Default implementation of decode_response/1.

Handles success/error responses with standard ReqLLM.Response creation.

decode_stream_event(event, model)

Default implementation of decode_stream_event/2.

Decodes SSE events using OpenAI-compatible format.

default_base_url()

default_env_key()

Callback implementation for ReqLLM.Provider.default_env_key/0.

encode_body(request)

Custom body encoding that adds Zenmux-specific extensions to the default OpenAI-compatible format.

Adds support for Zenmux routing and configuration parameters:

  • provider (routing configuration)
  • model_routing_config (model selection)
  • reasoning (reasoning process config)
  • web_search_options (web search config)
  • verbosity (output detail level)
  • reasoning_effort (reasoning level)
  • max_completion_tokens (replaces max_tokens)

extract_usage(body, model)

Default implementation of extract_usage/2.

Extracts usage data from standard usage field in response body.

prepare_request(operation, model_spec, input, opts)

Custom prepare_request for :object operations to maintain Zenmux-specific max_tokens handling.

Ensures that structured output requests have adequate token limits while delegating other operations to the default implementation.

provider_extended_generation_schema()

provider_id()

provider_schema()

supported_provider_options()

translate_options(operation, model, opts)

Default implementation of translate_options/3.

Pass-through implementation that returns options unchanged.